Merge pull request #119317 from sternenseemann/static-naming

stdenv.mkDerivation: add -static to name if building statically
This commit is contained in:
Domen Kožar
2021-04-13 15:04:02 +02:00
committed by GitHub
2 changed files with 22 additions and 15 deletions
+15 -9
View File
@@ -193,15 +193,21 @@ in rec {
"__darwinAllowLocalNetworking" "__darwinAllowLocalNetworking"
"__impureHostDeps" "__propagatedImpureHostDeps" "__impureHostDeps" "__propagatedImpureHostDeps"
"sandboxProfile" "propagatedSandboxProfile"]) "sandboxProfile" "propagatedSandboxProfile"])
// (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) { // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
name = "${attrs.pname}-${attrs.version}"; name =
} // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) { let
# Fixed-output derivations like source tarballs shouldn't get a host staticMarker = lib.optionalString stdenv.hostPlatform.isStatic "-static";
# suffix. But we have some weird ones with run-time deps that are name' = attrs.name or
# just used for their side-affects. Those might as well since the "${attrs.pname}${staticMarker}-${attrs.version}";
# hash can't be the same. See #32986. # Fixed-output derivations like source tarballs shouldn't get a host
name = "${attrs.name or "${attrs.pname}-${attrs.version}"}-${stdenv.hostPlatform.config}"; # suffix. But we have some weird ones with run-time deps that are
} // { # just used for their side-affects. Those might as well since the
# hash can't be the same. See #32986.
hostSuffix = lib.optionalString
(stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix)
"-${stdenv.hostPlatform.config}";
in name' + hostSuffix;
}) // {
builder = attrs.realBuilder or stdenv.shell; builder = attrs.realBuilder or stdenv.shell;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
inherit stdenv; inherit stdenv;
@@ -24,14 +24,13 @@ common =
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp , withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp , withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
, enableStatic ? stdenv.hostPlatform.isStatic , enableStatic ? stdenv.hostPlatform.isStatic
, name, suffix ? "", src , pname, version, suffix ? "", src
, patches ? [ ] , patches ? [ ]
}: }:
let let
sh = busybox-sandbox-shell; sh = busybox-sandbox-shell;
nix = stdenv.mkDerivation rec { nix = stdenv.mkDerivation rec {
inherit name src patches; inherit pname version src patches;
version = lib.getVersion name;
is24 = lib.versionAtLeast version "2.4pre"; is24 = lib.versionAtLeast version "2.4pre";
@@ -196,9 +195,10 @@ in rec {
nix = nixStable; nix = nixStable;
nixStable = callPackage common (rec { nixStable = callPackage common (rec {
name = "nix-2.3.10"; pname = "nix";
version = "2.3.10";
src = fetchurl { src = fetchurl {
url = "https://nixos.org/releases/nix/${name}/${name}.tar.xz"; url = "https://nixos.org/releases/nix/${pname}-${version}/${pname}-${version}.tar.xz";
sha256 = "a8a85e55de43d017abbf13036edfb58674ca136691582f17080c1cd12787b7ab"; sha256 = "a8a85e55de43d017abbf13036edfb58674ca136691582f17080c1cd12787b7ab";
}; };
@@ -213,7 +213,8 @@ in rec {
}); });
nixUnstable = lib.lowPrio (callPackage common rec { nixUnstable = lib.lowPrio (callPackage common rec {
name = "nix-2.4${suffix}"; pname = "nix";
version = "2.4${suffix}";
suffix = "pre20210326_dd77f71"; suffix = "pre20210326_dd77f71";
src = fetchFromGitHub { src = fetchFromGitHub {