Commit Graph

533 Commits

Author SHA1 Message Date
Alyssa Ross
f82a1d12eb Revert "make-binary-wrapper: add cc to propagatedBuildInputs"
This reverts commit 0c34636a56.

Seems to be causing some weird side effects. pkgsMusl.systemd no
longer builds:

Command line: `clang /run/user/1008/tmp.WuVNjgdfHT/source/build/meson-private/tmpdd3qc57v/testfile.c -o /run/user/1008/tmp.WuVNjgdfHT/source/build/meson-private/tmpdd3qc57v/output.obj -c -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -std=gnu11` -> 1
stderr:
clang: error: argument unused during compilation: '-pie' [-Werror,-Wunused-command-line-argument]
2024-05-27 21:56:47 +02:00
John Ericson
e897cae4da
Merge pull request #311794 from rhelmot/freebsd-minimal3/make-binary-wrapper
make-binary-wrapper: add cc to propagatedBuildInputs
2024-05-26 11:50:45 -04:00
Thomas Watson
4d6d293fad setup-hooks/strip: uniqify files by inode number before stripping
https://github.com/NixOS/nixpkgs/pull/246164 but for hardlinks.

Mesa, among other packages, has binaries that are linked together and
can end up corrupted when the same binary is stripped through two
different names.

To resolve this, print out the device and inode number before each file
name, sort/uniq based on that, then cut it back out before stripping.

The symlink resolution logic is removed as the same file accessed
through two different links in `$paths` will necessarily have the same
numbers. File/directory within the paths listed in `$paths` are
correctly not (and were never) processed due to the `-type f` predicate
and (implied) `-P` option to `find`.
2024-05-24 16:53:14 -05:00
Artemis Tosini
0c34636a56 make-binary-wrapper: add cc to propagatedBuildInputs
Adding cc to propagatedBuildInputs makes derivations with
makeBinaryWrapper in nativeBuildInputs run the cc-wrapper
setup hook. This isn't an issue for derivations using
stdenv, as the cc setup hook is already run by default.
However, derivations that are made with stdenvNoCC, e.g.
because they're made with runCommand, will not run the
cc-wrapper setup hook without this change.

For some reason the FreeBSD native compiler will not work
correctly without the setup hook.
2024-05-17 12:52:49 -07:00
Jan Tojnar
eb04659fc2 treewide: wrapGAppsHook → wrapGAppsHook3
This was achieved using the following command:

    sd 'wrapGAppsHook\b' wrapGAppsHook3 (rg -l 'wrapGAppsHook\b')

And then manually reverted the following changes:

- alias in top-level.nix
- function name in wrap-gapps-hook.sh
- comment in postFixup of at-spi2-core
- comment in gtk4
- comment in preFixup of 1password-gui/linux.nix
- comment in postFixup of qgis/unwrapped-ltr.nix and qgis/unwrapped.nix
- comment in postFixup of telegram-desktop
- comment in postFixup of fwupd
- buildCommand of mongodb-compass
- postFixup of xflux-gui
- comment in a patch in kdePackages.kde-gtk-config and plasma5Packages.kde-gtk-config
- description of programs.sway.wrapperFeatures.gtk NixOS option (manual rebuild)
2024-04-27 02:23:22 +02:00
Jan Tojnar
70cf3ecaae wrapGAppsHook: Flip inheritance relationship with wrapGAppsNoGuiHook 2024-04-27 00:05:46 +02:00
Philip Taron
83440df1f6
auditBlasHook: remove
This was added in d83e9c9573,
but included substitution variables `@blas@` and `@lapack@` that were
never substituted. It's not used anywhere in `nixpkgs`.
2024-04-02 10:50:15 -07:00
Domen Kožar
fb884172ab
Merge pull request #297628 from cwp/python-env-venv
Fix venv creation in Python environments
2024-03-22 19:17:13 +07:00
Colin Putney
234bb31f61
Fix venv creation in Python environments
The way we build python environments is subtly broken. A python
environment should be semantically identical to a vanilla Python
installation in, say, /usr/local. The current implementation, however,
differs in two important ways. The first is that it's impossible to use
python packages from the environment in python virtual environments. The
second is that the nix-generated environment appears to be a venv, but
it's not.

This commit changes the way python environments are built:

  * When generating wrappers for python executables, we inherit argv[0]
    from the wrapper. This causes python to initialize its configuration
    in the environment with all the correct paths.
  * We remove the sitecustomize.py file from the base python package.
    This file was used tweak the python configuration after it was
    incorrectly initialized. That's no longer necessary.

The end result is that python environments no longer appear to be venvs,
and behave more like a vanilla python installation. In addition it's
possible to create a venv using an environment and use packages from
both the environment and the venv.
2024-03-21 19:26:57 -06:00
github-actions[bot]
66eeab8faf
Merge staging-next into staging 2024-03-19 06:01:43 +00:00
Qyriad
2ad2295bb3 autoPatchelfHook: move multiline hook into a function
In NixOS/nixpkgs#290081 it came to attention that autoPatchelfHook is
one of if not the only hook in Nixpkgs that is a multiline string
expression. Almost all hooks are functions, which guard with something
like `if [ -z "${dontDoTheThing-}" ]; then ...` in the function, or
single-line strings which include that guard inline and then call the
real function, e.g. `if [ -z "${dontDoTheThing-} ]; then doTheThing; fi`.

This commit moves autoPatchelfHook to the former, which seems to be the
most common style now.
2024-03-17 09:48:43 -06:00
TomaSajt
48285f7169
stripJavaArchivesHook: rename from canonicalize-jars-hook and use strip-nondeterminism 2024-03-17 13:30:54 +01:00
Rick van Schijndel
b728d76d0e
Merge pull request #255463 from emilylange/stdenv/patch-shebangs-trailing-newline
patch-shebangs: fix crash with shebang without trailing newline
2024-02-16 18:33:27 +01:00
Mario Rodas
70b51d8d17 postgresqlTestHook: add postgresqlExtraSettings variable
Add `postgresqlExtraSettings` to allow to setup the `postgresql.conf`.
This would be useful in cases where we need to set
`shared_preload_libraries`.
2024-01-22 04:20:00 +00:00
Connor Baker
45901c42fc auto-patchelf: improve deprecation check by searching all elements 2023-12-14 16:53:34 +00:00
Connor Baker
9faad7fb0b auto-patchelf: add support for __structuredAttrs 2023-12-14 16:32:29 +00:00
Alyssa Ross
52a13b8125 separateDebugInfo: use NIX_RUSTFLAGS
Setting RUSTFLAGS causes Cargo to ignore other ways of configuring
flags, including the target-specific RUSTFLAGS options.  This broke
pkgsCross.musl64.crosvm, and was surprising to users.

Fixes: https://github.com/NixOS/nixpkgs/pull/261727
2023-11-30 09:23:06 +00:00
K900
b852b4fa5a autoPatchelfHook: fix arguments parsing 2023-11-17 20:46:13 +03:00
Jari Vetoniemi
0c73f39dab darwin: fix also .so names in darwin
Darwin does not actually require `*.dylib` extension, and some ports of
unix software may still simply compile and install these as `*.so` files.

Include `*.so` in the find in this case.

Co-authored-by: Artturi <Artturin@artturin.com>
Co-authored-by: toonn <toonn@toonn.io>
2023-10-28 00:00:52 +02:00
K900
10cb2bd443 autoPatchelfHook: add patchelfFlags option
This may be useful. Eventually. Maybe.
2023-09-30 10:26:35 +03:00
Artturi
6096abb008
Merge pull request #255208 from rhendric/rhendric/make-binary-wrapper 2023-09-20 09:41:44 +03:00
Ryan Hendrickson
df8b425f89 makeBinaryWrapper: protect wildcards in flags 2023-09-18 02:49:33 -04:00
Nick Cao
c6e11d15ce
makeBinaryWrapper.extractCmd: fix use in cross compilation 2023-09-16 22:17:22 -04:00
emilylange
c47f245253
patch-shebangs: fix crash with shebang without trailing newline
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-09-16 14:20:56 +02:00
toonn
924efe5313
Merge pull request #249268 from Enzime/remmina-bundle
writeDarwinBundle: use binary wrapper
2023-09-14 15:05:13 +02:00
Artturi
31c9deb4f7
Merge pull request #218783 from timbertson/stripExcludeExtensions 2023-09-05 00:37:17 +03:00
Artturi
d5139e3017
Merge pull request #245909 from Artturin/setupshchanges2 2023-09-04 20:41:16 +03:00
Artturin
fa98c56f75 setup-hooks/separate-debug-info.sh: Warn if necessary variables are not set
`$OBJCOPY` is not available in bootstrap tools
`stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.bash.stdenv.cc.bintools`
2023-09-03 23:02:45 +03:00
Tim Cuthbertson
0bffcc3f3c setup-hooks/strip: add stripExclude 2023-09-03 20:18:10 +03:00
Artturin
1db1e3c467 stdenv: Fix possible issues discovered with
```
set -o errexit -o nounset -o pipefail
shopt -s inherit_errexit
```

in `stdenv/default-builder.sh`
2023-09-02 03:25:36 +03:00
brano543
1086f093a9 win-dll-links: also copy dll from dependencies
Fixes running `pkgsCross.mingwW64._7zz` in wine.

Fixes issue 38451

```
tree result/bin
result/bin
├── 7zz.exe
└── mcfgthread-12.dll -> ../../wmgj476qjfw26f9aij1d64lxrjfv6kk0-mcfgthreads-x86_64-w64-mingw32-git/bin/mcfgthread-12.dll
```

Co-authored-by: marius david <marius@mariusdavid.fr>
2023-08-31 21:47:48 +03:00
markuskowa
212d454c2a
Merge pull request #246867 from markuskowa/add-mpi-hook
add mpiCheckPhaseHook
2023-08-26 11:54:56 +02:00
Markus Kowalewski
587a19e43c mpiCheckPhaseHook: add new setup hook for MPI aware check phases
Add this hook to checkPhase to allow for running MPI application in
the sandbox. It detects the MPI implementations and sets the respective
environment variables.
2023-08-22 23:27:47 +02:00
Michael Hoang
66884a4912 writeDarwinBundle: use binary wrapper
Previously `writeDarwinBundle` used a handcrafted shell wrapper, however
this causes issues on Apple Silicon Macs as script-only application
bundles are always run under Rosetta[0][1].

Replacing the handcrafted shell wrapper with a binary wrapper allows
apps to run natively instead of requiring Rosetta. However, this means
we can no longer use `$1` and `$@`.

After checking nearly every current usage of `desktopToDarwinBundle`,
there were no apps that used `%[fFuU]` before the last argument, meaning
removing them naively is good enough for the current apps.

[0]: https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary
[1]: https://stackoverflow.com/a/68208374
2023-08-21 13:29:12 +10:00
Artturin
520a544ee5 setup-hooks/strip: Create the log file in '$TMDPIR'
vcunat said

> This invocation of mktemp creates the file in the current directory, which is bad practice. We should add "--tmpdir=$TMPDIR" or make the template absolute.

> I noticed because one package did cd $src during installing, which is a read-only path...
2023-08-07 18:20:56 +03:00
Theodore Ni
ca73fb024a
makeBinaryWrapper: remove cc dependency on aarch64-darwin 2023-08-04 14:12:56 -07:00
Artturi
c0731df13c
Merge pull request #238525 from tie/patch-shebang-update-store-paths 2023-08-04 01:21:07 +03:00
Vladimír Čunát
2141d9879a
Revert "stdenv: use improved strip.sh for aarch64-linux"
This reverts commit 39919b8f21.
The parent merge resolved this more properly.
2023-07-31 11:20:15 +02:00
Linus Heckemann
a3d2e71a6c
Merge pull request #246164 from trofi/strip-no-symlinks
setup-hooks/strip: resolve/uniq symlinks before stripping
2023-07-31 11:02:20 +02:00
Vladimír Čunát
39919b8f21
stdenv: use improved strip.sh for aarch64-linux
Adapted from PR #246164
TODO: clean up / use it everywhere on the next rebuild.
2023-07-30 21:18:30 +02:00
Sergei Trofimovich
7adf0a4eeb setup-hooks/strip: resolve/uniq symlinks before stripping
Before the change the hook had a chance to run `strip` against the same
file using multiple link paths. In case of `gcc` `libgcc.a` was stripped
multiple times in parallel and produces corrupted archive.

The change runs inputs via `realpath | uniq` to make sure we don't
attempt to strip the same files multiple times.
2023-07-30 16:27:18 +01:00
Artturin
f46c8c1bcd setup-hooks/strip: Exit if cmd or ranlibCmd are empty 2023-07-21 21:57:44 +03:00
Artturin
2ae18b7e10 setup-hooks/strip: Add -- before $cmd 2023-07-21 21:57:44 +03:00
Artturin
5093766f79 setup-hooks/strip: Print strip stderr if command fails
This is easiest to do through a file.

mktemp needs six X because busybox only accepts exactly six X.
2023-07-21 21:57:44 +03:00
Linus Heckemann
70945eb79b setup-hooks/strip: parallelise stripping
This makes bootstrapping to GNU hello ~1-2% faster on an 8-core
machine and ~3-4% faster on a 64-core machine.
2023-07-10 12:24:13 +02:00
Ivan Trubach
ebd4619053 patch-shebangs: add a flag to update shebangs with store paths
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-19 09:01:21 +03:00
James Kay
40fbc97988 makeWrapper: fix flag handling
When `--add-flags` is not used, `flagsBefore` is unset.  This causes an error when invoking `makeWrapper` from a context that sets `-o nounset`, as is done in `buildDotnetModule`.
This change makes `makeWrapper` safe for use in these conditions.
2023-06-11 23:14:54 +03:00
fetsorn
3565fdf30c pkgs/build-support: fix typos 2023-05-31 04:00:14 +04:00
Guillaume Maudoux
dd0dee4c97 autoPatchelfHook: Add support for single files 2023-05-30 13:48:30 +02:00
Vladimír Čunát
50983f16a3
Merge #229154: staging: make wrapProgram<Type> use the right wrapper
...into staging
2023-05-01 10:17:18 +02:00