diff --git a/machines/kholinar/default.nix b/machines/kholinar/default.nix index 34f7a789..993976cd 100644 --- a/machines/kholinar/default.nix +++ b/machines/kholinar/default.nix @@ -20,6 +20,7 @@ }; }; zfs = { + enable = true; encrypted = true; backups = [ { diff --git a/machines/lasting-integrity/default.nix b/machines/lasting-integrity/default.nix index 3937133f..b9d94fb5 100644 --- a/machines/lasting-integrity/default.nix +++ b/machines/lasting-integrity/default.nix @@ -28,6 +28,7 @@ }; nix.enableDirenv = false; zfs = { + enable = true; backups = [ { path = "zroot/safe/data"; diff --git a/machines/urithiru/default.nix b/machines/urithiru/default.nix index af01a712..62b119cd 100644 --- a/machines/urithiru/default.nix +++ b/machines/urithiru/default.nix @@ -27,6 +27,7 @@ internalIPV4 = "192.168.0.1"; }; zfs = { + enable = true; backups = [ { path = "zroot/safe/data"; diff --git a/modules/nixos/base/nix/default.nix b/modules/nixos/base/nix/default.nix index 3087096e..a1b35a17 100644 --- a/modules/nixos/base/nix/default.nix +++ b/modules/nixos/base/nix/default.nix @@ -1,23 +1,20 @@ { config, lib, pkgs, ... }: { - config = { - chvp.base = { - emacs.extraConfig = [ - '' - ;; Nix syntax support - (use-package nix-mode - :mode "\\.nix\\'" - ) - '' - ] ++ lib.optional config.chvp.base.nix.enableDirenv '' - ;; Direnv integration in emacs. - (use-package direnv - :config (direnv-mode) + chvp.base = { + emacs.extraConfig = [ + '' + ;; Nix syntax support + (use-package nix-mode + :mode "\\.nix\\'" ) - ''; - zfs.homeLinks = (lib.optional config.chvp.base.nix.enableDirenv { path = ".local/share/direnv"; type = "cache"; }); - }; - nix.gc.dates = if config.chvp.base.nix.slowGc then "daily" else "hourly"; - programs.command-not-found.enable = false; + '' + ] ++ lib.optional config.chvp.base.nix.enableDirenv '' + ;; Direnv integration in emacs. + (use-package direnv + :config (direnv-mode) + ) + ''; }; + nix.gc.dates = if config.chvp.base.nix.slowGc then "daily" else "hourly"; + programs.command-not-found.enable = false; } diff --git a/modules/nixos/base/zfs/default.nix b/modules/nixos/base/zfs/default.nix index fdc965c7..0bb3da90 100644 --- a/modules/nixos/base/zfs/default.nix +++ b/modules/nixos/base/zfs/default.nix @@ -1,48 +1,7 @@ { config, lib, ... }: { - options.chvp.base.zfs = { - encrypted = lib.mkOption { - default = false; - example = true; - }; - systemLinks = lib.mkOption { - default = [ ]; - example = [ - { path = "/var/lib/docker"; type = "cache"; } - { path = "/var/lib/docker/volumes"; type = "data"; } - ]; - }; - homeLinks = lib.mkOption { - default = [ ]; - example = [ - { path = ".config/syncthing"; type = "data"; } - { path = ".cache/nix-index"; type = "cache"; } - ]; - }; - ensureSystemExists = lib.mkOption { - default = [ ]; - example = [ "/data/etc/ssh" ]; - }; - ensureHomeExists = lib.mkOption { - default = [ ]; - example = [ ".ssh" ]; - }; - backups = lib.mkOption { - default = [ ]; - example = [{ - path = "rpool/safe/data"; - remotePath = "zdata/recv//safe/data"; - fast = false; - location = "lasting-integrity.vanpetegem.me"; - }]; - }; - rootDataset = lib.mkOption { - example = "rpool/local/root"; - }; - }; - - config = { + config = lib.mkIf config.chvp.base.zfs.enable { chvp.dataPrefix = lib.mkDefault "/data"; chvp.cachePrefix = lib.mkDefault "/cache"; diff --git a/modules/nixos/base/zsh/default.nix b/modules/nixos/base/zsh/default.nix index 003d8052..b7182147 100644 --- a/modules/nixos/base/zsh/default.nix +++ b/modules/nixos/base/zsh/default.nix @@ -73,8 +73,6 @@ let in { chvp.base.zsh.usersToConfigure = [ "charlotte" "root" ]; - chvp.base.zfs.systemLinks = [{ path = "/root/.local/share/autojump"; type = "cache"; }]; - chvp.base.zfs.homeLinks = [{ path = ".local/share/autojump"; type = "cache"; }]; } // { home-manager.users = builtins.foldl' (a: b: a // b) { } ( builtins.map diff --git a/modules/shared/base/default.nix b/modules/shared/base/default.nix index 076fee80..d42f18c8 100644 --- a/modules/shared/base/default.nix +++ b/modules/shared/base/default.nix @@ -3,6 +3,7 @@ { imports = [ ./nix + ./zfs ./zsh ]; diff --git a/modules/shared/base/nix/default.nix b/modules/shared/base/nix/default.nix index 9987f870..4880c06f 100644 --- a/modules/shared/base/nix/default.nix +++ b/modules/shared/base/nix/default.nix @@ -36,6 +36,7 @@ in }; config = { + chvp.base.zfs.homeLinks = (lib.optional config.chvp.base.nix.enableDirenv { path = ".local/share/direnv"; type = "cache"; }); nix = { gc = { automatic = true; diff --git a/modules/shared/base/zfs/default.nix b/modules/shared/base/zfs/default.nix new file mode 100644 index 00000000..bb77e4d1 --- /dev/null +++ b/modules/shared/base/zfs/default.nix @@ -0,0 +1,49 @@ +{ config, lib, ... }: + +# Define shared options so that links configuration can live close to actual configuration +{ + options.chvp.base.zfs = { + enable = lib.mkOption { + default = false; + example = true; + }; + encrypted = lib.mkOption { + default = false; + example = true; + }; + systemLinks = lib.mkOption { + default = [ ]; + example = [ + { path = "/var/lib/docker"; type = "cache"; } + { path = "/var/lib/docker/volumes"; type = "data"; } + ]; + }; + homeLinks = lib.mkOption { + default = [ ]; + example = [ + { path = ".config/syncthing"; type = "data"; } + { path = ".cache/nix-index"; type = "cache"; } + ]; + }; + ensureSystemExists = lib.mkOption { + default = [ ]; + example = [ "/data/etc/ssh" ]; + }; + ensureHomeExists = lib.mkOption { + default = [ ]; + example = [ ".ssh" ]; + }; + backups = lib.mkOption { + default = [ ]; + example = [{ + path = "rpool/safe/data"; + remotePath = "zdata/recv//safe/data"; + fast = false; + location = "lasting-integrity.vanpetegem.me"; + }]; + }; + rootDataset = lib.mkOption { + example = "rpool/local/root"; + }; + }; +} diff --git a/modules/shared/base/zsh/default.nix b/modules/shared/base/zsh/default.nix index 787c3e95..dde00db4 100644 --- a/modules/shared/base/zsh/default.nix +++ b/modules/shared/base/zsh/default.nix @@ -65,6 +65,8 @@ in config = { programs.zsh.enable = true; + chvp.base.zfs.homeLinks = lib.mkIf (builtins.elem username config.chvp.base.zsh.usersToConfigure) [{ path = ".local/share/autojump"; type = "cache"; }]; + chvp.base.zfs.systemLinks = lib.mkIf (builtins.elem "root" config.chvp.base.zsh.usersToConfigure) [{ path = "/root/.local/share/autojump"; type = "cache"; }]; } // { home-manager.users = builtins.foldl' (a: b: a // b) { } ( builtins.map