about summary refs log tree commit diff
path: root/pkgs/test/stdenv
AgeCommit message (Collapse)AuthorFilesLines
2024-04-15stdenv: make inputDerivation never fixed-outputJade Lovelace1-0/+22
This fixes using inputDerivation on derivations that are fixed-output. Previously: ``` nix-repl> drv = runCommand "huh" { outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; outputHashAlgo = "sha256"; outputHashType = "flat"; } "touch $out" nix-repl> drv.inputDerivation «derivation /nix/store/d8mjs6cmmvsr1fv7psm6imis5pmh9bcs-huh.drv» nix-repl> :b drv.inputDerivation error: fixed output derivation 'huh' is not allowed to refer to other store paths. You may need to use the 'unsafeDiscardReferences' derivation attribute, see the manual for more details. ``` Fixes: https://github.com/NixOS/nixpkgs/issues/304209
2024-02-16Merge pull request #255463 from ↵Rick van Schijndel1-1/+16
emilylange/stdenv/patch-shebangs-trailing-newline patch-shebangs: fix crash with shebang without trailing newline
2023-10-25tests/stdenv: Check derivations with an MD5 `outputHash` fail to evaluatenicoo1-0/+9
2023-09-16patch-shebangs: fix crash with shebang without trailing newlineemilylange1-1/+16
This fixes a bug where `patchShebangs` crashes when trying to patch files that contain only a shebang (e.g. `#!/bin/bash`) (and nothing else) and do not end with a newline. Such file can be produced using `printf "#!/bin/bash" > example` or `echo -n "#!/bin/bash" > example`. I don't understand why one would want to create such files, as they do literally nothing, but the chromium tarball we are using started shipping some 🫠 Full reproducer: ```nix with import <nixpkgs> { }; stdenv.mkDerivation { dontUnpack = true; name = "patch-shebangs-no-trailing-newline-reproducer"; postPatch = '' printf "#!/bin/bash" > reproducer chmod +x reproducer patchShebangs reproducer ''; } ``` ``` ❯ nix-build reproducer.nix this derivation will be built: /nix/store/vmbshdkdk4a0bayw3wi21wvxyhzpcsy2-patch-shebangs-no-trailing-newline-reproducer.drv building '/nix/store/vmbshdkdk4a0bayw3wi21wvxyhzpcsy2-patch-shebangs-no-trailing-newline-reproducer.drv'... patching sources patching script interpreter paths in reproducer /nix/store/vr6wwdxkmyy44sg0gwxi10b8fc5zhwz0-stdenv-linux/setup: line 144: pop_var_context: head of shell_variables not a function context error: builder for '/nix/store/vmbshdkdk4a0bayw3wi21wvxyhzpcsy2-patch-shebangs-no-trailing-newline-reproducer.drv' failed with exit code 1; last 3 log lines: > patching sources > patching script interpreter paths in reproducer > /nix/store/vr6wwdxkmyy44sg0gwxi10b8fc5zhwz0-stdenv-linux/setup: line 144: pop_var_context: head of shell_variables not a function context For full logs, run 'nix log /nix/store/vmbshdkdk4a0bayw3wi21wvxyhzpcsy2-patch-shebangs-no-trailing-newline-reproducer.drv'. ```
2023-06-19patch-shebangs: add a flag to update shebangs with store pathsIvan Trubach1-1/+18
This change adds a flag to update shebang paths that point to the Nix store. This is particularly useful when a cross-compiled package uses same script at compile-time and run-time, but the interpreter must be changed since hostPlatform != buildPlatform.
2023-06-17tests.stdenv.hooks.reproducible-builds: fix mistakeArtturin1-1/+1
2023-05-09tests.stdenv.test-inputDerivation: initAlyssa Ross1-0/+15
2023-04-02pkgs/test/stdenv/default.nix: add gcc-stageCompareAdam Joseph1-0/+32
This commit adds a derivation `gcc-stageCompare` to `pkgs/test/stdenv/default.nix`. It is important to always build this derivation whenever building `stdenv`! Because we are using a Nix-driven bootstrap instead of gcc's built-in `--enable-bootstrap`, the `gcc` derivation no longer performs the post-self-compilation sanity check. You must build this derivation in order to perform that sanity check. The major benefit of this new approach is that the sanity check (which involves a third compilation of gcc) can be performed *concurrently* with all packages that depend on `stdenv`, rather than serially. Since `stdenv` has very little derivation-level parallelism it cannot take advantage of more than one or perhaps two builders. If you have three or more builders this commit will reduce the time-to-rebuild-stdenv by around 20% (one of three gcc rebuilds is removed from the critical path, and stdenv's build time is dominated by roughly 3*gcc + 1*binutils + 1*bison-test-suite). Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-03-02tests.stdenv.outputs-no-out: update expectedMsgArtturin1-1/+1
2023-03-02tests.stdenv.outputs-no-out: cause less rebuildsArtturin1-2/+4
now gcc isn't built
2023-02-23Merge staging-next into staginggithub-actions[bot]2-2/+2
2023-02-22treewide: move NIX_CFLAGS_COMPILE to the env attrsetArtturin1-1/+1
with structuredAttrs lists will be bash arrays which cannot be exported which will be a issue with some patches and some wrappers like cc-wrapper this makes it clearer that NIX_CFLAGS_COMPILE must be a string as lists in env cause a eval failure
2023-02-22tests.stdenv.outputs-no-out: fixArtturin1-1/+1
2023-02-17tests.stdenv: add hooks.patch-shebangs.split-string & tweak testsArtturin1-37/+65
2023-02-17tests.stdenv: move patch-shebangs testArtturin3-4/+74
2023-01-25Merge pull request #212286 from Artturin/runonallArtturi1-1/+11
make-symlinks-relative: run on all outputs
2023-01-23make-symlinks-relative: run on all outputsArtturin1-1/+11
2023-01-16multi-outputs.sh: Improve _assignFirst error messageRobert Hensing1-1/+21
Closes #16182 This improves the error message Error: _assignFirst found no valid variant! which occurred when the set of outputs was not sufficient to set the various outputDev, outputBin, etc variables. Specifically, this would mean that "out" is not among the outputs, which is valid for a derivation. This changes the message to something like error: _assignFirst: could not find a non-empty variable to assign to outputDev. The following variables were all unset or empty: dev out. If you did not define an "out" output, make sure to define all the specific required outputs: define an output for one of the unset variables. While this isn't a full explanation of what stdenv can and can not do, I think it's vast improvement over the 0 bits of information that it used to provide. This at least gives a clue as to what's going on, and even suggests a fix, although probably multiple such fixes are required in an instance where someone starts with a no-out derivation from scratch (and decide to persist).
2022-12-15Merge pull request #205944 from ncfavier/structured-attrs-envNaïm Favier1-0/+20
2022-12-15tests.stdenv: check that attrs in env are exportedArtturin1-0/+1
2022-12-15stdenv: handle `env` gracefullyNaïm Favier1-0/+19
Derivations not using `__structuredAttrs` should not attempt to set environment variables from `env`. Derivations using `__structuredAttrs` should fail if `env` is not exportable.
2022-12-13stdenv: sort defaultNativeBuildInputs alphabeticallyArtturin1-70/+66
2022-12-12tests.stdenv.hooks: add more testsArtturin2-3/+98
2022-12-12tests: move stdenv hook tests to stdenv.hooksArtturin2-0/+41
2022-12-12tests.stdenv: add test-golden-example-structuredAttrsArtturin1-0/+71
examples copied from https://nixos.mayflower.consulting/blog/2020/01/20/structured-attrs/ nix has tests for structuredAttrs but i figured it'd be good to have a golden test here too https://github.com/NixOS/nix/blob/master/tests/structured-attrs.nix https://github.com/NixOS/nix/blob/master/tests/structured-attrs-shell.nix
2022-12-10stdenv: detect the type of variable in {prepend,append}ToVarArtturin1-4/+15
stdenv: error if using {prepend,append}ToVar on associative array i don't know how to prepend to associative array
2022-12-10tests.stdenv: add tests for prependToVar and appendToVarArtturin1-8/+88
2022-12-10tests.stdenv: deduplicateArtturin1-75/+36
2022-12-08tests.stdenv: add some env attrset testsArtturin1-0/+107