diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-24 14:52:36 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-24 14:52:57 +0200 |
commit | 33b704060e74e970313a1d64f6112588fca2332c (patch) | |
tree | e18665498100f3f9db0aa13b4c0bd2ffad87d767 /modules/by-name/un/unison/module.nix | |
parent | build(build.sh): Fail, when the build fails (diff) | |
download | nixos-config-33b704060e74e970313a1d64f6112588fca2332c.tar.gz nixos-config-33b704060e74e970313a1d64f6112588fca2332c.zip |
refactor(modules/unison): Migrate to `by-name` and parameterize
Diffstat (limited to 'modules/by-name/un/unison/module.nix')
-rw-r--r-- | modules/by-name/un/unison/module.nix | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/modules/by-name/un/unison/module.nix b/modules/by-name/un/unison/module.nix new file mode 100644 index 00000000..baf92b02 --- /dev/null +++ b/modules/by-name/un/unison/module.nix @@ -0,0 +1,92 @@ +{ + lib, + config, + pkgs, + sysLib, + ... +}: let + cfg = config.soispha.services.unison; + + script = import ./shellScript.nix {inherit sysLib lib pkgs cfg;}; +in { + options.soispha.services.unison = let + homePath = lib.types.strMatching "^~.*"; + in { + enable = lib.mkEnableOption "a unison home sync script"; + + dataDir = lib.mkOption { + type = lib.types.path; + description = '' + This directory is used by unison to store it's data. + ''; + }; + + foreign = { + address = lib.mkOption { + type = lib.types.str; + description = '' + The address to contact via ssh, when syncing. + ''; + }; + userName = lib.mkOption { + type = lib.types.str; + description = '' + The user name to try to login with at the foreign host. + ''; + }; + }; + + userSourceDir = lib.mkOption { + description = '' + The directory to replace the `~` in the relative user paths with. + If using `impermanence`, this should be the path to the persistent home directory. + ''; + }; + + pathsToIgnore = lib.mkOption { + type = lib.types.listOf homePath; + default = []; + description = '' + A list of the paths that should not be synced. + Beware that this applies not only to this path, but also to all paths under it. + ''; + }; + pathsToSync = lib.mkOption { + type = lib.types.listOf homePath; + default = []; + description = '' + A list of the paths that should be synced. + Beware that this applies not only to this path, but also to all paths under it. + ''; + }; + + unisonOptions = lib.mkOption { + internal = true; + default = { + sshcmd = "ssh"; + ui = "text"; + auto = "true"; + # This is a trap, thanks to the HM links + # TODO: Auto-ignore all `home.file` paths <2024-10-24> + links = "false"; + + backupdir = "${cfg.dataDir}/backups"; + backuploc = "central"; + }; + type = lib.types.attrsOf lib.types.str; + description = "The options passed to every unison call."; + }; + }; + + config = lib.mkIf cfg.enable { + home-manager.users.soispha = { + home.sessionVariables = { + UNISON = cfg.dataDir; + }; + home.packages = [ + pkgs.unison + script + ]; + }; + }; +} |