lix/doc/manual/command-ref
regnat 7c5596734f
Add a post-build-hook
Passing `--post-build-hook /foo/bar` to a nix-* command will cause
`/foo/bar` to be executed after each build with the following
environment variables set:

    DRV_PATH=/nix/store/drv-that-has-been-built.drv
    OUT_PATHS=/nix/store/...build /nix/store/...build-bin /nix/store/...build-dev

This can be useful in particular to upload all the builded artifacts to
the cache (including the ones that don't appear in the runtime closure
of the final derivation or are built because of IFD).

This new feature prints the stderr/stdout output to the `nix-build`
and `nix build` client, and the output is printed in a Nix 2
compatible format:

    [nix]$ ./inst/bin/nix-build ./test.nix
    these derivations will be built:
      /nix/store/ishzj9ni17xq4hgrjvlyjkfvm00b0ch9-my-example-derivation.drv
    building '/nix/store/ishzj9ni17xq4hgrjvlyjkfvm00b0ch9-my-example-derivation.drv'...
    hello!
    bye!
    running post-build-hook '/home/grahamc/projects/github.com/NixOS/nix/post-hook.sh'...
    post-build-hook: + sleep 1
    post-build-hook: + echo 'Signing paths' /nix/store/qr213vjmibrqwnyp5fw678y7whbkqyny-my-example-derivation
    post-build-hook: Signing paths /nix/store/qr213vjmibrqwnyp5fw678y7whbkqyny-my-example-derivation
    post-build-hook: + sleep 1
    post-build-hook: + echo 'Uploading paths' /nix/store/qr213vjmibrqwnyp5fw678y7whbkqyny-my-example-derivation
    post-build-hook: Uploading paths /nix/store/qr213vjmibrqwnyp5fw678y7whbkqyny-my-example-derivation
    post-build-hook: + sleep 1
    post-build-hook: + printf 'very important stuff'
    /nix/store/qr213vjmibrqwnyp5fw678y7whbkqyny-my-example-derivation

    [nix-shell:~/projects/github.com/NixOS/nix]$ ./inst/bin/nix build -L -f ./test.nix
    my-example-derivation> hello!
    my-example-derivation> bye!
    my-example-derivation (post)> + sleep 1
    my-example-derivation (post)> + echo 'Signing paths' /nix/store/c263gzj2kb2609mz8wrbmh53l14wzmfs-my-example-derivation
    my-example-derivation (post)> Signing paths /nix/store/c263gzj2kb2609mz8wrbmh53l14wzmfs-my-example-derivation
    my-example-derivation (post)> + sleep 1
    my-example-derivation (post)> + echo 'Uploading paths' /nix/store/c263gzj2kb2609mz8wrbmh53l14wzmfs-my-example-derivation
    my-example-derivation (post)> Uploading paths /nix/store/c263gzj2kb2609mz8wrbmh53l14wzmfs-my-example-derivation
    my-example-derivation (post)> + sleep 1
    my-example-derivation (post)> + printf 'very important stuff'
    [1 built, 0.0 MiB DL]

Co-authored-by: Graham Christensen <graham@grahamc.com>
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2019-08-02 10:48:15 -04:00
..
command-ref.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
conf-file.xml Add a post-build-hook 2019-08-02 10:48:15 -04:00
env-common.xml docs: describe $IN_NIX_SHELL values (#2796) 2019-05-17 09:50:42 +02:00
files.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
main-commands.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
nix-build.xml Remove docs on removed --drv-link and --add-drv-link options 2018-02-01 16:40:58 +01:00
nix-channel.xml nix-channel: Don't fetch binary-cache-url 2019-06-25 13:27:16 +02:00
nix-collect-garbage.xml nix-collect-garbage: little doc fix 2018-04-30 09:36:46 -07:00
nix-copy-closure.xml Don't look for a "pv" program, or mention it in the manual source 2019-01-07 16:40:19 -05:00
nix-daemon.xml Fix references to version.txt 2014-09-16 14:57:45 +02:00
nix-env.xml Merge pull request #767 from mogorman/garbage_collect_keep_last_few 2018-05-31 10:00:21 +02:00
nix-hash.xml Escape left angle brackets in XML documentation 2017-12-09 15:31:03 +00:00
nix-instantiate.xml Clarify nix-instantiate --read-write-mode 2018-12-14 09:36:40 +01:00
nix-prefetch-url.xml man page (nix-prefetch-url): Add some missing options 2017-07-07 22:11:46 +02:00
nix-shell.xml Update instructions for Haskell script using nix-shell interpreter 2019-01-18 10:50:54 +10:00
nix-store.xml Merge pull request #2779 from LnL7/build-exit-codes 2019-07-02 17:37:49 +02:00
opt-common-syn.xml doc: Adds --quiet to the common options. 2018-04-20 16:34:06 -04:00
opt-common.xml docs: Mention --max-jobs 0 to build remotely only 2019-03-31 03:57:45 +02:00
opt-inst-syn.xml Restructuring the Nix manual 2014-08-27 18:41:09 +02:00
utilities.xml Nuke nix-push. 2016-08-10 11:13:11 -04:00