Skip to content

Instantly share code, notes, and snippets.

@YellowOnion
Created May 26, 2024 09:26
Show Gist options
  • Save YellowOnion/fa6b4957e89bc1efd2022280aafc967c to your computer and use it in GitHub Desktop.
Save YellowOnion/fa6b4957e89bc1efd2022280aafc967c to your computer and use it in GitHub Desktop.
{ 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