From 0cd03bfeaf49c865068d5a064d73bb3019af4cc6 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Thu, 18 Apr 2024 23:01:01 +0200 Subject: [PATCH] Add attic-client module --- modules/default.nix | 1 + modules/services/attic-client/default.nix | 39 +++++++++++++++++++++++ systems/gwyn/default.nix | 1 + 3 files changed, 41 insertions(+) create mode 100644 modules/services/attic-client/default.nix diff --git a/modules/default.nix b/modules/default.nix index 609892f..5278cea 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -21,6 +21,7 @@ ./programs/restic-management ./programs/scripts ./programs/steam + ./services/attic-client ./services/attic-server ./services/common-x86 ./services/data-share diff --git a/modules/services/attic-client/default.nix b/modules/services/attic-client/default.nix new file mode 100644 index 0000000..d0bd317 --- /dev/null +++ b/modules/services/attic-client/default.nix @@ -0,0 +1,39 @@ +{ + config, + inputs, + lib, + pkgs, + ... +}: +let + system = pkgs.system; + cfg = config.services.az-attic-client; + atticWatcher = pkgs.writeShellScript "attic-watcher" '' + ${inputs.attic.packages.${system}.attic-client}/bin/attic watch-store prod + ''; +in +{ + options = { + services.az-attic-client = { + enable = lib.mkEnableOption "Enable a service to watch the nix store and upload new paths to attic"; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ inputs.attic.packages.${system}.attic-client ]; + # sytemd service + systemd.services.az-attic-client = { + description = "Watch the nix store and upload new paths to attic"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${atticWatcher}"; + Restart = "always"; + RestartSec = "5"; + User = config.az-username; + Group = "users"; + }; + }; + }; +} diff --git a/systems/gwyn/default.nix b/systems/gwyn/default.nix index 8da9ccb..d8223ae 100644 --- a/systems/gwyn/default.nix +++ b/systems/gwyn/default.nix @@ -81,6 +81,7 @@ }; services = { + az-attic-client.enable = true; az-logs-share.enable = true; az-restic-client-desktop.enable = true; az-tlp.enable = true;