makeBinaryWrapper: move into its own folder

The derivation is complex enough to warrant moving out of
all-packages.nix
This commit is contained in:
Naïm Favier 2022-05-10 15:51:43 +02:00
parent 3a79190750
commit 0d6bcb513b
No known key found for this signature in database
GPG Key ID: 49B07322580B7EE2
5 changed files with 30 additions and 27 deletions

View File

@ -869,7 +869,7 @@ makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz
makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello git ]}
```
Theres many more kinds of arguments, they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh` for the `makeWrapper` implementation and in `nixpkgs/pkgs/build-support/setup-hooks/make-binary-wrapper.sh` for the `makeBinaryWrapper` implementation.
Theres many more kinds of arguments, they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh` for the `makeWrapper` implementation and in `nixpkgs/pkgs/build-support/setup-hooks/make-binary-wrapper/make-binary-wrapper.sh` for the `makeBinaryWrapper` implementation.
`wrapProgram` is a convenience function you probably want to use most of the time, implemented by both `makeWrapper` and `makeBinaryWrapper`.

View File

@ -0,0 +1,20 @@
{ stdenv
, lib
, makeSetupHook
, dieHook
, tests
, cc ? stdenv.cc
, sanitizers ? []
}:
makeSetupHook {
deps = [ dieHook cc ];
substitutions = {
cc = let
san = lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers);
in "${cc}/bin/cc ${san}";
passthru.tests = tests.makeBinaryWrapper;
};
} ./make-binary-wrapper.sh

View File

@ -43,7 +43,7 @@ makeWrapper() {
mkdir -p "$(dirname "$wrapper")"
makeDocumentedCWrapper "$original" "$@" | \
@CC@ \
@cc@ \
-Wall -Werror -Wpedantic \
-Wno-overlength-strings \
-Os \

View File

@ -71,7 +71,13 @@ with pkgs;
dhall = callPackage ./dhall { };
makeWrapper = callPackage ./make-wrapper {};
makeWrapper = callPackage ./make-wrapper { };
makeBinaryWrapper = callPackage ./make-binary-wrapper {
makeBinaryWrapper = pkgs.makeBinaryWrapper.override {
sanitizers = pkgs.lib.optionals (! (pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64))
[ "undefined" "address" ];
};
};
pkgs-lib = recurseIntoAttrs (import ../pkgs-lib/tests { inherit pkgs; });
}

View File

@ -783,30 +783,7 @@ with pkgs;
}
../build-support/setup-hooks/make-wrapper.sh;
makeBinaryWrapper = let
f = { cc, sanitizers }: let
san = lib.concatMapStringsSep " " (s: "-fsanitize=${s}") sanitizers;
script = runCommand "make-binary-wrapper.sh" {} ''
substitute ${../build-support/setup-hooks/make-binary-wrapper.sh} $out \
--replace " @CC@ " " ${cc}/bin/cc ${san} "
'';
in
makeSetupHook {
deps = [ dieHook cc ];
substitutions.passthru.tests = callPackage ../test/make-binary-wrapper {
makeBinaryWrapper = makeBinaryWrapper.override {
sanitizers = (if stdenv.isDarwin && stdenv.isAarch64
then [ ]
else [ "undefined" "address" ]
);
};
};
} script;
in
lib.makeOverridable f {
cc = stdenv.cc;
sanitizers = [ ];
};
makeBinaryWrapper = callPackage ../build-support/setup-hooks/make-binary-wrapper { };
makeModulesClosure = { kernel, firmware, rootModules, allowMissing ? false }:
callPackage ../build-support/kernel/modules-closure.nix {