Skip to content
forked from divnix/digga

Commit

Permalink
suites: simplify code
Browse files Browse the repository at this point in the history
If this code had been written this way, I wouldn't have opened divnix#200 in
the first place. (perspective of a begginer nix-langer)

closes: divnix#200
  • Loading branch information
David Arnold committed Mar 18, 2021
1 parent 2961c1e commit 7cfb98c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 13 additions & 0 deletions lib/devos/mkProfileAttrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ let mkProfileAttrs =
Example:
let profiles = mkProfileAttrs ./profiles; in
assert profiles ? core.default; 0
Example folder layout:
profiles/core/default.nix
profiles/core/sub/default.nix
profiles/code/ignored-no-default-nix/
profiles/other/default.nix
Example result:
{
core = { default = "..." };
sub = { default = "..." };
other = { default = "..." };
}
**/
dir:
let
Expand Down
12 changes: 4 additions & 8 deletions suites/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ let
profiles = dev.os.mkProfileAttrs (toString ../profiles);
users = dev.os.mkProfileAttrs (toString ../users);

allProfiles =
let defaults = lib.collect (x: x ? default) profiles;
in map (x: x.default) defaults;
allProfiles = dev.os.profileMap (lib.attrVals profiles);

allUsers =
let defaults = lib.collect (x: x ? default) users;
in map (x: x.default) defaults;
allUsers = dev.os.profileMap (lib.attrVals users);


suites = with profiles; rec {
base = [ users.nixos users.root ];
base = dev.os.profileMap [ users.nixos users.root ];
};
in
lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
suites // {
inherit allProfiles allUsers;
}

0 comments on commit 7cfb98c

Please sign in to comment.