diff --git a/hosts/nil.nix b/hosts/nil.nix index 7490d82..b46b4ce 100644 --- a/hosts/nil.nix +++ b/hosts/nil.nix @@ -5,11 +5,12 @@ { imports = [ - ../modules/zfs.nix ../modules/profiles/laptop.nix (modulesPath + "/installer/scan/not-detected.nix") ]; + this.systems.zfs.enable = true; + # This is required for the zfs module as well. Must be unique. Run the following head -c4 /dev/urandom | od -A none -t x4 networking.hostId = "a7a1c3f5"; networking.hostName = "nil"; # Define your hostname. diff --git a/modules/default.nix b/modules/default.nix index fef1693..1084584 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -15,6 +15,5 @@ # TODO Refactor everything after this. ./cli.nix ./fonts.nix - ./zfs.nix ]; } diff --git a/modules/system/default.nix b/modules/system/default.nix index b139094..82ec425 100644 --- a/modules/system/default.nix +++ b/modules/system/default.nix @@ -1,3 +1,3 @@ { config, pkgs, ... }: { - imports = [ ./gtk.nix ./boot.nix ./xdg.nix ./flatpak.nix ]; + imports = [ ./gtk.nix ./boot.nix ./xdg.nix ./flatpak.nix ./zfs.nix ]; } diff --git a/modules/system/zfs.nix b/modules/system/zfs.nix index 3a0aeeb..6258210 100644 --- a/modules/system/zfs.nix +++ b/modules/system/zfs.nix @@ -1,22 +1,33 @@ -{ config, pkgs, ... }: { - boot = { - supportedFilesystems = [ "zfs" ]; - zfs = { - forceImportRoot = false; - forceImportAll = false; - }; - # this was required for the initial setup of the zpool. - # see https://nixos.org/nixos/options.html#boot.zfs.forceimportroot - # kernelParams = ["zfs_force=1"]; - }; - - services.zfs = { - autoScrub.enable = true; - # enable default auto-snapshots - autoSnapshot = { - enable = true; - flags = "-k -p --utc"; +{ config, lib, pkgs, ... }: +let cfg = config.this.systems.zfs; +in with lib; { + options.this.systems.zfs = { + enable = mkOption { + default = false; + type = with types; bool; + description = "enable zfs"; }; }; + config = mkIf cfg.enable { + boot = { + supportedFilesystems = [ "zfs" ]; + zfs = { + forceImportRoot = false; + forceImportAll = false; + }; + # this was required for the initial setup of the zpool. + # see https://nixos.org/nixos/options.html#boot.zfs.forceimportroot + # kernelParams = ["zfs_force=1"]; + }; + + services.zfs = { + autoScrub.enable = true; + # enable default auto-snapshots + autoSnapshot = { + enable = true; + flags = "-k -p --utc"; + }; + }; + }; } diff --git a/modules/zfs.nix b/modules/zfs.nix deleted file mode 100644 index 3a0aeeb..0000000 --- a/modules/zfs.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ config, pkgs, ... }: { - boot = { - supportedFilesystems = [ "zfs" ]; - zfs = { - forceImportRoot = false; - forceImportAll = false; - }; - # this was required for the initial setup of the zpool. - # see https://nixos.org/nixos/options.html#boot.zfs.forceimportroot - # kernelParams = ["zfs_force=1"]; - }; - - services.zfs = { - autoScrub.enable = true; - # enable default auto-snapshots - autoSnapshot = { - enable = true; - flags = "-k -p --utc"; - }; - }; - -}