callCabal2nix: Fix calling with a path in the store.
This commit is contained in:
parent
7fedfeabae
commit
4e78aeb441
@ -93,7 +93,7 @@ let
|
|||||||
hiPrioSet;
|
hiPrioSet;
|
||||||
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
||||||
cleanSource sourceByRegex sourceFilesBySuffices
|
cleanSource sourceByRegex sourceFilesBySuffices
|
||||||
commitIdFromGitRepo cleanSourceWith;
|
commitIdFromGitRepo cleanSourceWith pathHasContext canCleanSource;
|
||||||
inherit (modules) evalModules closeModules unifyModuleSyntax
|
inherit (modules) evalModules closeModules unifyModuleSyntax
|
||||||
applyIfFunction unpackSubmodule packSubmodule mergeModules
|
applyIfFunction unpackSubmodule packSubmodule mergeModules
|
||||||
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
||||||
|
@ -93,4 +93,8 @@ rec {
|
|||||||
else lib.head matchRef
|
else lib.head matchRef
|
||||||
else throw ("Not a .git directory: " + path);
|
else throw ("Not a .git directory: " + path);
|
||||||
in lib.flip readCommitFromFile "HEAD";
|
in lib.flip readCommitFromFile "HEAD";
|
||||||
|
|
||||||
|
pathHasContext = builtins.hasContext or (lib.hasPrefix builtins.storeDir);
|
||||||
|
|
||||||
|
canCleanSource = src: src ? _isLibCleanSourceWith || !(pathHasContext (toString src));
|
||||||
}
|
}
|
||||||
|
14
pkgs/build-support/safe-discard-string-context.nix
Normal file
14
pkgs/build-support/safe-discard-string-context.nix
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# | 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)
|
@ -146,7 +146,9 @@ in package-set { inherit pkgs stdenv callPackage; } self // {
|
|||||||
overrideCabal (self.callPackage (haskellSrc2nix {
|
overrideCabal (self.callPackage (haskellSrc2nix {
|
||||||
inherit name;
|
inherit name;
|
||||||
src = pkgs.lib.cleanSourceWith
|
src = pkgs.lib.cleanSourceWith
|
||||||
{ inherit src;
|
{ src = if pkgs.lib.canCleanSource src
|
||||||
|
then src
|
||||||
|
else pkgs.safeDiscardStringContext src;
|
||||||
filter = path: type:
|
filter = path: type:
|
||||||
pkgs.lib.hasSuffix "${name}.cabal" path ||
|
pkgs.lib.hasSuffix "${name}.cabal" path ||
|
||||||
pkgs.lib.hasSuffix "package.yaml" path;
|
pkgs.lib.hasSuffix "package.yaml" path;
|
||||||
|
@ -20237,4 +20237,6 @@ with pkgs;
|
|||||||
wal-g = callPackage ../tools/backup/wal-g {};
|
wal-g = callPackage ../tools/backup/wal-g {};
|
||||||
|
|
||||||
tlwg = callPackage ../data/fonts/tlwg { };
|
tlwg = callPackage ../data/fonts/tlwg { };
|
||||||
|
|
||||||
|
safeDiscardStringContext = callPackage ../build-support/safe-discard-string-context.nix { };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user