about summary refs log tree commit diff
path: root/src/libutil/util.cc
AgeCommit message (Collapse)AuthorFilesLines
2019-08-02 Add a post-build-hookregnat1-1/+22
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-05-12 runProgram: Uncomment chdir supportGraham Christensen1-2/+2
2019-05-12 runProgram: support gid, uid, chdirGraham Christensen1-2/+13
2019-05-12 diff hook: execute as the build user, and pass the temp dirGraham Christensen1-2/+2
2019-05-03 Fix "Bad system call" running i686-linux binaries on x86_64-linuxEelco Dolstra1-0/+3
To determine which seccomp filters to install, we were incorrectly using settings.thisSystem, which doesn't denote the actual system when --system is used. Fixes #2791.
2019-03-14 experimental/optional -> optionalEelco Dolstra1-1/+1
2019-02-05 Revert "Restore parent mount namespace before executing a child process"Eelco Dolstra1-24/+0
This reverts commit a0ef21262f4d5652bfb65cfacaec01d89c475a93. This doesn't work in 'nix run' and nix-shell because setns() fails in multithreaded programs, and Boehm GC mark threads are uncancellable. Fixes #2646.
2018-12-13 probably typovolth1-1/+1
...at least MSVC unable to compile this
2018-11-15 Fix 'Read-only file system' when building a derivationEelco Dolstra1-1/+2
2018-11-13 Restore parent mount namespace before executing a child processEelco Dolstra1-0/+23
This ensures that they can't write to /nix/store. Fixes #2535.
2018-10-31 config: use all of XDG_CONFIG_DIRSLinus Heckemann1-0/+9
Previously, config would only be read from XDG_CONFIG_HOME. This change allows reading config from additional directories, which enables e.g. per-project binary caches or chroot stores with the help of direnv.
2018-09-13 Merge branch 'dirOf-relative' of https://github.com/lheckemann/nixEelco Dolstra1-1/+1
2018-09-04 Get effective user in Nix commandsMatthew Bauer1-1/+1
‘geteuid’ gives us the user that the command is being run as, including in setuid modes. By using geteuid to determind id, we can avoid the ‘sudo -i’ hack when upgrading Nix. So now, upgrading Nix on macOS is as simple as: $ sudo nix-channel --update $ sudo nix-env -u $ sudo launchctl stop org.nixos.nix-daemon $ sudo launchctl start org.nixos.nix-daemon or $ sudo systemctl restart nix-daemon
2018-08-13 dirOf: allow use on non-absolute pathsLinus Heckemann1-1/+1
2018-05-30 Make <nix/fetchurl.nix> run in constant memoryEelco Dolstra1-0/+17
E.g. nix-build --store ~/my-nix/ -E 'import <nix/fetchurl.nix> { url = https://cache.nixos.org/nar/0nwi996rgq4b914qyx0mv2wq4k80hjac7xilikavagw7kxmn2iiv.nar.xz; sha256 = "0nwi996rgq4b914qyx0mv2wq4k80hjac7xilikavagw7kxmn2iiv"; }' now runs in 17 MiB (was 70 MiB), while nix-build --store ~/my-nix/ -E 'import <nix/fetchurl.nix> { url = https://cache.nixos.org/nar/0nwi996rgq4b914qyx0mv2wq4k80hjac7xilikavagw7kxmn2iiv.nar.xz; sha256 = "0d2fxljdih3nc5dqx41hjzic3141ajil94m8kdbpryq569dpsbvb"; unpack = true; }' runs in 17 MiB (was 346 MiB).
2018-05-30 Make LocalBinaryCacheStore::narFromPath() run in constant memoryEelco Dolstra1-1/+9
This reduces memory consumption of nix copy --from file://... --to ~/my-nix /nix/store/95cwv4q54dc6giaqv6q6p4r02ia2km35-blender-2.79 from 514 MiB to 18 MiB for an uncompressed binary cache, and from 192 MiB to 53 MiB for a bzipped binary cache. It may also be faster because fetching can happen concurrently with decompression/writing. Continuation of 48662d151bdf4a38670897beacea9d1bd750376a. Issue https://github.com/NixOS/nix/issues/1681.
2018-03-22 Merge branch 'fix/avoid-large-stack-buffers' of https://github.com/dtzWill/nixEelco Dolstra1-8/+9
2018-03-20 Hack to get SSH error messages from build-remoteEelco Dolstra1-3/+20
E.g. cannot build on 'ssh://mac1': cannot connect to 'mac1': bash: nix-store: command not found cannot build on 'ssh://mac2': cannot connect to 'mac2': Host key verification failed. cannot build on 'ssh://mac3': cannot connect to 'mac3': Received disconnect from 213... port 6001:2: Too many authentication failures Authentication failed.
2018-03-19 util: rename stdout/stdin members to avoid conflicts w/standard macroWill Dietz1-7/+7
(cherry picked from commit c389a7fb617ed7bcd617efa68c6a48c00405310d)
2018-03-16 decompress(): Use a Source and SinkEelco Dolstra1-15/+60
This allows decompression to happen in O(1) memory.
2018-03-15 Filter ANSI colors when not writing to a terminalEelco Dolstra1-2/+2
Fixes https://github.com/NixOS/nixpkgs/issues/37114.
2018-03-02 don't allocate large buffers on the stackWill Dietz1-11/+12
2018-02-26 nix run: Fix segfault on macOSEelco Dolstra1-0/+7
Note that clearenv() is not available on macOS. Fixes #1907.
2018-02-19 libutil: Fix infinite loop in filterANSIEscapes on '\r'Tuomas Tynkkynen1-1/+1
E.g. nix-instantiate --eval -E 'abort "\r"' hangs. Found by afl-fuzz.
2018-02-07 Improve filtering of ANSI escape sequences in build logsEelco Dolstra1-26/+41
All ANSI sequences except color setting are now filtered out. In particular, terminal resets (such as from NixOS VM tests) are filtered out. Also, fix the completely broken tab character handling.
2018-01-16 Add pure evaluation modeEelco Dolstra1-0/+6
In this mode, the following restrictions apply: * The builtins currentTime, currentSystem and storePath throw an error. * $NIX_PATH and -I are ignored. * fetchGit and fetchMercurial require a revision hash. * fetchurl and fetchTarball require a sha256 attribute. * No file system access is allowed outside of the paths returned by fetch{Git,Mercurial,url,Tarball}. Thus 'nix build -f ./foo.nix' is not allowed. Thus, the evaluation result is completely reproducible from the command line arguments. E.g. nix build --pure-eval '( let nix = fetchGit { url = https://github.com/NixOS/nixpkgs.git; rev = "9c927de4b179a6dd210dd88d34bda8af4b575680"; }; nixpkgs = fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-17.09"; rev = "66b4de79e3841530e6d9c6baf98702aa1f7124e4"; }; in (import (nix + "/release.nix") { inherit nix nixpkgs; }).build.x86_64-linux )' The goal is to enable completely reproducible and traceable evaluation. For example, a NixOS configuration could be fully described by a single Git commit hash. 'nixos-rebuild' would do something like nix build --pure-eval '( (import (fetchGit { url = file:///my-nixos-config; rev = "..."; })).system ') where the Git repository /my-nixos-config would use further fetchGit calls or Git externals to fetch Nixpkgs and whatever other dependencies it has. Either way, the commit hash would uniquely identify the NixOS configuration and allow it to reproduced.
2017-11-20 CleanupEelco Dolstra1-2/+2
2017-11-20 Merge pull request #1645 from twhitehead/stat-raceEelco Dolstra1-12/+11
Fix (highly unlikely) race condition in readLink
2017-11-01 fetchMercurial: Don't fetch hashes we already haveEelco Dolstra1-15/+26
2017-10-30 Fix (highly unlikely) race condition in readLinkTyson Whitehead1-12/+11
Used to determine symlink size with stat and value with readlink. This could technically result in garbage if symlink changed between calls. Also gets around the broken stat implementation in our network filesystem (returns size + 1 giving a byte of garbage).
2017-10-25 Pass lists/attrsets to bash as (associative) arraysEelco Dolstra1-0/+10
2017-09-08 ThreadPool: On exception, interrupt the other worker threadsEelco Dolstra1-1/+1
2017-08-29 readLink(): Handle symlinks in /procEelco Dolstra1-4/+5
Symlinks like /proc/self/exe report a stat() size of 0, so use a buffer of at least PATH_MAX instead.
2017-08-25 Handle SIGWINCHEelco Dolstra1-0/+28
2017-08-25 TypoEelco Dolstra1-1/+1
2017-08-18 Remove unused decodeOctalEscapedAndy Wingo1-15/+0
Besides being unused, this function has a bug that it will incorrectly decode the path component Ubuntu\04016.04.2\040LTS\040amd64 as "Ubuntu.04.2 LTS amd64" instead of "Ubuntu 16.04.2 LTS amd64".
2017-08-09 Use /proc/self/fd to efficiently close all FDs on LinuxEelco Dolstra1-2/+16
Issue #1506.
2017-07-30 Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim1-28/+28
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-07-11 replaceSymlink(): Handle the case where the temporary file already existsEelco Dolstra1-4/+13
Not really necessary anymore for #849, but still nice to have.
2017-06-12 Suppress spurious "killing process N: Operation not permitted" on macOSEelco Dolstra1-2/+9
2017-05-16 Improve progress indicatorEelco Dolstra1-1/+1
2017-05-05 Figure out the user's home directory if $HOME is not setEelco Dolstra1-17/+28
2017-05-01 Minor cleanupEelco Dolstra1-2/+2
2017-04-25 nix repl: Use $XDG_DATA_HOME for the readline historyEelco Dolstra1-0/+12
2017-04-21 add helper function to set 'interruptThrown'David McFarland1-1/+6
this fixes a linker failure on cygwin 64 due to some bad interaction between tls and shared libraries. see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64697
2017-04-20 Read per-user settings from ~/.config/nix/nix.confEelco Dolstra1-0/+12
2017-04-13 canonPath(): Check against empty pathsEelco Dolstra1-0/+2
2017-04-06 Fix bogus "unexpected Nix daemon error: interrupted by the user"Eelco Dolstra1-2/+2
2017-03-16 Remove "killing process <pid>" messagesEelco Dolstra1-3/+2
They convey no useful information.
2017-03-15 runProgram(): Distinguish between empty input and no inputEelco Dolstra1-10/+23
For example, if we call brotli with an empty input, it shouldn't read from the caller's stdin.