[Top][All Lists]

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

Re: running a shell script in a snippet

From: Ludovic Courtès
Subject: Re: running a shell script in a snippet
Date: Thu, 19 Jan 2017 17:38:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)


Ricardo Wurmus <address@hidden> skribis:

> Shogun comes with a script to remove all non-free source files and
> sections.  Previously we removed the non-free code in a snippet with
> some Guile code.  It would be better to use the upstream script, because
> it’s hard to keep the Guile code in sync with upstream changes.
> So I thought I could just run the script in the snippet, but there is no
> shell at the time when the snippet is executed.

That makes sense, assuming the script really does what we want.

> Patching and snippet application happens in an environment where the
> result of “%standard-patch-inputs” (a procedure in “(guix packages)”)
> is available.  If a package defines “patch-inputs” those inputs would be
> available instead.
> I tried to specify “patch-inputs” for shogun, but I cannot get this to
> work.  This is the naive way:
>        (patch-inputs
>         `(("bash" ,bash)
>           ("tar" ,tar)
>           ("bzip2" ,bzip2)
>           ("patch" ,patch)))
>        (snippet
>         `(zero? (system* "bash" "scripts/")))

In fact, I think you can leave ‘patch-inputs’ as is and write:

    #~(zero? (system* #+(file-append bash "/bin/sh") …)))

A little-known feature.  ;-)

(That doesn’t solve the circular dependency problem though.)

> I changed the field to be thunked and changed “origin->derivation” to
> unthunk the inputs before passing them to “patch-and-repack”, but here’s
> the next problem: “patch-and-repack” doesn’t set the PATH to include all
> patch-inputs.  This means that overriding “patch-inputs” gets me
> nowhere.
> So here’s a patch that triggers a rebuild of everything, which – I guess
> — does the right thing.  Since it causes a rebuild of the world I
> couldn’t actually confirm that it helps.
> From b2647c307165a995aa68dc9b83c533c6c05fabf2 Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <address@hidden>
> Date: Thu, 19 Jan 2017 14:11:05 +0100
> Subject: [PATCH] WIP: thunk patch-inputs.
> * guix/packages.scm (<origin>): Mark "patch-inputs" as thunked.
> (patch-and-repack): Add "bin" directories of all inputs to the PATH.
> (origin->derivation): Unthunk patch inputs when necessary.

Could you separate the PATH thing and commit it to ‘core-updates’?

The rest of the patch LGTM, and is OK for master.

Another approach would be to make ‘snippet’ thunked, so you could use
the gexp shown above.

Yet another one (probably better) would be to introduce a <gexp-delay>
type with its own “gexp compiler”, so that one could write

  #~(system* #+(file-append (gexp-delay bash) …) …)

and the promise would be forced only when the gexp is compiled.


reply via email to

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