1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-29 11:07:44 +00:00

Multi hosts, finally

This commit is contained in:
RGBCube 2024-01-02 13:41:00 +03:00
parent 084d2093bd
commit bd42073480
No known key found for this signature in database
48 changed files with 200 additions and 311 deletions

View file

@ -1,31 +1,37 @@
normalUsers: graphicalUsers:
rec {
inherit normalUsers graphicalUsers;
systemConfiguration = configuration: configuration;
systemPackages = packages: systemConfiguration {
environment.systemPackages = packages;
};
systemFonts = packages: systemConfiguration {
fonts.packages = packages;
};
lib: users: let
userHomeConfiguration = users: configuration: {
home-manager.users = builtins.foldl' (final: user: final // {
${user} = configuration;
}) {} (if builtins.isList users then users else [ users ]);
};
in rec {
inherit users;
graphicalConfiguration = userHomeConfiguration graphicalUsers;
graphicalPackages = packages: graphicalConfiguration {
home.packages = packages;
};
isServer = users.graphical == [];
isDesktop = !isServer;
homeConfiguration = userHomeConfiguration normalUsers;
homePackages = packages: homeConfiguration {
home.packages = packages;
};
# For every machine.
systemConfiguration = configuration: configuration;
systemPackages = packages: systemConfiguration { environment.systemPackages = packages; };
systemFonts = packages: systemConfiguration { fonts.packages = packages; };
# For every user, on every machine.
homeConfiguration = configuration: { home-manager.sharedModules = [ configuration ]; };
homePackages = packages: homeConfiguration { home.packages = packages; };
# For every desktop.
desktopSystemConfiguration = configuration: if isServer then {} else configuration;
desktopSystemPackages = packages: if isServer then {} else systemPackages packages;
desktopSystemFonts = packages: if isServer then {} else systemFonts packages;
# For every graphical user on every desktop.
desktopHomeConfiguration = configuration: if isServer then {} else userHomeConfiguration users.graphical configuration;
desktopHomePackages = packages: if isServer then {} else desktopHomeConfiguration { home.packages = packages; };
# For every server.
serverSystemConfiguration = configuration: if isServer then configuration else {};
serverSystemPackages = packages: if isServer then systemPackages packages else {};
serverSystemFonts = packages: if isServer then systemFonts packages else {};
# For every user on every server.
serverHomeConfiguration = configuration: if isServer then homeConfiguration configuration else {};
serverHomePackages = packages: if isServer then homePackages packages else {};
}

View file

@ -1,9 +1,5 @@
lib: normalUsers: graphicalUsers:
(import ./configuration.nix normalUsers graphicalUsers)
//
(import ./merge.nix lib)
//
(import ./modules.nix)
//
(import ./values.nix)
lib: users: let
configuration = import ./configuration.nix lib users;
merge = import ./merge.nix lib;
values = import ./values.nix;
in configuration // merge // values

View file

@ -1,8 +1,11 @@
lib:
rec {
merge = lib.recursiveUpdate;
merge3 = x: y: merge (merge x y);
merge4 = x: y: merge3 (merge x y);
merge5 = x: y: merge4 (merge x y);
lib: let
mergeAll = builtins.foldl' (collected: module: {
imports = collected.imports ++ [ module ];
}) { imports = []; };
in {
merge = a: b: mergeAll [ a b ];
merge3 = a: b: c: mergeAll [ a b c ];
merge4 = a: b: c: d: mergeAll [ a b c d ];
merge5 = a: b: c: d: e: mergeAll [ a b c d e ];
merge6 = a: b: c: d: e: f: mergeAll [ a b c d e f ];
}

View file

@ -1,8 +0,0 @@
{
importModules = modules: {
imports = builtins.map (module: if builtins.isPath module then
module
else
../modules/${module}) modules;
};
}

View file

@ -6,4 +6,9 @@
normalUser = attributes: attributes // {
isNormalUser = true;
};
graphicalUser = attributes: attributes // {
isNormalUser = true;
extraGroups = [ "graphical" ] ++ attributes.extraGroups or [];
};
}