mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
pkgs/stdenv/make-derivation: move hostSuffix before the version
Adding the hostSuffix to the end of the derivation's name is problematic since some stuff, including user facing programs like nix-env rely on the behavior of parseDrvName instead of pname and version. builtins.parseDrvName currently thinks that the cross compilation target added via hostSuffix is part of the version. This has the practical consequence for example that nix-env would think a cross compiled derivation would be an updated version of a native derivation of the same package and version — breaking user's profiles. We can easily prevent this by moving the hostSuffix in between pname and version. In case name is passed to mkDerivation this is of course not possible and we are forced to fall back to the old behavior. This change could serve as a replacement for the migitation we introduced with the -static appendix to pname in order to avoid confusion between nix and nixStatic as outlined in the comment added with this commit.
This commit is contained in:
parent
99de33bb1d
commit
b0c26d2c40
@ -200,9 +200,7 @@ 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}${staticMarker}-${attrs.version}";
|
||||
# Indicate the host platform of the derivation if cross compiling.
|
||||
# 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
|
||||
@ -210,7 +208,16 @@ in rec {
|
||||
hostSuffix = lib.optionalString
|
||||
(stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix)
|
||||
"-${stdenv.hostPlatform.config}";
|
||||
in name' + hostSuffix;
|
||||
# Disambiguate statically built packages. This was originally
|
||||
# introduce as a means to prevent nix-env to get confused between
|
||||
# nix and nixStatic. This should be also achieved by moving the
|
||||
# hostSuffix before the version, so we could contemplate removing
|
||||
# it again.
|
||||
staticMarker = lib.optionalString stdenv.hostPlatform.isStatic "-static";
|
||||
in
|
||||
if attrs ? name
|
||||
then attrs.name + hostSuffix
|
||||
else "${attrs.pname}${staticMarker}${hostSuffix}-${attrs.version}";
|
||||
}) // {
|
||||
builder = attrs.realBuilder or stdenv.shell;
|
||||
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
|
||||
|
Loading…
Reference in New Issue
Block a user