chore: refactor system modules
This commit is contained in:
9
system/services/default.nix
Normal file
9
system/services/default.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
imports = [
|
||||
./endlessh.nix
|
||||
./fwupd.nix
|
||||
./printing.nix
|
||||
./ssh.nix
|
||||
./sunshine.nix
|
||||
];
|
||||
}
|
||||
21
system/services/endlessh.nix
Normal file
21
system/services/endlessh.nix
Normal 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
13
system/services/fwupd.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
13
system/services/printing.nix
Normal file
13
system/services/printing.nix
Normal 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
30
system/services/ssh.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
||||
20
system/services/sunshine.nix
Normal file
20
system/services/sunshine.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user