From 8b32673bfe141d35f875ac4e36b9b03ade2001ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Fri, 21 Jan 2022 18:06:18 +0100 Subject: [PATCH] automatically upload the nix store to the cache --- config/default.nix | 1 + config/services/nix-cache-upload.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 config/services/nix-cache-upload.nix diff --git a/config/default.nix b/config/default.nix index b0c57456..141780e7 100644 --- a/config/default.nix +++ b/config/default.nix @@ -8,6 +8,7 @@ ./services/loki.nix ./home.nix ./services/restic.nix + ./services/nix-cache-upload.nix ]; services.openssh.enable = true; environment.systemPackages = [ pkgs.git ]; diff --git a/config/services/nix-cache-upload.nix b/config/services/nix-cache-upload.nix new file mode 100644 index 00000000..fe401dcc --- /dev/null +++ b/config/services/nix-cache-upload.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +let +in +{ + systemd.services.copy-to-cache = { + enable = true; + description = "Copy nix cache to cache.int.chir.rs"; + script = '' + #!${pkgs.bash}/bin/bash + ${pkgs.nix}/bin/nix copy --to 's3://cache.int.chir.rs?scheme=https&endpoint=minio.int.chir.rs' --all + ''; + unitConfig = { + user = "darkkirb"; + group = "users"; + }; + }; + systemd.timers.copy-to-cache = { + enable = true; + description = "Copy nix cache to cache.int.chir.rs"; + requires = [ "copy-to-cache.service" ]; + wantedBy = [ "multi-user.target" ]; + timerConfig = { + onUnitActiveSec = 3600; + onBootSec = 3600; + }; + }; +}