about summary refs log tree commit diff
path: root/src/libutil/util.hh
AgeCommit message (Collapse)AuthorFilesLines
2019-09-03 Add some noexceptsEelco Dolstra1-2/+2
This is to assert that callback functions should never throw (since the context in which they're called may not be able to handle the exception).
2019-09-03 Ensure that Callback is called only onceEelco Dolstra1-3/+16
Also, make Callback movable but uncopyable.
2019-08-02 Add a post-build-hookregnat1-0/+2
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-15 Merge pull request #2810 from NixOS/print-build-logsEelco Dolstra1-0/+1
nix: Add --print-build-logs flag
2019-05-15 nix: Add --print-build-logs flagEelco Dolstra1-0/+1
This causes 'nix' to print build log output to stderr rather than showing the last log line in the progress bar. Log lines are prefixed by the name of the derivation (minus the version string), e.g. binutils> make[1]: Leaving directory '/build/binutils-2.31.1' binutils-wrapper> unpacking sources binutils-wrapper> patching sources ... binutils-wrapper> Using dynamic linker: '/nix/store/kr51dlsj9v5cr4n8700jliyz8v5b2q7q-bootstrap-stage0-glibc/lib/ld-linux-x86-64.so.2' bootstrap-stage2-gcc-wrapper> unpacking sources ... linux-headers> unpacking sources linux-headers> unpacking source archive /nix/store/8javli69jhj3bkql2c35gsj5vl91p382-linux-4.19.16.tar.xz
2019-05-12 runProgram: support gid, uid, chdirGraham Christensen1-2/+3
2019-05-12 diff hook: execute as the build user, and pass the temp dirGraham Christensen1-0/+2
2019-05-03 Fix "Bad system call" running i686-linux binaries on x86_64-linuxEelco Dolstra1-0/+4
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-3/+3
2019-02-05 Revert "Restore parent mount namespace before executing a child process"Eelco Dolstra1-10/+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-11-15 Fix 'Read-only file system' when building a derivationEelco Dolstra1-0/+1
2018-11-13 Restore parent mount namespace before executing a child processEelco Dolstra1-0/+9
This ensures that they can't write to /nix/store. Fixes #2535.
2018-10-31 config: use all of XDG_CONFIG_DIRSLinus Heckemann1-0/+3
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-05-30 Make <nix/fetchurl.nix> run in constant memoryEelco Dolstra1-0/+2
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-0/+1
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-05-30 Simplify the callback mechanismEelco Dolstra1-33/+20
2018-03-20 Hack to get SSH error messages from build-remoteEelco Dolstra1-2/+2
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-2/+2
(cherry picked from commit c389a7fb617ed7bcd617efa68c6a48c00405310d)
2018-03-16 decompress(): Use a Source and SinkEelco Dolstra1-0/+8
This allows decompression to happen in O(1) memory.
2018-03-15 Filter ANSI colors when not writing to a terminalEelco Dolstra1-4/+6
Fixes https://github.com/NixOS/nixpkgs/issues/37114.
2018-02-26 nix run: Fix segfault on macOSEelco Dolstra1-0/+3
Note that clearenv() is not available on macOS. Fixes #1907.
2018-02-07 Improve filtering of ANSI escape sequences in build logsEelco Dolstra1-4/+6
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-2/+4
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-01 fetchMercurial: Don't fetch hashes we already haveEelco Dolstra1-0/+17
2017-10-30 builtins.fetchgit: Support importing a working treeEelco Dolstra1-0/+6
For example, you can write src = fetchgit ./.; and if ./. refers to an unclean working tree, that tree will be copied to the Nix store. This removes the need for "cleanSource".
2017-10-25 Pass lists/attrsets to bash as (associative) arraysEelco Dolstra1-4/+2
2017-09-08 ThreadPool: On exception, interrupt the other worker threadsEelco Dolstra1-1/+4
2017-08-25 Handle SIGWINCHEelco Dolstra1-0/+10
2017-08-18 Remove unused decodeOctalEscapedAndy Wingo1-6/+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-16 Progress indicator: Show number of active itemsEelco Dolstra1-0/+14
2017-08-09 Use /proc/self/fd to efficiently close all FDs on LinuxEelco Dolstra1-2/+2
Issue #1506.
2017-05-16 Improve progress indicatorEelco Dolstra1-0/+2
2017-05-05 Figure out the user's home directory if $HOME is not setEelco Dolstra1-0/+3
2017-04-25 nix repl: Use $XDG_DATA_HOME for the readline historyEelco Dolstra1-0/+3
2017-04-21 add helper function to set 'interruptThrown'David McFarland1-1/+1
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-1/+4
2017-03-21 Move istringstream_nocopy to a separate fileEelco Dolstra1-88/+0
2017-03-20 Merge branch 'darwin-s3-binary-cache-store' of https://github.com/shlevy/nixEelco Dolstra1-0/+87
2017-03-16 Remove "killing process <pid>" messagesEelco Dolstra1-1/+1
They convey no useful information.
2017-03-15 runProgram(): Distinguish between empty input and no inputEelco Dolstra1-1/+3
For example, if we call brotli with an empty input, it shouldn't read from the caller's stdin.
2017-03-08 Add missing header <sstream>Adrien Devresse1-0/+1
2017-03-06 istringstream_nocopy: Implement in a standards-compliant way.Shea Levy1-0/+87
Fixes the problem mentioned in e6a61b8da788efbbbb0eb690c49434b6b5fc9741 See #1135
2017-02-16 Support netrc in <nix/fetchurl.nix>Eelco Dolstra1-1/+1
This allows <nix/fetchurl.nix> to fetch private Git/Mercurial repositories, e.g. import <nix/fetchurl.nix> { url = https://edolstra@bitbucket.org/edolstra/my-private-repo/get/80a14018daed.tar.bz2; sha256 = "1mgqzn7biqkq3hf2697b0jc4wabkqhmzq2srdymjfa6sb9zb6qs7"; } where /etc/nix/netrc contains: machine bitbucket.org login edolstra password blabla... This works even when sandboxing is enabled. To do: add unpacking support (i.e. fetchzip functionality).
2017-02-01 Restore default signal handling in child processesEelco Dolstra1-4/+3
In particular, this fixes Ctrl-C in nix-shell sessions.
2017-01-26 Fix interrupt handlingEelco Dolstra1-0/+16
2017-01-19 Merge pull request #981 from shlevy/build-remote-c++Eelco Dolstra1-0/+3
build-remote: Implement in C++
2017-01-19 Kill builds when we get EOF on the log FDEelco Dolstra1-5/+6
This closes a long-time bug that allowed builds to hang Nix indefinitely (regardless of timeouts) simply by doing exec > /dev/null 2>&1; while true; do true; done Now, on EOF, we just send SIGKILL to the child to make sure it's really gone.
2017-01-19 CleanupEelco Dolstra1-5/+4
2017-01-17 Handle SIGINT etc. via a sigwait() signal handler threadEelco Dolstra1-1/+16
This allows other threads to install callbacks that run in a regular, non-signal context. In particular, we can use this to signal the downloader thread to quit. Closes #1183.
2017-01-16 AutoCloseDir: Use std::unique_ptrEelco Dolstra1-9/+6