Re: string-append plus package

2017-01-02 Thread Ludovic Courtès
Hi!

Hartmut Goebel  skribis:

> To make GuixSD successful – and not just another marginal distribution –
> guix must support users and administrator to do there job. Otherwise
> they will stay with other distributions. Administrators are typically
> short in time and they are not programmes. If they are programming, they
> are used to bash, perl, python and other imperative languages. Maybe
> they have some experiences with tools like puppet or ansible, which
> introduce some declarative paradigm.

[...]

> If now guix is inconsistent to use (see below), or uses some "magic", or
> is complicated to learn, administrators will abstain from GuixSD.
>
> So the road to success is based on on simplicity, consistency and no magic.

Agreed!

> ATM, system declarations are *not* consistent: While in a package
> description (gnu/packages/*.scm) and in service definitions
> (gnu/service/*.scm) one can use "(string-append PACKAGE …)", this does

Not sure what you mean: (string-append PACKAGE STRING) never works if
PACKAGE is a package object.

> *not* work in system declarations (gnu/system/examples/*.tmpl). From an
> administrators point of view, there is no reason for this different
> behaviour. it's plain confusing.
>
> Adding on this: I took two weeks (not counting the delay caused on my
> side) to get a working answer for the simple question in this thread.
> Imagine some admin trying ot GuixSD and being delayed that long. He/she
> will just stop evaluating GuixSD.
>
> If GuixSD should become successful, you need to change this.

Agreed, except on one point: “we” instead of “you”.  It’s a
collaborative effort and no single person can “get it right” and fix
every single issue.

User experience feedback like this is crucial if we are to improve
things.

As a “fisherman” like you wrote, there are many issues that I don’t even
notice.  Reporting how the tool fails to meet your expectations like you
did is the first step towards improving it.  It may be obvious to you
that something is broken here, but it was not obvious to me until you
described your expectations.

So, thanks for helping out!

Ludo’.



Re: string-append plus package

2016-12-31 Thread Hartmut Goebel
Am 31.12.2016 um 00:42 schrieb Ludovic Courtès:
> Where does that string you want to build go to?

As I already wrote in my initial mail, I need to reference the actual
package output's path in some config-file within a system definition
(e.g. gnu/system/examples/nginx.tmpl).

So assume gnu/system/examples/nginx.tmpl to be:

(use-modules (gnu))
(use-package-modules networking web)
(define NGINX (package-output (open-connection) nginx))
(define TEST (string-append NGINX "/bin/nginxctl"))

If "package-output" is not the correct solution, please tell me the
correct one.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel  | h.goe...@crazy-compilers.com   |
| www.crazy-compilers.com | compilers which you thought are impossible |




Re: string-append plus package

2016-12-30 Thread Ludovic Courtès
Hey Hartmut,

Hartmut Goebel  skribis:

> Am 19.12.2016 um 10:47 schrieb Ludovic Courtès:
>> Hartmut Goebel  skribis:
>>
>>> Am 08.12.2016 um 20:56 schrieb Leo Famulari:
> Here is the service-definition I use:
>
>  (nginx-service #:vhost-list
>(list (nginx-vhost-configuration 
>   (root (string-append nginx "/share/nginx/html"))
 I believe that file-append is intended for this use case.
>>> Maybe, but I can't get it to work. This minimal system declarision fails
>>> with "In procedure string-append: Wrong type (expecting string):
>>> #< base: #>> 2a236c0> suffix: ("/")>"
>>>
>>> (use-modules (gnu))
>>> (use-package-modules networking web)
>>> (define NGINX (file-append nginx "/bin/nginxctl"))
>>> (define TEST (string-append NGINX ""))
>> […]For example:
>>
>>   (scheme-file "foo" #~(foo bar #$(file-append nginx "/foo/bar")))
>>
>> leads to a file “foo” containing:
>>
>>   (foo bar "/gnu/store/…-nginx-1.2.3/foo/bar")
>>
>> HTH!
>
> I now found time trying this out. Unfortunately this does not do what I
> expect. I do not need some string "(foo bar
> \"/gnu/store/…-nginx-1.2.3/foo/bar\")".
>
> I need the string "/gnu/store/…-nginx-1.2.3/bin/nginxctl". No gexpr, no
> scheme magic, no string representing scheme code. But simply a string
> containing the path of a file with the package (nginx in the example)
> which I can assign to some variable (NGINX as shown in the example) and
> then be used for other string operations (like when defining TEST in the
> example).
>
> I tried adopting your example but #~ always gave me a gexp, which of
> course I can't use in string-append.
>
> The manual says "Gexps are meant to be written to a file …" so I assume
> "file-append" is the wrong approach at all

Where does that string you want to build go to?

Depending on the answer, the solution would be either a gexp with
‘file-append’ or the solution that Mathieu outlined with
‘package-output’ (the latter looks simpler but is also more “risky” in
that that you could end up with strings that refer to nonexistent store
items.)

Ludo’.



Re: string-append plus package

2016-12-29 Thread Hartmut Goebel
Am 29.12.2016 um 14:06 schrieb Mathieu Lirzin:
>   (use-modules (guix)
>(gnu packages web))
>   (define conn (open-connection))
>   (package-output conn nginx) ;returns the actual string

Thanks, based on this I made it work

-- 
Regards
Hartmut Goebel

| Hartmut Goebel  | h.goe...@crazy-compilers.com   |
| www.crazy-compilers.com | compilers which you thought are impossible |




Re: string-append plus package

2016-12-29 Thread Mathieu Lirzin
Hi,

Hartmut Goebel  writes:

> Am 19.12.2016 um 10:47 schrieb Ludovic Courtès:
>> Hartmut Goebel  skribis:
>>
>>> Am 08.12.2016 um 20:56 schrieb Leo Famulari:
> Here is the service-definition I use:
>
>  (nginx-service #:vhost-list
>(list (nginx-vhost-configuration 
>   (root (string-append nginx "/share/nginx/html"))
 I believe that file-append is intended for this use case.
>>> Maybe, but I can't get it to work. This minimal system declarision fails
>>> with "In procedure string-append: Wrong type (expecting string):
>>> #< base: #>> 2a236c0> suffix: ("/")>"
>>>
>>> (use-modules (gnu))
>>> (use-package-modules networking web)
>>> (define NGINX (file-append nginx "/bin/nginxctl"))
>>> (define TEST (string-append NGINX ""))
>> […]For example:
>>
>>   (scheme-file "foo" #~(foo bar #$(file-append nginx "/foo/bar")))
>>
>> leads to a file “foo” containing:
>>
>>   (foo bar "/gnu/store/…-nginx-1.2.3/foo/bar")
>>
>> HTH!
>
> I now found time trying this out. Unfortunately this does not do what I
> expect. I do not need some string "(foo bar
> \"/gnu/store/…-nginx-1.2.3/foo/bar\")".
>
> I need the string "/gnu/store/…-nginx-1.2.3/bin/nginxctl". No gexpr, no
> scheme magic, no string representing scheme code. But simply a string
> containing the path of a file with the package (nginx in the example)
> which I can assign to some variable (NGINX as shown in the example) and
> then be used for other string operations (like when defining TEST in the
> example).

The trick is that "…" in the above string depends on the actual hash of
nginx which will change every time nginx (or its dependencies) is
updated.  So you need to "ask" the Guix API what is the string, like
this:

  (use-modules (guix)
   (gnu packages web))
  (define conn (open-connection))
  (package-output conn nginx) ;returns the actual string

However I guess this would not be that useful in the context of writing
a service.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37



Re: string-append plus package

2016-12-29 Thread Hartmut Goebel
Am 19.12.2016 um 10:47 schrieb Ludovic Courtès:
> Hartmut Goebel  skribis:
>
>> Am 08.12.2016 um 20:56 schrieb Leo Famulari:
 Here is the service-definition I use:

  (nginx-service #:vhost-list
(list (nginx-vhost-configuration 
   (root (string-append nginx "/share/nginx/html"))
>>> I believe that file-append is intended for this use case.
>> Maybe, but I can't get it to work. This minimal system declarision fails
>> with "In procedure string-append: Wrong type (expecting string):
>> #< base: #> 2a236c0> suffix: ("/")>"
>>
>> (use-modules (gnu))
>> (use-package-modules networking web)
>> (define NGINX (file-append nginx "/bin/nginxctl"))
>> (define TEST (string-append NGINX ""))
> […]For example:
>
>   (scheme-file "foo" #~(foo bar #$(file-append nginx "/foo/bar")))
>
> leads to a file “foo” containing:
>
>   (foo bar "/gnu/store/…-nginx-1.2.3/foo/bar")
>
> HTH!

I now found time trying this out. Unfortunately this does not do what I
expect. I do not need some string "(foo bar
\"/gnu/store/…-nginx-1.2.3/foo/bar\")".

I need the string "/gnu/store/…-nginx-1.2.3/bin/nginxctl". No gexpr, no
scheme magic, no string representing scheme code. But simply a string
containing the path of a file with the package (nginx in the example)
which I can assign to some variable (NGINX as shown in the example) and
then be used for other string operations (like when defining TEST in the
example).

I tried adopting your example but #~ always gave me a gexp, which of
course I can't use in string-append.

The manual says "Gexps are meant to be written to a file …" so I assume
"file-append" is the wrong approach at all

Could you please correct my above example?. Thanks.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel  | h.goe...@crazy-compilers.com   |
| www.crazy-compilers.com | compilers which you thought are impossible |




Re: string-append plus package

2016-12-19 Thread Ludovic Courtès
Hartmut Goebel  skribis:

> Am 19.12.2016 um 10:47 schrieb Ludovic Courtès:
>> The result of ‘file-append’ is not a string, but ‘string-append’ expects
>> two strings, hence the error.
>>
>> ‘file-append’ returns a “string-valued gexp”.  This is to say that, in a
>> staging context, it will produce a string.  For example:
>>
>>   (scheme-file "foo" #~(foo bar #$(file-append nginx "/foo/bar")))
>>
>> leads to a file “foo” containing:
>>
>>   (foo bar "/gnu/store/…-nginx-1.2.3/foo/bar")
>
> Thanks for the explanation (which to be frank would take me some time to
> understand).
>
> Please reread you answer from the point of view of an administrator or
> somebody else who is not a Scheme programmer. Somebody who just wants to
> get some system up an running. He would answer like this:
>
> Parton? What? "string-valued gexp", "staging context"? I do not
> care. I simply want to get the path to a file within a package.
>
> Whatever you write above may be correct and may be understandable for
> every Scheme programmer. But this is discouraging for everybody who does
> not want to become a Scheme expert for administering his/her systems.
>
> I already wasted about an hour just to try to get this path! This is crap!

I agree!  The first two lines were all you wanted to know; the rest was
for you as someone who contributes to Scheme—I would not give that
explanation to someone who’s just trying to get nginx up and running.

As for the specifics of why ‘nginx-configuration’ makes this use case
complicated, I think we discussed it on guix-devel before, and there was
probably an action item, but “someone” just needs to make it happen or
at least to keep track of it.

HTH!  :-)

Ludo’.



Re: string-append plus package

2016-12-08 Thread Thompson, David
On Thu, Dec 8, 2016 at 12:46 PM, Hartmut Goebel
 wrote:
> Am 08.12.2016 um 18:28 schrieb Thompson, David:
>> This isn't a bug.  string-append is a procedure provided by Guile and
>> it only works on strings.
>
> I don't care whether this is a bug or not. I need to get the package's
> directory. And i works when using in a package definition.

Apologies Hartmut, I misread this as being sent to bug-guix.

- Dave



Re: string-append plus package

2016-12-08 Thread Thompson, David
On Thu, Dec 8, 2016 at 12:01 PM, Hartmut Goebel
 wrote:
> Hi,
>
> I'm confused about string-append working inconsistently:
>
> In package definitions, I'm used to write '(string-append PKG "…")'. But
> when I use this for defining a service, I get an error:
>
> In procedure string-append: Wrong type (expecting string): # nginx@1.11.6 gnu/packages/web.scm:124 42449c0>
>
> What is going on here?
>
> Here is the service-definition I use:
>
>  (nginx-service #:vhost-list
>(list (nginx-vhost-configuration
>   (root (string-append nginx "/share/nginx/html"))
>   (https-port #f)
>   (ssl-certificate #f)
>   (ssl-certificate-key #f

This isn't a bug.  string-append is a procedure provided by Guile and
it only works on strings.

- Dave