From fb70bd789e333d2f616971e3acdc6745180298c4 Mon Sep 17 00:00:00 2001 From: Henri Dohmen Date: Sat, 31 May 2025 00:20:26 +0200 Subject: [PATCH] structure, unison --- mod/default.nix | 8 +++++++- mod/hm/default.nix | 6 ++++++ mod/hm/unison.nix | 28 ++++++++++++++++++++++++++++ pc/sync.nix | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 mod/hm/default.nix create mode 100644 mod/hm/unison.nix diff --git a/mod/default.nix b/mod/default.nix index c915eb0..6f66a62 100644 --- a/mod/default.nix +++ b/mod/default.nix @@ -1 +1,7 @@ -{ ... }: { } +{ ... }: +{ + imports = [ ]; + home = { + imports = [ ./hm ]; + }; +} diff --git a/mod/hm/default.nix b/mod/hm/default.nix new file mode 100644 index 0000000..c9a0102 --- /dev/null +++ b/mod/hm/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./unison.nix + ]; +} diff --git a/mod/hm/unison.nix b/mod/hm/unison.nix new file mode 100644 index 0000000..2166b61 --- /dev/null +++ b/mod/hm/unison.nix @@ -0,0 +1,28 @@ +{ lib, config, ... }: +let + cfg = config.services.unison'; +in +{ + options.services.unison' = { + enable = lib.mkEnableOption "Unison file synchronizer"; + pairs = lib.mkOption { + type = lib.types.attrsOf (lib.types.attrsOf (lib.types.listOf lib.types.str)); + default = { }; + description = ""; + }; + }; + + config = lib.mkIf cfg.enable { + home.file = lib.mapAttrs' (name: roots: { + name = ".unison/${name}.prf"; + value.text = + '' + watch = true + logfile = /dev/null + confirmbigdeletes = true + confirmmerge = true + '' + + lib.concatStringsSep "\n" (map (root: "root = ${root}") roots.roots); + }) cfg.pairs; + }; +} diff --git a/pc/sync.nix b/pc/sync.nix index 4e93e05..336fc6d 100644 --- a/pc/sync.nix +++ b/pc/sync.nix @@ -1,6 +1,6 @@ { pkgs, ... }: { - home.services.unison = { + home.services.unison' = { enable = true; pairs = { "docs".roots = [