Commit graph

114 commits

Author SHA1 Message Date
Bernardo Meurer 6382598677
linkFarm: make last entry win in case of list repeats 2022-11-15 11:45:20 -05:00
Robert Hensing 449ae7573b
Merge pull request #170048 from lovesegfault/link-farm-passthru
linkFarm: add entries to passthru
2022-11-15 17:39:43 +01:00
Bernardo Meurer a93aed5bab
linkFarm: allow entries to be an attrset 2022-11-15 11:01:52 -05:00
Bernardo Meurer b54257fb36
linkFarm: add entries to passthru 2022-11-15 10:59:31 -05:00
Robert Hensing 8deb17a36e
Merge pull request #186323 from ShamrockLee/make-setuphook-passthru
trivial-builders.nix: Add input argument `passthru` to makeSetupHook
2022-09-19 11:30:37 +01:00
Jonathan Ringer dc607cf67b writeShellApplication: don't prefix empty PATH 2022-08-23 22:41:28 +02:00
Robert Hensing e8a38a2f52 makeSetupHook: Deprecate substitutions.passthru 2022-08-13 11:53:06 +02:00
Shamrock Lee ba895a7da8 trivial-builders.nix: Add input argument passthru to makeSetupHook
One significant use case is adding `passthru.tests` to setup-hooks,
and help increase test coverage for mission-critical setup-hooks.

As `meta`, `passthru` doesn't go into the build script directly.
However, passing an empty set to `passthru` breaks nixpkgs-review
and OfBorg tests, so pass it only when specified.
2022-08-13 04:20:12 +08:00
Sandro Jäckel 43d4ddf28e
treewide: remove usage of runCommandNoCC aliases 2022-06-07 16:57:06 +02:00
Artturin 1d44ac176c treewide: add enableParallelBuilding's to bootstrap packages so hashes stay the same
when enableParallelBuildingByDefault is enabled

verified with
`nix-diff $(nix eval ".#gcc-unwrapped.drvPath") $(nix eval --expr 'with import ./. { config = { enableParallelBuildingByDefault = true; }; }; gcc-unwrapped.drvPath' --impure)`
2022-05-25 16:03:14 +03:00
Artturin f002ffed9a treewide: enable strictDeps in bootstrap packages 2022-05-22 16:40:26 +03:00
Artturin 39b85d1c2a trivial-builders.nix: add TODO 2022-05-22 16:40:22 +03:00
Jörg Thalheim 03bf2ff19e
Merge pull request #173206 from SuperSandro2000/writeCBin
writeCBin: fix formatting
2022-05-16 06:58:47 +01:00
Sandro 27123795ad
writeCBin: fix formatting 2022-05-16 01:43:05 +02:00
Jules Aguillon 4acd65ce95
Escape paths
Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>
2022-05-15 21:29:01 +02:00
Jules Aguillon f2a91a6679 Fix string context lost in linkFarm
```nix
let pkgs = import ./. {}; in
pkgs.linkFarm "test" [
  { name = "foo"; path = ./README.md; }
]
```

The nix code above generates this result: (`nix build -f test.nix`)

```
lrwxrwxrwx 1 root root 31 Jan  1  1970 /nix/store/98mdz626n99w0467q4r203q154bnnli9-test/foo -> /home/juloo/w/nixpkgs/README.md
```

With this patch, the target file is naturally copied into the store:

```
lrwxrwxrwx 1 root root 53 Jan  1  1970 /nix/store/ndvffnardifqwzbp07g15llav55r5k1m-test/foo -> /nix/store/9rqwjskbbgbflrpyhzi6rak2j7jspr5f-README.md
```
2022-05-14 19:23:15 +02:00
Artturin 250ef1ff39 testers.testVersion: move from trivial-builders.nix
we will have more testers in the future so they should have their own
location

putting 'testers' in args will also make it simpler to use multiple testers
2022-04-22 16:22:40 +03:00
Artturi 3886bcd30f
Merge pull request #168703 from Artturin/testversion1 2022-04-17 22:40:45 +03:00
Artturin 390439d726 testVersion: when there is a error show the whole error
before

$ nix build ".#whipper.tests.version"
whipper>   File "/nix/store/2iiyy58pmm1ys6dy8ycbmmmfm67iakv1-whipper-0.10.0/bin/.whipper-wrapped", line 6, in <module>
whipper>   File "/nix/store/2iiyy58pmm1ys6dy8ycbmmmfm67iakv1-whipper-0.10.0/lib/python3.9/site-packages/whipper/__init__.py", line 5, in <module>
note: keeping build directory '/tmp/nix-build-whipper-0.10.0-test-version.drv-7'

after
$ nix build ".#whipper.tests.version"
whipper> Traceback (most recent call last):
whipper>   File "/nix/store/2iiyy58pmm1ys6dy8ycbmmmfm67iakv1-whipper-0.10.0/bin/.whipper-wrapped", line 6, in <module>
whipper>     from whipper.command.main import main
whipper>   File "/nix/store/2iiyy58pmm1ys6dy8ycbmmmfm67iakv1-whipper-0.10.0/lib/python3.9/site-packages/whipper/__init__.py", line 5, in <module>
whipper>     from pkg_resources import (get_distribution,
whipper> ModuleNotFoundError: No module named 'pkg_resources'
note: keeping build directory '/tmp/nix-build-whipper-0.10.0-test-version.drv-34'
error: builder for '/nix/store/5lxjicdhwgmjcz9ddlxgq3s3gyaa6lz4-whipper-0.10.0-test-version.drv' failed with exit code 1;
2022-04-14 23:10:20 +03:00
github-actions[bot] 3dc8bd98b9
Merge staging-next into staging 2022-04-06 00:02:41 +00:00
Vladimír Čunát b4729bad3d
Merge #165406: staging-next 2022-03-23 2022-04-05 20:34:08 +02:00
Robert Hensing 225ca9088a runCommand*: Rely on mkDerivation to sanitize name 2022-03-30 10:29:19 +02:00
Ben Siraphob ed863440b8
Merge pull request #163924 from OPNA2608/fix/autoPatchelfHook_isLinux 2022-03-26 16:01:56 -05:00
OPNA2608 48034046bf autoPatchelfHook: Make Linux-exclusive
After being rewritten in https://github.com/NixOS/nixpkgs/pull/149731, this hook
can fail on Mach-O binaries. Since patching ELF files on Darwin doesn't make
much sense anyway, we'll mark this as Linux-exclusive.
2022-03-22 19:55:46 +01:00
K900 3fae68b30c build-support/writeTextFile: fix for names with spaces
I am sorry.
2022-03-10 13:30:20 +03:00
Jan Tojnar f7aa55946b Merge branch 'staging-next' into staging
; Conflicts:
;	nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
;	nixos/doc/manual/release-notes/rl-2205.section.md
;	pkgs/build-support/libredirect/default.nix
2022-01-10 01:26:05 +01:00
Naïm Favier 10ec5da56e tests.trivial-builders.overriding: update after shellDryRun 2021-12-27 20:30:01 -05:00
Naïm Favier f2065d81ad stdenv/generic: introduce shellDryRun
Add `shellDryRun` to the generic stdenv and substitute it for uses of
`${stdenv.shell} -n`. The point of this layer of abstraction is to add
the flag `-O extglob`, which resolves #126344 in a more direct way.
2021-12-27 20:30:01 -05:00
pasqui23 767d56e834
concatScript: formatting
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-11-28 20:43:17 +00:00
Pasquale 67320a1668
concatText: fix typos 2021-11-28 19:35:43 +01:00
Pasquale 0f316ecef2
concatTextFile: init
nixos/networking: using concatTextFile
2021-11-28 01:39:42 +01:00
0x4A6F 0ca14515c6
testVersion: name runCommand after package.name 2021-11-20 22:00:22 +01:00
Bernardo Meurer 174995d14f
writeShellApplication: set meta.mainProgram 2021-11-08 09:33:42 -08:00
Bernardo Meurer ba7b7357ac
writeTextFile: allow passing extra derivationArgs 2021-11-08 09:33:40 -08:00
Bernardo Meurer d8ec0eeab7
writeShellApplication: run pre/postCheck hooks 2021-11-08 09:33:38 -08:00
Bernardo Meurer 949182a4a2
writeShellApplication: document runtimeShell == stdenv.shell assumption 2021-11-08 09:33:37 -08:00
Bernardo Meurer 014b23232f
writeShellApplication: fix typo in inline docs 2021-11-08 09:33:36 -08:00
Bernardo Meurer 97de845b60
writeShellApplication: fix setting pipefail 2021-11-08 09:33:35 -08:00
Bernardo Meurer 21c299f077
writeShellApplication: get shellcheck from pkgsBuildHost 2021-11-08 09:33:34 -08:00
Bernardo Meurer 0e4f04b74c
writeShellApplication: buildInputs -> runtimeInputs 2021-11-08 09:33:33 -08:00
Bernardo Meurer 89979c9c5b
writeShellApplication: init 2021-11-08 09:33:32 -08:00
talyz aa22fa9c0b trivial-builders: Add writeStringReferencesToFile
Add writeStringReferencesToFile, a builder which extracts a string's
references to derivations and paths and writes them to a text file,
removing the input string itself from the dependency graph. This is
useful when you want to make a derivation depend on the string's
references, but not its content (to avoid unnecessary rebuilds, for
example).
2021-10-28 12:55:01 +02:00
Sandro 3f3e055bcd
Merge pull request #133905 from raboof/buf-use-testVersion-utility
buf: use testVersion utility
2021-08-18 11:59:49 +02:00
Robert Hensing 9feb144c8c runCommandNoCC: deprecate
It has been synonymous with runCommand ~5y.
2021-08-15 17:36:41 +02:00
Arnout Engelen 1a604de2e7
buf: use testVersion utility
`installCheckPhase` is mainly intended for checks that are part of the
upstream package, for our 'own' checks we prefer `passthru.tests`.

This loses running `buf --help`, but I'm not sure how much that adds
on top of `buf --version`?
2021-08-15 09:00:30 +02:00
deliciouslytyped a71e906e3a trivial-builders: refactor writeTextFile to be overridable
This fixes #126344, specifically with the goal of enabling overriding the
checkPhase argument. See `design notes` at the end for details.

This allows among other things, enabling bash extension for the `checkPhase`.
Previously using such bash extensions was prohibited by the `writeShellScript`
code because there was no way to enable the extension in the checker.

As an example:

```nix
(writeShellScript "foo" ''
  shopt -s extglob
  echo @(foo|bar)
'').overrideAttrs (old: {
  checkPhase = ''
    # use subshell to preserve outer environment
    (
      export BASHOPTS
      shopt -s extglob
      ${old.checkPhase}
    )
  '';
})
```

This commit also adds tests for this feature to `pkgs/tests/default.nix`,
under `trivial-overriding`. The test code is located at
`pkgs/build-support/trivial-builders/test-overriding.nix`.

Design notes:
-------------

Per discussion with @sternenseemann, the original approach of just wrapping
`writeTextFile` in `makeOverridable` had the issue that combined with `callPackage`
in the following form, would shadow the `.override` attribute of the `writeTextFile`:

```nix
with import <nixpkgs>;
callPackage ({writeShellScript}: writeShellScript "foo" "echo foo")
```

A better approach can be seen in this commit, where `checkPhase` is moved
from an argument of `writeTextFile`, which is substituted into `buildCommand`,
into an `mkDerivation` argument, which is substituted from the environment
and `eval`-ed. (see the source)

This way we can simple use `.overideAttrs` as usual, and this also makes
`checkPhase` a bit more conformant to `mkDerivation` naming, with respect to
phases generally being overridable attrs.

Co-authored-by: sterni <sternenseemann@systemli.org>
Co-authored-by: Naïm Favier <n@monade.li>
2021-06-18 01:39:59 +02:00
Robert Hensing 047fe2fe23 emptyFile, emptyDirectory: init 2021-06-12 17:28:00 +02:00
Robert Hensing cc60f81e69 writeDirectReferencesToFile: init 2021-05-15 17:04:25 +02:00
Arnout Engelen b68130fd2c
test-utilities: version test
Extract 'version test' to a reusable test utility as discussed in
https://github.com/NixOS/nixpkgs/pull/119636#issuecomment-826137021 and
2021-05-07 09:53:35 +02:00
sternenseemann de78745bdd trivial-builders: rework runCommand' into runCommandWith && expose
runCommandWith receives an attribute set with options which previously
were positional arguments of runCommand' and a buildCommand. This
allows for overriding the used stdenv freely (so stuff like
llvmPackages.stdenv can be used). Additionally the possibility to change
arguments passed to stdenv.mkDerivation is made more explicit via the
derivationArgs argument.
2021-03-18 19:56:40 +01:00