Commit Graph

98 Commits

Author SHA1 Message Date
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
sternenseemann
b398d00903 trivial-builders: merge passAsFile with env in runCommand'
Previously it was awkward to use the runCommand-variants with
passAsFile as a double definition of passAsFile would potentially
break runCommand: passAsFile would overwrite the previous definition,
defeating the purpose of setting it in runCommand in the first place.
This is now fixed by concatenating the [ "buildCommand" ] list with
one the one from env, if present.

Adjust buildEnv where passAsFile = null; was passed in some cases,
breaking evaluation since it'd evaluate to [ "buildCommand" ] ++ null.
2021-03-18 19:56:40 +01:00
Vladimír Čunát
3937923f81
nixos/systemd.tmpfiles.packages: fix an edge case
symlinkJoin can break (silently) when the passed paths contain symlinks
to directories.  This should work now.

Down-side: when lib/tmpfiles.d doesn't exist for some passed package,
the error message is a little less explicit, because we never get
to the postBuild phase (and symlinkJoin doesn't provide a better way):
/nix/store/HASH-NAME/lib/tmpfiles.d: No such file or directory

Also, it seemed pointless to create symlinks for whole package trees
and using only a part of the result (usually very small part).
2020-08-16 10:23:53 +02:00
Silvan Mosberger
c60e559e13
trivial-builders: Sanitize derivation name
This then supports using functions like writeShellScriptBin with script names
that would be invalid as derivation names
2020-04-15 00:31:57 +02:00
(cdep)illabout
55e1529335 symlinkJoin: add more documentation 2020-02-18 16:35:28 +01:00
(cdep)illabout
ae607de23d linkFarmFromDrvs: Add a trivial builder to create a linkFarm from a list of derivations 2020-02-18 16:35:28 +01:00
Bas van Dijk
4e0a6bc4be symlinkJoin: fix "bash: Argument list too long" error
When the `paths` argument is too big `symlinkJoin` will fail with:

```
while setting up the build environment: executing '/nix/store/rm1hz1lybxangc8sdl7xvzs5dcvigvf7-bash-4.4-p23/bin/bash': Argument list too long
```

This is fixed by passing `paths` as a file instead of as an
environment variable.
2020-02-17 11:45:44 +01:00
Profpatsch
c5c5465fe4 pkgs/build-support/trivial-builders: remove runCommandCCLocal
We shouldn’t force the user to have a C compiler in scope, just
because the derivation is forced to build locally. That can’t be
counted as “lightweight” anymore.

Co-Authored-By: Silvan Mosberger<contact@infinisil.com>
2019-12-04 21:17:01 +01:00
Profpatsch
8deaf41d60 pkgs/build-support/trivial-builders: add runCommandLocal
A definition I’ve been copy-pasting everywhere so far, so it’s finally
time to add it to nixpkgs.

I’m using a remote builder for my regular nix builds, so trivial
`runCommand`s which first try a substitution and then copy the inputs
to the builder to run for 0.2s are quite noticable.

If we just always build these, we gain some build time, so let’s make
it easy to switch from remote to local.
2019-12-04 21:17:01 +01:00
Bas van Dijk
05393ca217 trivial-builders: add the applyPatches function
applyPatches applies a list of patches to a source directory.

For example to patch nixpkgs you can use:

  applyPatches {
    src = pkgs.path;
    patches = [
      (pkgs.fetchpatch {
        url = "1f770d2055.patch";
        sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr";
      })
    ];
  }
2019-09-02 11:18:52 +02:00
Robert Helgesson
6900a327ad
trivial-builders: support '/' in writeTextDir
Before one would get the following error

    nix-repl> pkgs.writeTextDir "share/my-file" "foo"
    error: invalid character '/' in name 'share/my-file'

Fixes #50347
2019-07-13 17:03:41 +02:00
Erik Nygren
4e5b10d98c trivial-builders: Fix writeShellScript example (#63888) 2019-06-29 14:50:02 +00:00
Jaakko Luttinen
fa95878fd3 writeScript: fix docstring
Fixes #59299

See:
b23dbb1a5d
2019-06-09 12:45:31 +02:00
deliciouslytyped
103ab24e94 trivial-builders: add writeShellScript and minor cleaning
Add writeShellScript
Small whitespace additions
Fix "Example:" docstring sections for some of the writeScript functions to use the correct function
2019-05-12 19:40:01 +02:00
Niklas Hambüchen
a0fa0cd8cf trivial-builders: Fix runCommand examples 2019-04-19 06:29:42 +02:00
Niklas Hambüchen
c4c2aa6586 trivial-builders: Fix outdated comment on writeTextFile 2019-04-08 01:12:50 +02:00
Michael Eden
53b0027fb4 writeShellScriptBin: use build-time shell in check phase 2019-04-04 13:31:51 -04:00