move suites implementation logic to lib as mkSuites

This commit is contained in:
Pacman99 2021-03-20 09:36:14 -07:00
parent 8ab865a853
commit 7ebd6b5730
3 changed files with 30 additions and 29 deletions

View file

@ -11,6 +11,8 @@
mkNodes = dev.callLibs ./mkNodes.nix;
mkSuites = dev.callLibs ./mkSuites.nix;
mkProfileAttrs = dev.callLibs ./mkProfileAttrs.nix;
mkPkgs = dev.callLibs ./mkPkgs.nix;

24
lib/devos/mkSuites.nix Normal file
View file

@ -0,0 +1,24 @@
{ lib, dev, ... }:
{ users, profiles, userProfiles, suites } @ args:
let
inherit (dev) os;
definedSuites = suites {
inherit (args) users profiles userProfiles;
};
allProfiles =
let defaults = lib.collect (x: x ? default) profiles;
in map (x: x.default) defaults;
allUsers =
let defaults = lib.collect (x: x ? default) users;
in map (x: x.default) defaults;
createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // {
inherit allProfiles allUsers;
};
in
lib.mapAttrs createSuites definedSuites

View file

@ -1,35 +1,10 @@
{ lib }:
let
inherit (lib) dev;
{ users, profiles, userProfiles, ... }:
profiles = dev.os.mkProfileAttrs (toString ../profiles);
userProfiles = dev.os.mkProfileAttrs (toString ../users/profiles);
users = dev.os.mkProfileAttrs (toString ../users);
allProfiles =
let defaults = lib.collect (x: x ? default) profiles;
in map (x: x.default) defaults;
allUsers =
let defaults = lib.collect (x: x ? default) users;
in map (x: x.default) defaults;
suites = with profiles; rec {
{
system = with profiles; rec {
base = [ users.nixos users.root ];
};
# available as 'suites' within the home-manager configuration
userSuites = with userProfiles; rec {
user = with userProfiles; rec {
base = [ direnv git ];
};
in
{
system = lib.mapAttrs (_: v: dev.os.profileMap v) suites // {
inherit allProfiles allUsers;
};
user = lib.mapAttrs (_: v: dev.os.profileMap v) userSuites // {
allProfiles = userProfiles;
};
}