aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build
AgeCommit message (Collapse)Author
2019-12-14nix-shell: don't check for "nix-shell" in shebang script nameAlbert Safin
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-11-22getEnv(): Return std::optionalEelco Dolstra
This allows distinguishing between an empty value and no value.
2019-10-27SimplificationEelco Dolstra
2019-10-27Add inNixShell = true to nix-shell auto-callRobert Hensing
This is an alternative to the IN_NIX_SHELL environment variable, allowing the expression to adapt itself to nix-shell without triggering those adaptations when used as a dependency of another shell. Closes #3147
2019-10-09nix-build: Fix compilationEelco Dolstra
2019-10-08Don’t source bashrc in pure modeMatthew Bauer
Pure mode should not try to source the user’s bashrc file. These may have many impurities that the user does not expect to get into their shell. Fixes #3090
2019-10-02Fix indentationEelco Dolstra
2019-09-22Don't catch exceptions by valueEelco Dolstra
(cherry picked from commit 893be6f5e36abb58bbaa9c49055a5218114dd514)
2019-05-08nix-shell: Don't absolutize '-p' expressionsEelco Dolstra
This prevents spurious syscalls like 25011 lstat("/home/eelco/with import <nixpkgs> { }; (pkgs.runCommandCC or pkgs.runCommand) \"shell\" { buildInputs = [ (hello) ]; } \"\"", 0x7ffe9c67f580) = -1 ENOENT (No such file or directory)
2019-02-05Revert "Restore parent mount namespace before executing a child process"Eelco Dolstra
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-13Restore parent mount namespace before executing a child processEelco Dolstra
This ensures that they can't write to /nix/store. Fixes #2535.
2018-10-26Merge all nix-* binaries into nixEelco Dolstra
These are all symlinks to 'nix' now, reducing the installed size by about ~1.7 MiB.
2018-09-27nix-shell: add bashInteractive to the start of the PATH, set SHELLGraham Christensen
Tools which re-exec `$SHELL` or `$0` or `basename $SHELL` or even just `bash` will otherwise get the non-interactive bash, providing a broken shell for the same reasons described in https://github.com/NixOS/nixpkgs/issues/27493. Extends c94f3d5575d7af5403274d1e9e2f3c9d72989751
2018-08-31nix-build: Print stats even in failing buildsGraham Christensen
2018-08-31nix-build: print stats on sucessful buildsGraham Christensen
2018-08-20Drop all references to NIX_INDENT_MAKETuomas Tynkkynen
Dead code since https://github.com/NixOS/nixpkgs/commit/6669a3b47711dc967df0ea8ff93fa9857aad015d
2018-08-03Merge pull request #2323 from samueldr/feature/selective-impurityEelco Dolstra
Allows selectively adding environment variables to pure shells.
2018-08-02Allows selectively adding environment variables to pure shells.Samuel Dionne-Riel
Includes documentation and test.
2018-08-01Removes unused variable from `nix-build/nix-shell`Samuel Dionne-Riel
This particular `shell` variable wasn't used, since a new one was declared in the only side of the `if` branch that used a `shell` variable. It could realistically confuse developers thinking it could use `$SHELL` under some situations.
2018-06-12Move EvalState from the stack to the heapEelco Dolstra
EvalState contains a few counters (e.g. nrValues) that increase quickly enough that they end up being interpreted as pointers by the garbage collector. Moving it to the heap makes them invisible to the garbage collector. This reduces the max RSS doing 100 evaluations of nixos.tests.firefox.x86_64-linux.drvPath from 455 MiB to 292 MiB. Note: ideally, allocations would be much further up in the 64-bit address space to reduce the odds of an integer being misinterpreted as a pointer. Maybe we can use some linker magic to move the .bss segment to a higher address.
2018-05-07nix-shell: Only download requested outputsEelco Dolstra
Fixes #2116.
2018-04-07nix-shell: Fixes use with ruby shebangs.Samuel Dionne-Riel
The ported code in 80ebc553eca19dafc64c47420cd49ddd506bc9b7 was incorrectly ported. ``` - $envCommand = "exec $execArgs $interpreter -e 'load(\"$script\")' -- ${\(join ' ', (map shellEscape, @savedArgs))}"; ... + envCommand = (format("exec %1% %2% -e 'load(\"%3%\") -- %4%") % execArgs % interpreter % script % joined.str()).str(); ``` The single-quote finishing the small ruby snippet was lost in translation.
2018-03-16nix-shell: allow symlinks to .drvsLinus Heckemann
This makes persistent shell environments easier to use.
2018-02-08Add plugins to make Nix more extensible.Shea Levy
All plugins in plugin-files will be dlopened, allowing them to statically construct instances of the various Register* types Nix supports.
2018-02-03Remove nix-build --hashEelco Dolstra
Instead, if a fixed-output derivation produces has an incorrect output hash, we now unconditionally move the outputs to the path corresponding with the actual hash and register it as valid. Thus, after correcting the hash in the Nix expression (e.g. in a fetchurl call), the fixed-output derivation doesn't have to be built again. It would still be good to have a command for reporting the actual hash of a fixed-output derivation (instead of throwing an error), but "nix-build --hash" didn't do that.
2018-02-01nix-build: Ignore --indirectEelco Dolstra
Note that nix-build always creates indirect roots. Fixes #1830.
2018-01-16Add pure evaluation modeEelco Dolstra
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-24nix-shell/nix-build: Support .drv files againEelco Dolstra
Fixes #1663. Also handle '!<output-name>' (#1694).
2017-10-30nix-build: Fix --hashEelco Dolstra
2017-10-25Pass lists/attrsets to bash as (associative) arraysEelco Dolstra
2017-10-24nix: Respect -I, --arg, --argstrEelco Dolstra
Also, random cleanup to argument handling.
2017-10-19nix-shell: Fix file name resolution in shebangsShea Levy
2017-09-18nix-shell: Ignore readFile() errorsEelco Dolstra
Fixes #1563.
2017-07-30Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-07-28nix-build: Fix regression causing all outputs to be builtEelco Dolstra
2017-07-26nix-build/nix-shell: Eliminate call to nix-instantiate / nix-storeEelco Dolstra
Note that this removes the need for a derivation symlink, so the --drv-path and --add-drv-link flags now do nothing.
2017-07-20nix-shell: Use bashInteractive from <nixpkgs>Eelco Dolstra
This adds about 0.1s to nix-shell runtime in the case where bashInteractive already exists. See discussion at https://github.com/NixOS/nixpkgs/issues/27493.
2017-07-03nix-shell: Respect --dry-runEelco Dolstra
Fixes #824.
2017-05-24Fix #1314Eelco Dolstra
Also, make nix-shell respect --option. (Previously it only passed it along to nix-instantiate and nix-build.)
2017-05-24Merge branch 'topic/cores-master' of https://github.com/neilmayhew/nixEelco Dolstra
2017-05-24Fix #1380Eelco Dolstra
It lacked a backslash. Use a raw string and single quotes around PS1 to simplify this.
2017-05-10nix-shell: use appropriate prompt terminatorLinus Heckemann
If running nix-shell as root, the terminator should be # and not $.
2017-05-03nix-shell: Implement passAsFileEelco Dolstra
2017-04-24nix-shell -p: Use runCommandCCEelco Dolstra
This restores pre-17.03 behaviour by making gcc available.
2017-04-09Propagate NIX_BUILD_CORES to nix-shell environmentsNeil Mayhew
2017-03-12nix-shell/pure: keep environment variable SHLVLStefan Junker
2017-02-24nix-shell: Better error message when the shell can't be startedEelco Dolstra
2017-02-24nix-shell: Overwrite environment variablesEelco Dolstra
Need to remember that std::map::insert() and emplace() don't overwrite existing entries... This fixes a regression relative to 1.11 that in particular triggers in nested nix-shells. Before: $ nativeBuildInputs=/foo nix-shell -p hello --run 'hello' build input /foo does not exist After: $ nativeBuildInputs=/foo nix-shell -p hello --run 'hello' Hello, world!
2017-02-01Restore default signal handling in child processesEelco Dolstra
In particular, this fixes Ctrl-C in nix-shell sessions.