bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toward 0.2


From: Ludovic Courtès
Subject: Re: Toward 0.2
Date: Fri, 01 Mar 2013 10:15:18 +0100
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)

Nikita Karetnikov <address@hidden> skribis:

>> Remember that (guix build ...) modules must not use Guix modules other
>> than (guix build ...).  This is a convention to distinguish between code
>> for the “builder stratum”, and code for the “host stratum”.
>
> OK.  But how can I get the location of a package?  The needed procedure
> (i.e., 'package-output') is in the host code.

It’s not needed.  All that needed is the name of the executable file to wrap.

>> (define* (wrap-program file #:rest variables)
>>    ...)
>
> Why do you want to use '#:rest' here?  The purpose of 'wrap-program' is
> to export some variables.

For the case where there are have several variables you want to set.

>> export CERT_PATH=$CERT_PATH${CERT_PATH:+:}:/nix/.../share/certs
>
> Could you explain the "$CERT_PATH${CERT_PATH:+:}" part?

The :+ part is to add a colon if and only if $CERT_PATH is non-empty
(info "(bash) Shell Parameter Expansion").

Otherwise you could end up with a value like “:/foo”, but the first
empty element (before the colon) is usually equivalent to “.”, and we
don’t want that.

>> Perhaps the separator string could be optional.
>
> Is it possible to make it optional without creating a separate clause?

No, you’d need an additional clause.

> +(define (wrap-program prog varlst)
> +  "Copy PROG to .PROG-real and make PROG a wrapper."

Could you document what the wrapper does, and what the grammar of
‘varlst’ (rather call it ‘vars’) is?

> +  (define (export-envvar lst)

‘export-variable’, rather.

> +    (define (separate lst delim)

You ‘string-join’ instead:

  (string-join '("a" "b") ":")
  => "a:b"

> +    ;; TODO: Make SEP optional.
> +    (match lst
> +           ((var sep '= rest)
> +            (format #f "export ~a=\"~a\""
> +                    var (separate rest sep)))
> +
> +           ((var sep 'prefix rest)
> +            (format #f "export ~a=\"~a~a${~a~a+~a}$~a\""
> +                    var (separate rest sep) sep var sep sep var))
> +
> +           ((var sep 'suffix rest)
> +            (format #f "export ~a=\"$~a${~a~a+~a}~a~a\""
> +                    var var var sep sep sep (separate rest sep)))))

Good (please indent like other uses of ‘match’ in this file).

> +  ;; XXX: Use an absolute filename; remove '-real'.
> +  (format #f "#!~a~%~aexec ./.~a-real~%"
> +          (which "bash")
> +
> +          (fold-right (lambda (x acc)
> +                        (string-append x "\n" acc))
> +                      ""
> +                      (map export-envvar varlst))

string-join

> +          prog)) ; XXX: use a real program instead

Just (canonicalize-path prog).

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]