diff --git a/configuration.nix b/configuration.nix index f5b9409..3691397 100644 --- a/configuration.nix +++ b/configuration.nix @@ -20,7 +20,6 @@ ./program-tmux.nix # Hardware - ./nfs-mount.nix ./hwaccel.nix # Services @@ -31,20 +30,19 @@ ++ lib.optionals (config.vars.host_type == "nas") [ ./service-zrepl.nix ] ++ lib.optionals (config.vars.host_type == "worker") [ ./nfs-mount.nix ./keepalived.nix ]; - # Use the systemd-boot EFI boot loader and enable that sweet zfs stuff. + # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - # boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; - boot.supportedFilesystems = [ "nfs" ]; # "zfs" - boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; }; - boot.kernel.sysctl = { "net.ipv6.conf.all.forwarding" = 1; }; + + # Enable IP forwarding for NAT (used in wireguard.nix) and load specific modules. + boot.kernel.sysctl = { + "net.ipv4.ip_forward" = 1; + "net.ipv6.conf.all.forwarding" = 1; + }; boot.kernelModules = [ "rbd" "nbd" ]; - # boot.zfs.forceImportRoot = false; - # boot.zfs.extraPools = [ "SERVICE" ]; - # services.zfs.autoScrub.enable = true; - networking.hostName = config.vars.hostname; # Define your hostname. - networking.hostId = config.vars.hostid; # Define your hostID - Needs to be unique!. + networking.hostName = config.vars.hostname; + networking.hostId = config.vars.hostid; networking = { interfaces = let primaryInterface = lib.head config.vars.interfaces; @@ -63,7 +61,7 @@ networking.defaultGateway = { address = "192.168.178.1"; - interface = lib.head config.vars.interfaces; + interface = lib.head config.vars.interfaces; # Sticking with the primary interface }; networking.nameservers = [ "192.168.178.10" "9.9.9.9" ]; diff --git a/nfs-mount.nix b/nfs-mount.nix index 50693e5..2bf5bbc 100644 --- a/nfs-mount.nix +++ b/nfs-mount.nix @@ -1,4 +1,7 @@ { config, pkgs, ... }: { + + # Add ZFS and NFS support to the initramfs so it can be mounted at boot. + boot.supportedFilesystems = [ "nfs" ]; systemd.mounts = [{ type = "nfs"; @@ -15,5 +18,6 @@ TimeoutIdleSec = "600"; }; where = config.vars.nfs_mount; + }]; } diff --git a/service-zrepl.nix b/service-zrepl.nix index d285c15..b10955d 100644 --- a/service-zrepl.nix +++ b/service-zrepl.nix @@ -36,4 +36,6 @@ }; environment.systemPackages = [ pkgs.zrepl ]; + services.nfs.server.enable = true; + } diff --git a/zfs-management.nix b/zfs-management.nix new file mode 100644 index 0000000..0655b91 --- /dev/null +++ b/zfs-management.nix @@ -0,0 +1,46 @@ +{ config, pkgs, ... }: +{ + # Add ZFS and NFS support to the initramfs so it can be mounted at boot. + boot.supportedFilesystems = [ "zfs" "nfs" ]; + + # boot.zfs.enableUnstable = true; + boot.zfs.forceImportRoot = false; + # boot.zfs.extraPools = [ "DATA" ]; + services.zfs.autoScrub.enable = true; + + # Enable and configure zrepl service + environment.systemPackages = [ pkgs.zrepl ]; + services.zrepl = { + enable = true; + settings = { + global = { + logging = [{ + # use syslog instead of stdout because it makes journald happy + type = "syslog"; + format = "human"; + level = "info"; + }]; + }; + + jobs = [{ + type = "source"; + name = "pullsource"; + send = { + encrypted = true; + }; + serve = { + type = "stdinserver"; + client_identities = [ "siredward" ]; + }; + filesystems = { + "SERVICE/volumes" = true; + }; + snapshotting = { + type = "periodic"; + prefix = "SN_"; + interval = "1h"; + }; + }]; + }; + }; +} \ No newline at end of file