diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index bd8af46..a44c744 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -16,6 +16,8 @@ # ../../modules/nix/enable-ip-forwarding.nix ../../modules/beszel/enable-agent.nix ../../modules/services/enable-rpcbind.nix + ../../modules/services/zfs/enable-service.nix + ../../modules/services/zfs/auto-mount-volumes.nix ]; @@ -23,9 +25,9 @@ networking.hostId = "6689f93e"; # Pick only one of the below networking options. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - boot.supportedFilesystems = [ "zfs" ]; - boot.zfs.forceImportRoot = false; - boot.zfs.package = pkgs.zfs_unstable; + # boot.supportedFilesystems = [ "zfs" ]; + # boot.zfs.forceImportRoot = false; + # boot.zfs.package = pkgs.zfs_unstable; services.beszel.agent.environment = { #DOCKER_HOST = "tcp://docker-socket-proxy:2375"; @@ -41,23 +43,23 @@ TOKEN = "48e71783-35df-4ea0-a8c2-05bc5e020d2e"; #system.userActivationScripts.createSetupSymlink.text = '' # ln -sf /mnt/docker-persistent-data/setup /home/nixos/setup #''; -boot.postBootCommands = '' - echo "=== STARTING ZPOOL IMPORT ===" - ${pkgs.zfs_unstable}/bin/zpool import -a -N -d /dev/disk/by-path - ${pkgs.zfs_unstable}/bin/zpool status - ${pkgs.zfs_unstable}/bin/zfs mount -a - ${pkgs.zfs_unstable}/bin/zfs list - echo "=== ZPOOL IMPORT COMPLETE ===" -''; - services.zfs = { - autoScrub.enable = true; - autoSnapshot.enable = true; - trim.enable = true; - }; +# boot.postBootCommands = '' +# echo "=== STARTING ZPOOL IMPORT ===" +# ${pkgs.zfs_unstable}/bin/zpool import -a -N -d /dev/disk/by-path +# ${pkgs.zfs_unstable}/bin/zpool status +# ${pkgs.zfs_unstable}/bin/zfs mount -a +# ${pkgs.zfs_unstable}/bin/zfs list +# echo "=== ZPOOL IMPORT COMPLETE ===" +# ''; +# services.zfs = { +# autoScrub.enable = true; +# autoSnapshot.enable = true; +# trim.enable = true; +# }; -systemd.services.zfs-import-cache.enable = true; -systemd.services.zfs-mount.enable = true; -boot.zfs.devNodes = "/dev/disk/by-id"; +# systemd.services.zfs-import-cache.enable = true; +# systemd.services.zfs-mount.enable = true; +# boot.zfs.devNodes = "/dev/disk/by-id"; systemd.services.nfs-server = { after = [ "zfs-mount.service" ]; diff --git a/modules/services/zfs/auto-mount-volumes.nix b/modules/services/zfs/auto-mount-volumes.nix new file mode 100644 index 0000000..4de81d4 --- /dev/null +++ b/modules/services/zfs/auto-mount-volumes.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +{ +boot.postBootCommands = '' + echo "=== STARTING ZPOOL IMPORT ===" + ${pkgs.zfs_unstable}/bin/zpool import -a -N -d /dev/disk/by-path + ${pkgs.zfs_unstable}/bin/zpool status + ${pkgs.zfs_unstable}/bin/zfs mount -a + ${pkgs.zfs_unstable}/bin/zfs list + echo "=== ZPOOL IMPORT COMPLETE ===" +''; + } \ No newline at end of file diff --git a/modules/services/zfs/enable-service.nix b/modules/services/zfs/enable-service.nix new file mode 100644 index 0000000..cbb0e20 --- /dev/null +++ b/modules/services/zfs/enable-service.nix @@ -0,0 +1,16 @@ +{ ... }: + + { +boot.supportedFilesystems = [ "zfs" ]; + boot.zfs.forceImportRoot = false; + boot.zfs.package = pkgs.zfs_unstable; + services.zfs = { + autoScrub.enable = true; + autoSnapshot.enable = true; + trim.enable = true; + }; + +systemd.services.zfs-import-cache.enable = true; +systemd.services.zfs-mount.enable = true; +boot.zfs.devNodes = "/dev/disk/by-id"; + } \ No newline at end of file