From 218d4dc154faca85c5e0024c6ab7bf2d1ddac0a5 Mon Sep 17 00:00:00 2001 From: Will Dietz <w@wdtz.org> Date: Fri, 22 Dec 2017 16:05:33 -0500 Subject: [PATCH] make-derivation: Don't add host-suffix to fixed-output derivations names Not only does the suffix unnecessarily reduce sharing, but it also breaks unpacker setup hooks (e.g. that of `unzip`) which identify interesting tarballs using the file extension. This also means we can get rid of the splicing hacks for fetchers. --- pkgs/stdenv/generic/make-derivation.nix | 13 +++++++++++-- pkgs/top-level/splice.nix | 9 ++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index dce715a6a53e..778f107f71e1 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -77,8 +77,13 @@ rec { , ... } @ attrs: - # TODO(@Ericson2314): Make this more modular, and not O(n^2). let + fixedOutputDrv = attrs ? outputHash; + noNonNativeDeps = builtins.length (depsBuildTarget ++ depsBuildTargetPropagated + ++ depsHostHost ++ depsHostHostPropagated + ++ buildInputs ++ propagatedBuildInputs + ++ depsTargetTarget ++ depsTargetTargetPropagated) == 0; + runtimeSensativeIfFixedOutput = fixedOutputDrv -> !noNonNativeDeps; supportedHardeningFlags = [ "fortify" "stackprotector" "pie" "pic" "strictoverflow" "format" "relro" "bindnow" ]; defaultHardeningFlags = lib.remove "pie" supportedHardeningFlags; enabledHardeningOptions = @@ -168,7 +173,11 @@ rec { # A hack to make `nix-env -qa` and `nix search` ignore broken packages. # TODO(@oxij): remove this assert when something like NixOS/nix#1771 gets merged into nix. name = assert validity.handled; name + lib.optionalString - (stdenv.hostPlatform != stdenv.buildPlatform) + # 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. + (stdenv.hostPlatform != stdenv.buildPlatform && runtimeSensativeIfFixedOutput) ("-" + stdenv.hostPlatform.config); builder = attrs.realBuilder or stdenv.shell; diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix index 1fde08d1d48b..078075323dd0 100644 --- a/pkgs/top-level/splice.nix +++ b/pkgs/top-level/splice.nix @@ -31,13 +31,8 @@ let then defaultBuildHostScope else assert pkgs.hostPlatform == pkgs.buildPlatform; defaultHostTargetScope; defaultHostHostScope = {}; # unimplemented - # TODO(@Ericson2314): we shouldn't preclude run-time fetching by removing - # these attributes. We should have a more general solution for selecting - # whether `nativeDrv` or `crossDrv` is the default in `defaultScope`. - pkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs; - targetPkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs.targetPackages; - defaultHostTargetScope = pkgsWithoutFetchers // pkgs.xorg; - defaultTargetTargetScope = targetPkgsWithoutFetchers // targetPkgsWithoutFetchers.xorg or {}; + defaultHostTargetScope = pkgs // pkgs.xorg; + defaultTargetTargetScope = pkgs.targetPackages // pkgs.targetPackages.xorg or {}; splicer = pkgsBuildBuild: pkgsBuildHost: pkgsBuildTarget: pkgsHostHost: pkgsHostTarget: