mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
mkStackPkgSet: filter out $locals package (#393)
I found that if I added this to my stack.yaml: ghc-options: $locals: -ddump-to-file -ddump-hi As specified in https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-options Then my build would fail to evaluate with: error: The option `packages."\$locals".package.identifier.name' is used but not defined. So to fix it, we filter out these special package globs in mkStackPkgSet. This commit also adds a regression test for that configuration option.
This commit is contained in:
parent
81a6da3c41
commit
d7d24fde4b
@ -105,6 +105,11 @@ self: super: {
|
||||
# The compiler referenced in the stack config
|
||||
compiler = (stack-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
|
||||
patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
|
||||
# Remove fake packages generated from stack keywords used in ghc-options
|
||||
removeStackSpecial = module: if builtins.typeOf module == "set"
|
||||
then module // { packages = removeSpecialPackages (module.packages or {}); }
|
||||
else module;
|
||||
removeSpecialPackages = ps: removeAttrs ps [ "$locals" "$targets" "$everything" ];
|
||||
in mkPkgSet {
|
||||
pkg-def = excludeBootPackages pkg-def;
|
||||
pkg-def-extras = [ stack-pkgs.extras
|
||||
@ -115,7 +120,7 @@ self: super: {
|
||||
# and we should trust stackage here!
|
||||
modules = [ { doExactConfig = true; } patchesModule ]
|
||||
++ modules
|
||||
++ stack-pkgs.modules or [];
|
||||
++ map removeStackSpecial (stack-pkgs.modules or []);
|
||||
};
|
||||
|
||||
# Create a Haskell package set based on a Cabal configuration.
|
||||
|
@ -8,6 +8,11 @@ let
|
||||
};
|
||||
packages = project.hsPkgs;
|
||||
|
||||
# Get the names of all packages. This is a test to see
|
||||
# whether there is a broken "$locals" package present.
|
||||
hasIdentifier = p: p != null && p ? identifier;
|
||||
packageNames = mapAttrsToList (name: p: p.identifier.name) (filterAttrs (name: hasIdentifier) packages);
|
||||
|
||||
in recurseIntoAttrs {
|
||||
ifdInputs = {
|
||||
inherit (project) stack-nix;
|
||||
@ -19,7 +24,7 @@ in recurseIntoAttrs {
|
||||
printf "checking whether executable runs... " >& 2
|
||||
cat ${haskellLib.check packages.test-ghc-options.components.exes.test-ghc-options-exe}
|
||||
|
||||
touch $out
|
||||
echo '${concatStringsSep " " packageNames}' > $out
|
||||
'';
|
||||
|
||||
meta.platforms = platforms.all;
|
||||
@ -29,4 +34,4 @@ in recurseIntoAttrs {
|
||||
inherit project packages;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,5 @@ packages:
|
||||
|
||||
ghc-options:
|
||||
test-ghc-options: -DTEST_GHC_OPTION
|
||||
# See https://github.com/ndmitchell/weeder/issues/53
|
||||
$locals: -ddump-to-file -ddump-hi
|
||||
|
Loading…
Reference in New Issue
Block a user