From fe0524cd7dfebc237eff2fc8969d507f84ec2b13 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 13 Apr 2021 12:31:26 +0200 Subject: [PATCH 1/3] stdenv/make-derivation: unify logic for name modifications Unify the logic for constructing the name from pname and version and modifying the name in case a host suffix needs to appended. This allows us to modify the construction of name from pname and version without having to duplicate it in two places. --- pkgs/stdenv/generic/make-derivation.nix | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 2b89b37f786..65ef2ea2834 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -193,15 +193,20 @@ 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 + name' = attrs.name or + "${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. + 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; From 851c0f1cb782bcc476ec115a72d0329da4af68dc Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 13 Apr 2021 12:33:00 +0200 Subject: [PATCH 2/3] stdenv/make-derivation: add -static to name if building statically --- pkgs/stdenv/generic/make-derivation.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 65ef2ea2834..74609412782 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -196,8 +196,9 @@ in rec { // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) { name = let + staticMarker = lib.optionalString stdenv.hostPlatform.isStatic "-static"; name' = attrs.name or - "${attrs.pname}-${attrs.version}"; + "${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 From f4e8746cb224b52ee3e8683ce4ec4efa9e820413 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 13 Apr 2021 13:10:56 +0200 Subject: [PATCH 3/3] nix{,Unstable}: pass pname, version to mkDerivation This allows stdenv.mkDerivation to append -static to the name for pkgsStatic.nix / nixStatic which should make nix-env stop thinking that nixStatic is a newer version of nix. This change replaces #119310. --- pkgs/tools/package-management/nix/default.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix index 2358f6e3350..7eda5ae6f35 100644 --- a/pkgs/tools/package-management/nix/default.nix +++ b/pkgs/tools/package-management/nix/default.nix @@ -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"; @@ -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"; }; @@ -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 {