format the repo files
This commit is contained in:
@@ -16,90 +16,91 @@
|
||||
#
|
||||
# myServer.extraSystemPackages = with pkgs; [ some-tool ];
|
||||
#
|
||||
|
||||
{ config, lib, pkgs, user, ... }:
|
||||
|
||||
let
|
||||
cfg = config.myServer;
|
||||
in
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
user,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myServer;
|
||||
in {
|
||||
# ── Options ──────────────────────────────────────────────────────────────
|
||||
|
||||
options.myServer = with lib; {
|
||||
|
||||
uid = mkOption {
|
||||
type = types.int;
|
||||
default = 3000;
|
||||
type = types.int;
|
||||
default = 3000;
|
||||
description = "UID for the server user.";
|
||||
};
|
||||
|
||||
sshPort = mkOption {
|
||||
type = types.port;
|
||||
default = 2220;
|
||||
type = types.port;
|
||||
default = 2220;
|
||||
description = "Port openssh listens on.";
|
||||
};
|
||||
|
||||
sudoRequiresPassword = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether wheel users must enter a password for sudo.";
|
||||
};
|
||||
|
||||
autoUpgrade.enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enable automatic NixOS upgrades (inherits flake URL from configuration_common.nix).";
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
enable = mkEnableOption "container/VM stack (podman with docker-compat, KVM tuning)";
|
||||
cpu = mkOption {
|
||||
type = types.enum [ "amd" "intel" "none" ];
|
||||
default = "none";
|
||||
cpu = mkOption {
|
||||
type = types.enum ["amd" "intel" "none"];
|
||||
default = "none";
|
||||
description = "CPU type — selects KVM kernel parameters when virtualisation is enabled.";
|
||||
};
|
||||
};
|
||||
|
||||
extraGroups = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Additional groups for the server user beyond the defaults.";
|
||||
};
|
||||
|
||||
extraSystemPackages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
description = "Additional system packages specific to this host.";
|
||||
};
|
||||
|
||||
fail2ban = {
|
||||
enable = mkEnableOption "fail2ban intrusion prevention";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# ── Configuration ────────────────────────────────────────────────────────
|
||||
|
||||
config = lib.mkMerge [
|
||||
|
||||
# ── Base server config ────────────────────────────────────────────────
|
||||
{
|
||||
users.users.${user} = {
|
||||
isNormalUser = true;
|
||||
uid = cfg.uid;
|
||||
extraGroups = [ "wheel" "networkmanager" "kvm" "libvirtd" ] ++ cfg.extraGroups;
|
||||
uid = cfg.uid;
|
||||
extraGroups = ["wheel" "networkmanager" "kvm" "libvirtd"] ++ cfg.extraGroups;
|
||||
};
|
||||
|
||||
security.sudo.wheelNeedsPassword = cfg.sudoRequiresPassword;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
ffmpeg
|
||||
smartmontools
|
||||
htop
|
||||
] ++ cfg.extraSystemPackages;
|
||||
environment.systemPackages = with pkgs;
|
||||
[
|
||||
ffmpeg
|
||||
smartmontools
|
||||
htop
|
||||
]
|
||||
++ cfg.extraSystemPackages;
|
||||
|
||||
services.openssh = {
|
||||
ports = [ cfg.sshPort ];
|
||||
ports = [cfg.sshPort];
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
@@ -114,12 +115,12 @@ in
|
||||
# ── Virtualisation (podman/docker-compat) ─────────────────────────────
|
||||
(lib.mkIf cfg.virtualisation.enable {
|
||||
virtualisation.podman = {
|
||||
enable = true;
|
||||
enable = true;
|
||||
autoPrune.enable = true;
|
||||
dockerCompat = true;
|
||||
dockerCompat = true;
|
||||
};
|
||||
|
||||
users.groups.docker.members = [ user ];
|
||||
users.groups.docker.members = [user];
|
||||
})
|
||||
|
||||
# ── KVM – AMD ─────────────────────────────────────────────────────────
|
||||
@@ -141,11 +142,10 @@ in
|
||||
# ── Fail2ban ──────────────────────────────────────────────────────────
|
||||
(lib.mkIf cfg.fail2ban.enable {
|
||||
services.fail2ban = {
|
||||
enable = true;
|
||||
maxretry = 5;
|
||||
enable = true;
|
||||
maxretry = 5;
|
||||
jails.DEFAULT.settings.findtime = "15m";
|
||||
};
|
||||
})
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user