summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks
Commit message (Collapse)AuthorAge
* wrapGAppsHook: don't add empty variablesKovacsics Robert2019-12-10
| | | | | | | | | | | | | | | | | | | | | | | | | | Adding empty variables can lead to this problem: ```diff wrapProgram \ ./pye_menu_shell \ --prefix PATH : /nix/store/4c3z5r6yxsf2cxwwyazhdn92xixn4j5b-python3-3.7.5/bin:/nix/store/b3l3niilvqcxcsbxmd6sgqk1dy1rk81c-pye-menu-1.0/bin:/nix/store/y8j1cfj8d9r5rbbxc22w7hnfjw5f4fd3-cairo-1.16.0-dev/bin:/nix/store/6mg7lfbdh9pgx7pbxr3544qqbrigdl1q-freetype-2.10.1-dev/bin:/nix/store/gpszqcy0xi0lavbbjdq82zkkjp3jbp2a-bzip2-1.0.6.0.1-bin/bin:/nix/store/031c5pk5lzabgmpqpyd46hzi625as6bp-libpng-apng-1.6.37-dev/bin:/nix/store/f8kl7kmpv130aw9zm542p74a3hg0yc13-fontconfig-2.12.6-bin/bin:/nix/store/bqp30vkncmm222mjvwggz0s7p318sflj-expat-2.2.7-dev/bin:/nix/store/w57xa8g4s4aviwmqwgra7m5hwj2b005m-glib-2.60.7-dev/bin:/nix/store/v5d4966ahvfir2hwpv003022f3pb7vik-gettext-0.19.8.1/bin:/nix/store/qpvxhl1jr0fxnrx9idnpdagqs00m5m2z-glib-2.60.7/bin \ --set PYTHONNOUSERSITE true \ --set GDK_PIXBUF_MODULE_FILE /nix/store/7ddlakx6xjczqbfs80xjd14f30fzadws-gdk-pixbuf-2.38.1/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \ --prefix XDG_DATA_DIRS : /nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10:/nix/store/b41z51vdv11n6df8ki5vj8dynxw98f9l-gsettings-desktop-schemas-3.32.0/share/gsettings-schemas/gsettings-desktop-schemas-3.32.0:/nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/share/gsettings-schemas/gtk+3-3.24.10 \ - --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : \ + --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "" \ --prefix GI_TYPELIB_PATH : /nix/store/0snjc1qg89zqn3v35l9d55xrykh9nj5c-gtk+3-3.24.10/lib/girepository-1.0:/nix/store/z29l5xaaxh1s0697mcldj71ab0zshry1-librsvg-2.44.15/lib/girepository-1.0:/nix/store/pija1xzm7izxfb5m2hvhvlwp1l38ffxa-gobject-introspection-1.60.2/lib/girepository-1.0 \ - --prefix GRL_PLUGIN_PATH : + --prefix GRL_PLUGIN_PATH : "" ``` Where the diff is to highlight the problem: we don't have a valid value for GST_PLUGIN_SYSTEM_PATH_1_0 or GRL_PLUGIN_PATH, and instead of passing the empy string, the empty string gets unquoted somewhere, so we end up passing no arguments, thus the parser in wrapProgram takes --prefix as the argument of GST_PLUGIN_SYSTEM_PATH_1_0, and then GI_TYPELIB_PATH is missing it's --prefix so wrapProgram complains/dies. The easiest change is to not add empty arguments to the wrapper
* java classpath hook: allow unbound $CLASSPATHJason Felice2019-11-24
|
* multiple-outputs setup hook: Remove accidentally added tabJohn Ericson2019-11-04
| | | | | I don't want to just rebase this away because the original commit is also in #72074.
* find-xml-catalogues: Ensure XML_CATALOG_FILES is definedJohn Ericson2019-11-01
|
* treewide: Make still dont* Variables are optional in most casesJohn Ericson2019-11-01
| | | | | | | | | | Go beyond the obvious setup hooks now, with a bit of sed, with a skipped case: - cc-wrapper's `dontlink`, because it already is handled. Also, in nix files escaping was manually added. EMP
* common setup hooks: set -u robustnessJohn Ericson2019-11-01
| | | | Explicitly handle `dont*` and friends not being defined.
* makeWrapper: Remove unused extraFlagsArray featureChuck2019-09-25
| | | | | | | | | | | | | | | | | | | | | | | | | There is a bug in this feature: It allows extra arguments to leak in from the environment. For example: $ export extraFlagsArray=date $ man ls Note that you get the man page for date rather than for ls. This happens because 'man' happens to use a wrapper (to add groff to its PATH). An attempt to fix this was made in 5ae18574fce in PR #19328 for issue #2537, but 1. That change didn't actually fix the problem because it addressed makeWrapper's environment during the build process, not the constructed wrapper script's environment after installation, and 2. That change was apparently accidentally lost when merged with 7ff6eec5fd8. Rather than trying to fix the bug again, we remove the extraFlagsArray feature, since it has never been used in the public repo in the ten years it has been available. wrapAclocal continues to use its own, separate flavor of extraFlagsArray in a more limited context. The analogous bug there was fixed in 4d7d10da6b1 in 2011.
* wrapGAppsHook: address some shellcheck suggestionsJan Tojnar2019-09-10
| | | | | | | These should not cause issues in practice but it is good idea to handle them. * prefix and targetOffset are mandatory, as they are always set by the generic builder. * wrapPrefixVariables and dontWrapGApps are now defaulting to empty value, as they are not mandatory.
* wrapGAppsHook: simplify taking env varsJan Tojnar2019-09-10
| | | | using indirect variable access must be better than eval
* wrapGAppsHook: add wrapGApp helperJan Tojnar2019-09-10
|
* installShellFiles: init (#65211)Lily Ballard2019-09-04
| | | | | | | | | | | | | | | | | | | | | This is a new package that provides a shell hook to make it easy to declare manpages and shell completions in a manner that doesn't require remembering where to actually install them. Basic usage looks like { stdenv, installShellFiles, ... }: stdenv.mkDerivation { # ... nativeBuildInputs = [ installShellFiles ]; postInstall = '' installManPage doc/foobar.1 installShellCompletion --bash share/completions/foobar.bash installShellCompletion --fish share/completions/foobar.fish installShellCompletion --zsh share/completions/_foobar ''; # ... } See source comments for more details on the functions.
* add shortenPerlShebang functionBenjamin Esham2019-08-18
| | | | | | | This setup hook modifies a Perl script so that any "-I" flags in its shebang line are rewritten into a "use lib ..." statement on the next line. This gets around a limitation in Darwin, which will not properly handle a script whose shebang line exceeds 511 characters.
* patchShebangs: Exit if no arguments were givenDaniel Schaefer2019-05-26
| | | | | | Commit "patchShebangs: Allow for multiple arguments" 4a1e51f957b57f78 removed the check. We don't want to break existing usages so this introduces it again with a successful exit code.
* patchShebangs: Allow for multiple argumentsDaniel Schaefer2019-05-25
| | | | | | | | It's tempting to think patchShebangs supports multiple arguments. Without this patch it just silently ignores all but the first. Now it patches the shebangs in all of its arguments. Fixes: #57695
* patchShebangs: Explain that script must be executableDaniel Schaefer2019-05-25
|
* Merge pull request #56744 from matthewbauer/macos-10-12Matthew Bauer2019-04-26
|\ | | | | Update macOS to 10.12
| * patch-shebangs: fix dev detectionMatthew Bauer2019-04-26
| | | | | | | | | | $output = $outputDev is the right condition. ${!outputDev} is only useful if you want a path.
| * Revert "Revert "patch-shebangs: respect cross compilation""Matthew Bauer2019-04-26
| | | | | | | | This reverts commit 9c4b11e9a060de2175aef4d36881f97812ab17fe.
* | Merge pull request #60215 from nmattia/nm-tmp-timestampGraham Christensen2019-04-25
|\ \ | |/ |/| patchShebangs: create timestamp in tmp dir
| * patchShebangs: create timestamp in tmp dirNicolas Mattia2019-04-25
| | | | | | | | | | | | | | | | Creating the timestamp in the patched script's directory has a few drawbacks: * if "foo.timestamp" already exists, it will be overwritten * it requires the directory to be writable
* | Merge remote-tracking branch 'origin/master' into stagingWael M. Nasreddine2019-03-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/master: (693 commits) buildGoModule: use go_1_12 instead of go_1_11 (#58103) gitAndTools.lab: 0.15.2 -> 0.15.3 (#58091) signal-desktop: 1.22.0 -> 1.23.0 added missing semicolon to documentation terminus_font_ttf: 4.46.0 -> 4.47.0 buildGoModule: remove SSL env vars in favor of cacert in buildInputs (#58071) dav1d: init at 0.2.1 dropbox-cli: 2018.11.28 -> 2019.02.14 atlassian-confluence: 6.14.1 -> 6.14.2 maintainers: update email for dywedir python.pkgs.hglib: use patch to specify hg path (#57926) chkrootkit: 0.52 -> 0.53 radare2-cutter: 1.7.2 -> 1.8.0 autorandr: 1.7 -> 1.8 pythonPackages.pyhepmc: fix build llvm-polly/clang-polly: use latest llvm apulse: 0.1.11.1 -> 0.1.12, cleanup factorio: experimental 0.17.14 → 0.17.16 (#58000) sequeler: 0.6.7 -> 0.6.8 nasc: 0.5.1 -> 0.5.2 ...
| * | auto-patchelf: don't use grep -q, as it causes Broken pipe (#56958)Danylo Hlynskyi2019-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This rare sitation was caught when building zoom-us package: ``` automatically fixing dependencies for ELF files /nix/store/71d65fplq44y9yn2fvkpn2d3hrszracd-auto-patchelf-hook/nix-support/setup-hook: line 213: echo: write error: Broken pipe /nix/store/71d65fplq44y9yn2fvkpn2d3hrszracd-auto-patchelf-hook/nix-support/setup-hook: line 210: echo: write error: Broken pipe ``` The worst is that derivation continued and resulted into broken package: https://github.com/NixOS/nixpkgs/pull/55566#issuecomment-470065690 I hope, replacing `grep -q` with `grep` will remove this race condition.
* | | wrapGAppsHook: add package’s own modules to GIO_EXTRA_MODULESJan Tojnar2019-03-13
|/ / | | | | | | | | | | | | | | | | When a package provides both executables and gio modules, it is quite probable the executables will need those modules. wrapGAppsHook wraps executables with GIO_EXTRA_MODULES picked up from dependencies but forgets about the package being built. Let’s add to consideration. Closes: https://github.com/NixOS/nixpkgs/issues/50254
* | Merge master into staging-nextFrederik Rietdijk2019-02-13
|\ \
| * | Document undocumented argument to makeWrapper()deliciouslytyped2019-02-11
| | |
* | | Merge pull request #54578 from alyssais/gcj-darwinAlyssa Ross2019-02-08
|\ \ \ | | | | | | | | gcj: fix build on Darwin
| * | | gcj: fix build on DarwinAlyssa Ross2019-01-30
| |/ / | | | | | | | | | Partially addresses https://github.com/NixOS/nixpkgs/issues/29715.
* / / wrap-gapps-hook.sh: only wrap links when requiredBruce Toll2019-01-31
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unless dontWrapGapps is set, the wrap-gapps-hook.sh will currently wrap all executables (and symbolic links to executables) found under the target directories: bin and libexec. As a result, if a symbolic link in a target directory points to an executable in a target directory, both will get wrapped. This causes an extra shell/exec when following the symbolic link, as well as increasing the size of the final executable's environment. To avoid wrapping a link to an already wrapped executable, this commit splits the determination of what gets wrapped into two phases: 1. All binaries under the target directories are wrapped and logged with "Wrapping program ..." 2. All links to executables under the target directories are identified and checked to see if they reference an executable under one of the target directories. If yes, the required wrapping has already been performed on the associated binary (in phase 1), so no wrapping is done and "Not wrapping link: ... (already wrapped)" is logged. If no, the link points at an executable that hasn't been wrapped, so the link is wrapped and "Wrapping link: ..." is logged. As an example, the yelp package has a bin directory that contains an executable "yelp" and a symbolic link "gnome-help" -> "yelp". Prior to this commit, the bin directory would contain these files after wrapping: gnome-help -- wrapper to exec .gnome-help-wrapped .gnome-help-wrapped -- a symbolic link to yelp yelp -- wrapper to exec .yelp-wrapped .yelp-wrapped -- the original yelp binary After this commit, the bin directory will instead contain: gnome-help -- a symbolic link to yelp yelp -- wrapper to exec .yelp-wrapped .yelp-wrapped -- the original yelp binary NOTE: The primary motivation for this commit is to avoid obscuring the fact that two or more paths are simple aliases and expected to behave identically. It also reduces the likelihood of hitting limits related to environment variable size. LIMITATION: The method used above is intended to be conservative and will still wrap symbolic links to other symbolic links when the ultimate target is outside of bin or libexec.
* | pruneLibtoolFiles: check if prefix existsPiotr Bogdan2018-12-09
| |
* | pruneLibtoolFiles: more permissive regex for detecting libtool filesPiotr Bogdan2018-12-09
| |
* | audit-tmpdir hook: clean up whitespaceBjørn Forsman2018-12-02
| |
* | audit-tmpdir hook: use abspath matching on RPATH entriesBjørn Forsman2018-12-02
| | | | | | | | | | | | This ensures that RPATH entries like "/foo/build/bar" doesn't trigger a match when TMPDIR is "/build/bar". (I've had this problem with a prebuilt package.)
* | Merge pull request #51217 from mayflower/source-date-epoch-fix-warningJohn Ericson2018-11-29
|\ \ | | | | | | set-source-date-epoch-to-latest: fix warning
| * | set-source-date-epoch-to-latest: fix warningRobin Gloster2018-11-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | If there was no older file than $NIX_BUILD_TOP this would result in a warning, e.g. with nix-info. ``` /nix/store/15kgcm8hnd99p7plqzx7p4lcr2jni4df-set-source-date-epoch-to-latest.sh: line 13: [: : integer expression expected ```
* | | Merge master into staging-nextFrederik Rietdijk2018-11-29
|\ \ \ | |/ / |/| |
| * | autoPatchelfHook: Skip on missing segment headersaszlig2018-11-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the file in question is not a shared object file but an ELF, we really want to skip the file, because we won't have anything to patch there. For example if the file is created via "gcc -c -o foo.o foo.c", we don't get a segment header and so far autoPatchelf was trying to patch such a file. By checking for missing segment headers, we're now no longer going to attempt patching such a file. Signed-off-by: aszlig <aszlig@nix.build> Reported-by: Sander van der Burg <svanderburg@gmail.com>
| * | autoPatchelfHook: Fix type of norecurse variableaszlig2018-11-26
| | | | | | | | | | | | | | | | | | | | | While declaring it as an array doesn't do any harm in our usage, it might be a bit confusing when reading the code. Signed-off-by: aszlig <aszlig@nix.build>
| * | autoPatchelfHook: Add addAutoPatchelfSearchPathaszlig2018-11-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function is useful if autoPatchelf is invoked during some of the phases of a build and allows to add arbitrary shared objects to the search path. So far the same functionality was in autoPatchelf itself, but not available as a separate function, so when adding shared objects to the dependency cache one would have to do so manually. The function also has the --no-recurse flag, which prevents recursing into subdirectories. Signed-off-by: aszlig <aszlig@nix.build>
| * | autoPatchelfHook: Add --no-recurse flagaszlig2018-11-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to be used with the autoPatchelf command and allows to only patch a specific file or directory without recursing into subdirectories. Apart from being able to run the command in a standalone way, as detailled in the previous commit this is also needed for the Android SDK emulator, because according to @svanderburg there are subdirectories we don't want to patch. The reason why I didn't use GNU getopt is that it might not be available on all operating systems and the getopts bash builtin doesn't support long arguments. Apart from that, the implementation for recognizing the flag is pretty trivial and it's also using bash builtins only, so if we want to do something really fancy someday, we can still change it. Signed-off-by: aszlig <aszlig@nix.build>
| * | autoPatchelfHook: Allow to prevent automatic runaszlig2018-11-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you want to only run autoPatchelf on a specific path and leave everything else alone, we now have a $dontAutoPatchelf environment variable, which causes the postFixup hook to not run at all. The name "dontAutoPatchelf" probably is a bit weird in conjunction with putting "autoPatchelfHook" in nativeBuildInputs, but unless someone comes up with a better name I keep it that way because it's consistent with all the other dontStrip, dontPatchShebangs, dontPatchELF and whatnot. A specific example where this is needed is when building the Android SDK emulator, which contains a few ARM binaries in subdirectories that should not be patched. If we were to run autoPatchelf on all outputs unconditionally we'd run into errors because some ARM libraries couldn't be found. Signed-off-by: aszlig <aszlig@nix.build>
| * | autoPatchelfHook: Make easier to run autoPatchelfaszlig2018-11-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The autoPatchelf main function which is run against all of the outputs was pretty much tailored towards this specific setup-hook and was relying on $prefix to be set globally. So if you wanted to run autoPatchelf manually - let's say during buildPhase - you would have needed to run it like this: prefix=/some/directory autoPatchelf This is now more intuitive and all you need to do is run the following: autoPatchelf /some/directory Signed-off-by: aszlig <aszlig@nix.build>
* | | tmpdir audit: only fail with files referenced below (#35068)zimbatm2018-11-16
| | | | | | | | | | | | | | | | | | | | | On Linux the `$TMPDIR` is `/build`. The TMPDIR audit looks for `$TMPDIR` in the build output, which will then fail with packages like /buildkite-agent. This fixes the heuristic to look for `$TMPDIR/` instead.
* | | Revert "Revert "Revert "patch-shebangs: respect cross compilation"""Daiderd Jordan2018-11-14
| | | | | | | | | | | | | | | | | | | | | Completely breaks darwin. Every package in the stdenv that has shebangs in the output will end up with references to bootstrap-tools. This reverts commit bde99096a80e74692795fa2782619c46a476839e.
* | | Revert "patch-shebangs: use --build for auto patch shebangs"Daiderd Jordan2018-11-14
| | | | | | | | | | | | | | | | | | | | | Completely breaks darwin. Every package in the stdenv that has shebangs in the output will end up with references to bootstrap-tools. This reverts commit eb7c50a993833ecdb94cc3affb55ac4c560edf50.
* | | Merge pull request #50244 from tathougies/travis/wrap-correctlyMatthew Bauer2018-11-13
|\ \ \ | | | | | | | | make-wrapper should use runtimeShell, not $SHELL, for cross-compilation
| * | | make-wrapper should use runtimeShell, not bash, for cross-compilationTravis Athougies2018-11-11
| |/ /
* | | Merge pull request #49608 from matthewbauer/cross-patch-shebangs-2Matthew Bauer2018-11-07
|\ \ \ | |/ / |/| | Restore cross-patch-shebangs branch
| * | patch-shebangs: use --build for auto patch shebangsMatthew Bauer2018-11-02
| | | | | | | | | | | | | | | | | | | | | | | | In strictDeps=false, autoPatchshebangs should use --build (corresponding to PATH) to lookup commands. This restores the previous behavior of patchshebangs so that we don’t break stuff that isn’t careful in the buildInputs vs. nativeBuildInputs distinction. Unfortunately this won’t work under cross compilation.
| * | Revert "Revert "patch-shebangs: respect cross compilation""Matthew Bauer2018-11-02
| | | | | | | | | | | | This reverts commit 9c4b11e9a060de2175aef4d36881f97812ab17fe.
* | | autoPatchelfHook: Correctly detect PIE binariesaszlig2018-11-03
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I originally thought it would just be enough to just check for an INTERP section in isExecutable, however this would mean that we don't detect statically linked ELF files, which would break our recent improvement to gracefully handle those. In theory, we are only interested in ELF files that have an INTERP section, so checking for INTERP would be enough. Unfortunately the isExecutable function is already used outside of autoPatchelfHook, so we can't easily get rid of it now, so let's actually strive for more correctness and make isExecutable actually match ELF files that are executable. So what we're doing instead now is to check whether either the ELF type is EXEC *or* we have an INTERP section and if one of them is true we should have an ELF executable, even if it's statically linked. Along the way I also set LANG=C for the invocations of readelf, just to be sure we don't get locale-dependent output. Tested this with the following command (which contains almost[1] all the packages using autoPatchelfHook), checking whether we run into any library-related errors: nix-build -E 'with import ./. { config.allowUnfree = true; }; runCommand "test-executables" { drvs = [ anydesk cups-kyodialog3 elasticsearch franz gurobi masterpdfeditor oracle-instantclient powershell reaper sourcetrail teamviewer unixODBCDrivers.msodbcsql17 virtlyst vk-messenger wavebox zoom-us ]; } ("for i in $drvs; do for b in $i/bin/*; do " + "[ -x \"$b\" ] && timeout 10 \"$b\" || :; done; done") ' Apart from testing against library-related errors I also compared the resulting store paths against the ones prior to this commit. Only anydesk and virtlyst had the same as they didn't have self-references, everything else differed only because of self-references, except elasticsearch, which had the following PIE binaries: * modules/x-pack/x-pack-ml/platform/linux-x86_64/bin/autoconfig * modules/x-pack/x-pack-ml/platform/linux-x86_64/bin/autodetect * modules/x-pack/x-pack-ml/platform/linux-x86_64/bin/categorize * modules/x-pack/x-pack-ml/platform/linux-x86_64/bin/controller * modules/x-pack/x-pack-ml/platform/linux-x86_64/bin/normalize These binaries were now patched, which is what this commit is all about. [1]: I didn't include the "maxx" package (MaXX Interactive Desktop) because the upstream URLs are no longer existing and I couldn't find them elsewhere on the web. Signed-off-by: aszlig <aszlig@nix.build> Fixes: https://github.com/NixOS/nixpkgs/issues/48330 Cc: @gnidorah (for MaXX Interactive Desktop)