Created
May 26, 2024 09:26
-
-
Save YellowOnion/fa6b4957e89bc1efd2022280aafc967c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ nixpkgs ? import <nixpkgs> {}}: | |
let | |
lib = nixpkgs.lib; | |
mkpkg = a: deps: { name = a; deps = deps;}; | |
testPkgs = { | |
a = mkpkg "a" [ "b" "c" ]; | |
b = mkpkg "b" [ "a" ]; | |
c = mkpkg "c" [ "b" ]; | |
}; | |
buildPkgList = pkgs: list: lib.foldl' (l: i: | |
l ++ (if builtins.hasAttr i pkgs | |
then (let pkg = lib.getAttr i pkgs; | |
in [ pkg ] ++ (buildPkgList pkgs (lib.subtractList list pkg.deps))) | |
else []) | |
) [] (builtins.trace list) list; | |
in | |
{ | |
inherit testPkgs buildPkgList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment