Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdenv.mkDerivation: add -static to name if building statically #119317

Merged
merged 3 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,21 @@ in rec {
"__darwinAllowLocalNetworking"
"__impureHostDeps" "__propagatedImpureHostDeps"
"sandboxProfile" "propagatedSandboxProfile"])
// (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) {
name = "${attrs.pname}-${attrs.version}";
} // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {
# Fixed-output derivations like source tarballs shouldn't get a host
# 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.
name = "${attrs.name or "${attrs.pname}-${attrs.version}"}-${stdenv.hostPlatform.config}";
} // {
// (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
name =
let
staticMarker = lib.optionalString stdenv.hostPlatform.isStatic "-static";
name' = attrs.name or
"${attrs.pname}${staticMarker}-${attrs.version}";
# Fixed-output derivations like source tarballs shouldn't get a host
# 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;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
inherit stdenv;
Expand Down
13 changes: 7 additions & 6 deletions pkgs/tools/package-management/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ common =
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
, enableStatic ? stdenv.hostPlatform.isStatic
, name, suffix ? "", src
, pname, version, suffix ? "", src
, patches ? [ ]
}:
let
sh = busybox-sandbox-shell;
nix = stdenv.mkDerivation rec {
inherit name src patches;
version = lib.getVersion name;
inherit pname version src patches;

is24 = lib.versionAtLeast version "2.4pre";

Expand Down Expand Up @@ -196,9 +195,10 @@ in rec {
nix = nixStable;

nixStable = callPackage common (rec {
name = "nix-2.3.10";
pname = "nix";
version = "2.3.10";
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";
};

Expand All @@ -213,7 +213,8 @@ in rec {
});

nixUnstable = lib.lowPrio (callPackage common rec {
name = "nix-2.4${suffix}";
pname = "nix";
version = "2.4${suffix}";
suffix = "pre20210326_dd77f71";

src = fetchFromGitHub {
Expand Down