about summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks
AgeCommit message (Collapse)AuthorFilesLines
2023-03-12Merge pull request #219683 from symphorien/separatedebuginfo_staticSergei Trofimovich1-0/+3
separate-debug-info.sh: succeed when output only contains static libs
2023-03-12separate-debug-info.sh: succeed when output does not contain elf filesGuillaume Girol1-0/+3
Currently, separate-debug-info adds a debug output, and the build fail when it is not created. the output is only created when at least one elf file is stripped. As a result, adding separateDebugInfo = true on a lib will break the static build (unless the lib also contains an executable). In order to not have to remember to add an exception every time, let's just create the debug output unconditionally.
2023-03-10Merge pull request #219182 from Artturin/multipleoutputsshdirnotemptyArtturi1-2/+2
2023-03-04multiple-outputs.sh: silence 'rmdir: failed to remove ... Directory not empty'Artturin1-2/+2
++ rmdir /nix/store/6f233lsgbqv87w4nmzpsdaydwhyapps6-at-spi2-core-aarch64-unknown-linux-gnu-2.46.0/lib rmdir: failed to remove '/nix/store/6f233lsgbqv87w4nmzpsdaydwhyapps6-at-spi2-core-aarch64-unknown-linux-gnu-2.46.0/lib': Directory not empty
2023-02-26multiple-outputs.sh: Make _assignFirst message more accurateRobert Hensing1-1/+1
2023-02-26multiple-outputs.sh: Do not leak `_var` variable from _assignFirstRobert Hensing1-0/+1
2023-02-26multiple-outputs.sh: Allow `var` as an output nameRobert Hensing1-2/+2
2023-02-18Merge pull request #215715 from Artturin/removegirworkarounds2Artturi1-11/+21
2023-02-18Merge pull request #211187 from Artturin/movetestpatchshenbagArtturi1-4/+10
2023-02-18setup-hooks/reproducible-builds.sh: NIX_OUTPATH_USED_AS_RANDOM_SEED (take 2) ↵Sergei Trofimovich1-1/+2
(#216967) This time the change targets `staging`. This reverts commit e1f1c7eb79fefa5e640bfbc9e023619ef095935a.
2023-02-17patch-shebangs: handle env -S shebangsTimothy DeHerrera1-4/+10
`env -S` allows one to set more than one argument in a shebang. This small patch allows the patch-shebangs hook to handle this case appropriately.
2023-02-17wrapGAppsHook: add gtk3 to depsTargetTargetPropagatedArtturin1-1/+4
for typelibs and girs
2023-02-17wrapGAppsHook: run tests with strictDepsArtturin1-0/+8
'nix build -f . "wrapGAppsHook.tests"' pass
2023-02-17wrapGAppsHook: move dconf.lib to depsTargetTargetPropagatedArtturin1-10/+9
luckily the lib output does not contain binaries therefore its safe to remove it from propagatedBuildInputs
2023-02-07treewide: makeSetupHook deps -> propagatedBuildInputsArtturin1-2/+1
2023-02-07wrapGAppsHook: make it work with strictDepsArtturin2-7/+22
remove unused input add test for GDK_PIXBUF_MODULE_FILE run tests with strictDeps if the tests work with strictDeps then they work with non strictDeps
2023-01-25Merge pull request #212286 from Artturin/runonallArtturi1-1/+10
make-symlinks-relative: run on all outputs
2023-01-25Merge master into staging-nextgithub-actions[bot]2-1/+6
2023-01-25postgresqlTestHook: run postgresqlTestSetupPost hook after setting upNick Cao2-1/+6
2023-01-23make-symlinks-relative: run on all outputsArtturin1-1/+10
2023-01-21treewide: switch to nativeCheckInputsGuillaume Girol1-1/+1
checkInputs used to be added to nativeBuildInputs. Now we have nativeCheckInputs to do that instead. Doing this treewide change allows to keep hashes identical to before the introduction of nativeCheckInputs.
2023-01-21postgresqlTestHook: adapt comment to nativeCheckInputsGuillaume Girol1-1/+1
2023-01-21Merge branch 'nativeCheckInputs' into staging-nativeCheckInputsGuillaume Girol2-2/+2
2023-01-19Merge pull request #211082 from hercules-ci/fix-issue-16182Robert Hensing1-5/+21
Fix issue 16182 `Error: _assignFirst found no valid variant!`
2023-01-19treewide: add names to all setup hooksAlyssa Ross1-0/+2
2023-01-17multiple-outputs.sh: Apply suggestions from code reviewRobert Hensing1-3/+5
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-01-16multi-outputs.sh: Improve _assignFirst error messageRobert Hensing1-5/+19
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).
2023-01-16treewide: remove usages of header and stopNestArtturin5-12/+7
they're obsolete
2023-01-15Merge pull request #210908 from Yarny0/auto-patchelfGuillaume Maudoux1-0/+7
autoPatchelfHook: fix symlink handling
2023-01-15auto-patchelf: don't resolve symlinks if basenames don't matchYarny01-0/+7
The auto-patchelf python script assembles a list of library (so=shared object) file names and their paths. This helps speed up the discovery of library files later when patching elf files. As further optimization, if a symlink points to a library file, the script uses the resolved path and file name. However, this produces a broken list entry if the symlink's target name doesn't match the symlink's name. A symptom of the bug, affecting the `tsm-client` package, is fixed in https://github.com/NixOS/nixpkgs/pull/172372 . The commit at hand stops resolving symlinks if the target name differs from the symlink's name. The commit has been authored by layus (Guillaume Maudoux <layus.on@gmail.com>) in pull request comment https://github.com/NixOS/nixpkgs/pull/172372#issuecomment-1194687183
2023-01-08setup-hooks/strip.sh: redirect stdout to dev/nullArtturin1-1/+1
to not unnecessarily print ``` hello> ++ type -f strip hello> strip is /nix/store/xzqzq99kbbkad23s2bf4bbrjppg6x0vj-bootstrap-stage2-gcc-wrapper-/bin/strip ``` printing what the strip command is is already done in stripDirs `echo "stripping (with command $cmd and flags $stripFlags) in $paths"`
2023-01-06setup-hooks/make-symlinks-relative.sh: match what other hooks do soArtturin1-2/+2
the hook doesn't output the following if $prefix doesn't exist find: '/nix/store/...': No such file or directory some other hooks that do this: prune-libtool-files.sh, audit-tmpdir.sh separate-debug-info.sh
2022-12-13audit-tmpdir.sh: fix on darwinArtturin1-2/+2
compress-man-pages.sh uses `find ... | while ...; do...` so this works on darwin vcunat says the following in https://github.com/NixOS/nixpkgs/commit/94d164dd7#r22030369 > Unfortunately, process substitution doesn't work during early darwin bootstrap. http://hydra.nixos.org/build/52433342 We've run into that before. > I think it should work to have `find ... | while ...; do...`
2022-12-13build-support/setup-hooks: change shebang to shellcheck directiveArtturin3-3/+3
2022-12-12move-docs.sh: update commentArtturin1-3/+1
_multioutDocs is in multiple-outputs.sh
2022-12-10Merge pull request #175649 from Artturin/opt-in-structured-attrsRobert Hensing6-30/+43
stdenv: support opt-in __structuredAttrs
2022-12-08stdenv: support opt-in __structuredAttrsArtturin6-30/+43
Co-authored-by: Robin Gloster <mail@glob.in> stdenv: print message if structuredAttrs is enabled stdenv: add _append reduces the chance of a user doing it wrong fix nix develop issue output hooks don't work yet in nix develop though making $outputs be the same on non-structuredAttrs and structuredAttrs is too much trouble. lets instead make a function that gets the output names reading environment file '/nix/store/2x7m69a2sm2kh0r6v0q5s9z1dh41m4xf-xz-5.2.5-env-bin' nix: src/nix/develop.cc:299: std::string Common::makeRcScript(nix::ref<nix::Store>, const BuildEnvironment&, const Path&): Assertion `outputs != buildEnvironment.vars.end()' failed. use a function to get all output names instead of using $outputs copy env functionality from https://github.com/NixOS/nixpkgs/pull/76732/commits
2022-12-06make-symlinks-relative: fix no such file or directory if output is created ↵Artturin1-1/+1
in postFixup wlroots(and others) have ``` wlroots> +++ find /nix/store/3a0xwszw8n5dzzhsgfnilvsqi4hk565s-wlroots-0.15.1-examples -type l -print0 wlroots> find: '/nix/store/3a0xwszw8n5dzzhsgfnilvsqi4hk565s-wlroots-0.15.1-examples': No such file or directory ``` because the examples output is created in postFixup while this hook runs in fixupPhase
2022-11-18Merge pull request #182055 from wentasah/moveToOutput-comment-fixSergei Trofimovich1-1/+1
multiple-output.sh: fix moveToOutput comment
2022-11-10patchRcPath hooks: use the passthru argumentShamrock Lee1-24/+20
2022-11-10patchRcPathBash, patchRcPathCsh, patchRcPathFish, patchRcPathPosix: initShamrock Lee14-0/+784
Init patchRcPath hooks, which provides utilities to patch shell scripts to be sourced by users. Add test cases and documentation.
2022-11-06patchPpdFilesHook: new setup hook for absolute executable pathsYarny05-0/+320
PostScript Printer Description (ppd) files describe printer features and capabilities. They are usually evaluated by CUPS to convert print jobs into a format suitable for a printer. The conversion is often accomplished by commands or even short shell scripts inside the ppd files. ppd files are included in many printer driver packages. Their scripts sometimes refer to other executables; some of them are more common (like `perl`), others are more exotic (like `rastertohp`). If an executable is called with its name alone, the effects of the ppd file depend on whether the executable is in the PATH of CUPS, and on the executable's version. If an executable is called with an absolut path (like `/usr/bin/perl`), it won't work at all in NixOS. The commit at hand adds a setup hook that uses the `fixupPhase` to substitute certain executable's invocations in pdd files with absolute paths. To use it, add the hook to `nativeBuildInputs` and provide a list of executable names in `ppdFileCommands`. Each executable must be available in the package that is being built, or in `buildInputs`. The setup hook's script then looks for ppd files in `share/cups/model` and `share/ppds` in each output, and replaces executable names with their absolute paths. If ppd files need to be patched in unorthodox locations or the setup hook needs to be invoked manually for other reasons, one may leave the list `ppdFileCommands` empty to avoid automatic processing of ppd files, then call the shell function `patchPpdFileCommands` directly. Details are described in the file `patch-ppd-hook.sh`. Notes on the motivation for this setup hook: Most packages in nixpkgs that provide ppd files do not patch those ppd files at all. This is not fatal when the executables are just called with their names since the user can add packages with the executables to `services.printing.drivers`. E.g. if the user adds `pkgs.perl`, then all ppd files that invoke `perl` will work as expected. Nevertheless, to make these ppd files independent of their execution environment, command invocations should be substituted with absolut paths into the nix store. This is similar to patching shebang lines so scripts can be called independently of having the interpreter in the PATH. The hook script in this commit is meant to support new packages `foomatic-db*` which will generate several thousands of ppd files referencing a plethora of different executables. During development of these packages, I realized that it's quite hard to patch ppd files in a robust way. While binary names like `rastertokpsl` seem to be sufficiently unique to be patched with `sed`, names like `date` or `gs` are hard to patch without producing "false positives", i.e., coincidental occurences of the executable's name that do *not* refer to the executable and should not be patched at all. As this problem also affects other packages, it seems reasonable to put a robust implementation in its own setup hook so that other packages can use it without much effort. Notes on the implementation: The ppd file format is far from trivial. The basic structure are key-value pairs; keys may occur multiple times. Only a small subset of keys may contain executable names or shell scripts in their values. Some values may span multiple lines; a linebreak might even occur in the middle of a token. Some executable names also occur in other keys by accident where they must not be substituted (e.g. `gs` or `date`). It is necessary to provide the list of command names that will be patched for two reasons: ppd files often contain "tokens" that might look like commands (e.g. "file" or "host") but aren't; these would erroneously get patched. Also, looking for everything that might be a command would slow down the patching process considerably. The implementation uses `awk` to detect keys that might contain executable names; only their values are treated for substitution. This avoids most cases of "overzealous" substitutions. Since values may span multiple lines, `sed` alone (while faster than `awk`) cannot focus its substitution capabilities on relevant keys. An elaborate set of regular expressions further helps to minimize the probability of "false positives". Several tricks are employed to speed up `awk`. Notably, relevant files are identified with `grep` before `awk` is applied to those files only. Note that the script probably cannot handle fancy command names (like spaces or backslashes as part of the name). Also, there are still edge cases that the script would mistakenly skip, e.g. if a shell script contains a line break in the middle of an executable's name; although ppd files permit such constellations, I have yet to see one. ppd files may be gzipped. The setup hook accepts gzipped ppd files: It decompresses them, substitutes paths, then recompresses them. However, Nix cannot detect substituted paths as runtime dependencies in compressed ppd files. To ensure substituted paths are propagated as runtime dependencies, the script adds each substituted path to the variable `propagatedBuildInputs`. Since this might not be enough for multi-output packages, those paths are also written directly to `nix-support/propagated-build-inputs`. See the comment in `patch-ppd-hook.sh` for details. Finally, the setup hook comes with a small test that probes some edge cases with an artificial ppd file. References: * https://www.cups.org/doc/spec-ppd.html * general ppd file specification * lists some keys that may contain executable names or shell scripts * https://refspecs.linuxfoundation.org/LSB_4.0.0/LSB-Printing/LSB-Printing/ppdext.html * lists some keys that may contain executable names or shell scripts * https://en.wikipedia.org/wiki/PostScript_Printer_Description#CUPS * lists the usual locations of ppd files
2022-10-10autoPatchelfHook: support glob patternsadisbladis1-2/+5
so for example cuda could be ignored by setting: ``` nix autoPatchelfIgnoreMissingDeps = [ "*cuda*.so*" ]; ```
2022-10-10autoPatchelfHook: fix turning `[ "*" ]` into bash arrayadisbladis1-1/+1
Previously globs were incorrectly handled and expanded by bash into the files in the temporary build directory.
2022-09-19Merge pull request #186323 from ShamrockLee/make-setuphook-passthruRobert Hensing3-7/+9
trivial-builders.nix: Add input argument `passthru` to makeSetupHook
2022-08-13wrapGAppsHook: Set nameRobert Hensing1-0/+1
The previous commit, removing substitutions, causes a mass rebuild, so we use the opportunity to set the name; also a mass rebuild.
2022-08-13setup hooks: substitutions.passthru -> passthruRobert Hensing2-4/+6
2022-08-13trivial-builders.nix: Add input argument `passthru` to makeSetupHookShamrock Lee1-3/+2
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-07setup-hooks/separate-debug-info.sh: don't inhibit strip hookSergei Trofimovich2-13/+12
Before the change separate-debug-info.sh did the stripping itself. This scheme has a few problems: 1. Stripping happens only on ELF files. *.a and *.o files are skipped. Derivations have to do it manually. Usually incorrectly as they don't run $RANLIB (true for `glibc` and `musl`). 2. Stripping happens on all paths. Ideally only `stripDebugList` paths should be considered. 3. Host strip is called on Target files. This change offloads stripping logic to strip hook. This strips more files for `glibc` and `musl`. Now we can remove most $STRIP calls from individual derivations. Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2022-08-03gcc: extend stripping of .a libraries and .o objectsSergei Trofimovich1-1/+1
The initial intent was to strip .a and .o files, not .a.o files. While at it expanded stripping for $lib output as well. Without the change `libgcc.a` was not stripped and `.debug*` sections made into final binaries. It's not a problem on it's own, but it's an unintended side-effect. Noticed on `crystal_1_0` test failure where `crystal` was not able to handle `dwarf-5`. While at it allowed absolute file names to be passed to stripDebugList and friends.