From 7f623cfa45d3262e37f7961efe2c02406a94f4b6 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 28 Feb 2018 14:22:19 -0500 Subject: [PATCH] callCabal2nix: Fix filtering for non-cleanSourceable sources. What was here before wasn't correct anyway, and now it works in restricted mode. Fixes #35207 --- .../build-support/safe-discard-string-context.nix | 14 -------------- .../haskell-modules/make-package-set.nix | 15 +++++++-------- pkgs/top-level/all-packages.nix | 2 -- 3 files changed, 7 insertions(+), 24 deletions(-) delete mode 100644 pkgs/build-support/safe-discard-string-context.nix diff --git a/pkgs/build-support/safe-discard-string-context.nix b/pkgs/build-support/safe-discard-string-context.nix deleted file mode 100644 index 293a15295d55..000000000000 --- a/pkgs/build-support/safe-discard-string-context.nix +++ /dev/null @@ -1,14 +0,0 @@ -# | Discard the context of a string while ensuring that expected path -# validity invariants hold. -# -# This relies on import-from-derivation, but it is only useful in -# contexts where the string is going to be used in an -# import-from-derivation anyway. -# -# safeDiscardStringContext : String → String -{ writeText }: s: - builtins.seq - (import (writeText - "discard.nix" - "${builtins.substring 0 0 s}null\n")) - (builtins.unsafeDiscardStringContext s) diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 2c628eff5622..458c4eae136d 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -148,14 +148,13 @@ in package-set { inherit pkgs stdenv callPackage; } self // { callCabal2nix = name: src: args: overrideCabal (self.callPackage (haskellSrc2nix { inherit name; - src = pkgs.lib.cleanSourceWith - { src = if pkgs.lib.canCleanSource src - then src - else pkgs.safeDiscardStringContext src; - filter = path: type: - pkgs.lib.hasSuffix "${name}.cabal" path || - pkgs.lib.hasSuffix "package.yaml" path; - }; + src = + let filter = path: type: + pkgs.lib.hasSuffix "${name}.cabal" path || + baseNameOf path == "package.yaml"; + in if pkgs.lib.canCleanSource src + then pkgs.lib.cleanSourceWith { inherit src filter; } + else src; }) args) (_: { inherit src; }); # : { root : Path diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 62a9e9714d92..b79099c28bdf 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20842,8 +20842,6 @@ with pkgs; tlwg = callPackage ../data/fonts/tlwg { }; - safeDiscardStringContext = callPackage ../build-support/safe-discard-string-context.nix { }; - simplehttp2server = callPackage ../servers/simplehttp2server { }; diceware = callPackage ../tools/security/diceware { };