mirror of
https://github.com/RGBCube/ncc
synced 2025-07-29 11:07:44 +00:00
Refactor the whole codebase. Most notable changes:
- No more fail2ban. It didn't work properly anyways, I'll need to look into this in the future - No nix-super. I don't need it and the overlay is broken so I'm waiting for that to be fixed first. - Uses nh instead of nixos-rebuild. This is much better.
This commit is contained in:
parent
f145bdaa4a
commit
62c575774b
106 changed files with 1252 additions and 1367 deletions
|
@ -1,37 +0,0 @@
|
|||
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;
|
||||
|
||||
isServer = users.graphical == [];
|
||||
isDesktop = !isServer;
|
||||
|
||||
# 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 {};
|
||||
}
|
6
lib/configuration1.nix
Normal file
6
lib/configuration1.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
lib: {
|
||||
systemConfiguration = cfg: cfg;
|
||||
systemPackages = pkgs: { environment.systemPackages = pkgs; };
|
||||
systemFonts = pkgs: { fonts.packages = pkgs; };
|
||||
homeConfiguration = cfg: { home-manager.sharedModules = [ cfg ]; };
|
||||
}
|
32
lib/configuration2.nix
Normal file
32
lib/configuration2.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
lib: config: let
|
||||
userHomeConfiguration = users: cfg: {
|
||||
home-manager.users = lib.genAttrs users (_: cfg);
|
||||
};
|
||||
|
||||
allNormalUsers = [ "root" ] ++ lib.pipe config.users.users [
|
||||
(lib.filterAttrs (_: lib.getAttr "isNormalUser"))
|
||||
lib.attrNames
|
||||
];
|
||||
|
||||
desktopUsers = lib.pipe config.users.users [
|
||||
(lib.filterAttrs (_: lib.getAttr "isDesktopUser"))
|
||||
lib.attrNames
|
||||
];
|
||||
in rec {
|
||||
inherit allNormalUsers desktopUsers;
|
||||
|
||||
isDesktop = desktopUsers != [];
|
||||
isServer = desktopUsers == [];
|
||||
|
||||
desktopSystemConfiguration = cfg: lib.optionalAttrs isDesktop cfg;
|
||||
desktopSystemPackages = pkgs: desktopSystemConfiguration (lib.systemPackages pkgs);
|
||||
desktopSystemFonts = pkgs: desktopSystemConfiguration (lib.systemFonts pkgs);
|
||||
desktopUserHomeConfiguration = cfg: userHomeConfiguration desktopUsers cfg;
|
||||
desktopUserHomePackages = pkgs: desktopUserHomeConfiguration { home.packages = pkgs; };
|
||||
desktopHomeConfiguration = cfg: desktopSystemConfiguration (lib.homeConfiguration cfg);
|
||||
desktopHomePackages = pkgs: desktopHomeConfiguration { home.packages = pkgs; };
|
||||
|
||||
serverSystemConfiguration = cfg: lib.optionalAttrs isServer cfg;
|
||||
serverSystemPackages = pkgs: serverSystemConfiguration (lib.systemPackages pkgs);
|
||||
serverHomeConfiguration = cfg: serverSystemConfiguration (lib.homeConfiguration cfg);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
lib: users: let
|
||||
configuration = import ./configuration.nix users;
|
||||
merge = import ./merge.nix lib;
|
||||
ssl = import ./ssl.nix;
|
||||
values = import ./values.nix;
|
||||
in configuration // merge // ssl // values
|
11
lib/enabled.nix
Normal file
11
lib/enabled.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
lib: {
|
||||
enabled = lib.mkMerge [{
|
||||
enable = true;
|
||||
}] // {
|
||||
__functor = self: attributes: self // {
|
||||
contents = self.contents ++ [ attributes ];
|
||||
};
|
||||
};
|
||||
|
||||
disabled = { enable = false; };
|
||||
}
|
|
@ -1,13 +1,7 @@
|
|||
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 ];
|
||||
|
||||
recursiveUpdateAll = builtins.foldl' lib.recursiveUpdate {};
|
||||
lib: {
|
||||
merge = lib.mkMerge [] // {
|
||||
__functor = self: next: self // {
|
||||
contents = self.contents ++ [ next ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
10
lib/modules.nix
Normal file
10
lib/modules.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
lib: {
|
||||
mkConst = value: lib.mkOption {
|
||||
default = value;
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
mkValue = value: lib.mkOption {
|
||||
default = value;
|
||||
};
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
sslTemplate = domain: {
|
||||
forceSSL = true;
|
||||
quic = true;
|
||||
useACMEHost = domain;
|
||||
};
|
||||
}
|
|
@ -1,18 +1,19 @@
|
|||
{
|
||||
enabled = attributes: attributes // {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
lib: {
|
||||
normalUser = attributes: attributes // {
|
||||
isNormalUser = true;
|
||||
};
|
||||
|
||||
sudoUser = attributes: attributes // {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ] ++ attributes.extraGroups or [];
|
||||
};
|
||||
|
||||
desktopUser = attributes: attributes // {
|
||||
isNormalUser = true;
|
||||
isDesktopUser = true; # Defined in options/desktop.nix.
|
||||
};
|
||||
|
||||
systemUser = attributes: attributes // {
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
graphicalUser = attributes: attributes // {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "graphical" ] ++ attributes.extraGroups or [];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue