chore: refactor system modules

This commit is contained in:
2025-07-05 00:02:39 +02:00
parent d054442c28
commit af1a606c1a
56 changed files with 549 additions and 475 deletions

View File

@@ -0,0 +1,9 @@
{
imports = [
./endlessh.nix
./fwupd.nix
./printing.nix
./ssh.nix
./sunshine.nix
];
}

View File

@@ -0,0 +1,21 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.system.services.endlessh;
in {
options.system.services.endlessh = {
enable = mkEnableOption "Enables endlessh.";
port = mkOption {
type = types.port;
default = 2222;
example = 22;
};
};
config.services.endlessh-go = mkIf cfg.enable {
inherit (cfg) enable port;
openFirewall = true;
};
}

13
system/services/fwupd.nix Normal file
View File

@@ -0,0 +1,13 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.system.services.fwupd;
in {
options.system.services.fwupd.enable = mkEnableOption "Enable fwupd";
config.services.fwupd = mkIf cfg.enable {
inherit (cfg) enable;
};
}

View File

@@ -0,0 +1,13 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.system.services.printing;
in {
options.system.services.printing.enable = mkEnableOption "Enable printing with CUPS";
config.services.printing = mkIf cfg.enable {
inherit (cfg) enable;
};
}

30
system/services/ssh.nix Normal file
View File

@@ -0,0 +1,30 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.system.services.ssh;
in {
options.system.services.ssh = {
enable = mkEnableOption "Enables OpenSSH";
allowedUsers = mkOption {
type = types.listOf types.str;
example = ["alice" "bob"];
default = ["phundrak"];
};
passwordAuthentication = mkOption {
type = types.bool;
example = true;
default = false;
};
};
config.services.openssh = mkIf cfg.enable {
inherit (cfg) enable;
settings = {
AllowUsers = cfg.allowedUsers;
PermitRootLogin = "no";
PasswordAuthentication = cfg.passwordAuthentication;
};
};
}

View File

@@ -0,0 +1,20 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.system.services.sunshine;
in {
options.system.services.sunshine = {
enable = mkEnableOption "Enables Sunshine";
autostart = mkEnableOption "Enables autostart";
};
config.services.sunshine = mkIf cfg.enable {
inherit (cfg) enable;
autoStart = cfg.autostart;
capSysAdmin = true;
openFirewall = true;
settings.sunshine_name = config.system.networking.hostname;
};
}