1
1
mirror of https://github.com/nmattia/snack.git synced 2025-01-06 04:25:30 +03:00

Don't use store paths as attr names

This commit is contained in:
Nicolas Mattia 2018-09-01 20:39:51 +03:00
parent a1e352a780
commit 6860bac91f
2 changed files with 22 additions and 27 deletions

View File

@ -73,33 +73,28 @@ rec {
[ modSpec ] ++
( lib.lists.concatMap flattenModuleSpec modSpec.moduleImports );
allTransitiveDeps = allTransitiveLists "moduleDependencies" lib.id;
allTransitiveGhcOpts = allTransitiveLists "moduleGhcOpts" lib.id;
allTransitiveExtensions = allTransitiveLists "moduleExtensions" lib.id;
allTransitiveDirectories =
allTransitiveLists
"moduleDirectories"
builtins.toString; # XXX: is toString correct?
allTransitiveImports =
allTransitiveLists
"moduleImports"
(modSpec: modSpec.moduleName);
allTransitiveLists = attr: toLabel: modSpecs:
lib.attrsets.attrValues
( foldDAG
{ f = modSpec:
lib.lists.foldl
(x: y: x // { ${toLabel y} = y;})
{} modSpec.${attr};
empty = {};
elemLabel = modSpec: modSpec.moduleName;
reduce = a: b: a // b;
elemChildren = modSpec: modSpec.moduleImports;
}
modSpecs
);
allTransitiveDeps = allTransitiveLists "moduleDependencies";
allTransitiveGhcOpts = allTransitiveLists "moduleGhcOpts";
allTransitiveExtensions = allTransitiveLists "moduleExtensions";
allTransitiveDirectories = allTransitiveLists "moduleDirectories";
allTransitiveImports = allTransitiveLists "moduleImports";
allTransitiveLists = attr: modSpecs:
foldDAG
{ f = modSpec:
lib.lists.foldl
# calling "unique" is not super efficient but a set-based
# approach breaks because not all values can be used as attribute
# names (in particular strings referring to a store path)
(x: y: lib.lists.unique (x ++ [y]))
[] modSpec.${attr};
empty = [];
elemLabel = modSpec: modSpec.moduleName;
reduce = a: b: a ++ b;
elemChildren = modSpec: modSpec.moduleImports;
}
modSpecs
;
# Takes a package spec and returns (modSpecs -> Fold)
modSpecFoldFromPackageSpec = pkgSpec:

View File

@ -2,5 +2,5 @@
src = ./.;
dependencies = ["file-embed"];
extra-directories =
(modName: if modName == "Main" then [ ../. ] else []);
{ Main = [../.]; };
}