summaryrefslogtreecommitdiff
path: root/modules/secrets.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-01 00:01:46 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-25 00:04:23 +0200
commit06782a203fa0ed5ab29a03c96294f138209211da (patch)
tree8b51a7307e867e3b7cf9467efe0ebd93ff3e78b3 /modules/secrets.nix
parenta3eb56c4fc73da93d42c9298cc94aafffca0bd37 (diff)
downloadNUR-06782a203fa0ed5ab29a03c96294f138209211da.tar.gz
NUR-06782a203fa0ed5ab29a03c96294f138209211da.tar.zst
NUR-06782a203fa0ed5ab29a03c96294f138209211da.zip
Add a filesWatcher service to restart them when secrets change
Diffstat (limited to 'modules/secrets.nix')
-rw-r--r--modules/secrets.nix14
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/secrets.nix b/modules/secrets.nix
index b282e56e..808b15c5 100644
--- a/modules/secrets.nix
+++ b/modules/secrets.nix
@@ -39,11 +39,15 @@
39 if [ -f /run/keys/secrets.tar ]; then 39 if [ -f /run/keys/secrets.tar ]; then
40 if [ ! -f ${location}/currentSecrets ] || ! sha512sum -c --status "${location}/currentSecrets"; then 40 if [ ! -f ${location}/currentSecrets ] || ! sha512sum -c --status "${location}/currentSecrets"; then
41 echo "rebuilding secrets" 41 echo "rebuilding secrets"
42 rm -rf ${location} 42 TMP=$(${pkgs.coreutils}/bin/mktemp -d)
43 install -m0750 -o root -g keys -d ${location} 43 if [ -n "$TMP" ]; then
44 ${pkgs.gnutar}/bin/tar --strip-components 1 -C ${location} -xf /run/keys/secrets.tar 44 install -m0750 -o root -g keys -d $TMP
45 sha512sum /run/keys/secrets.tar > ${location}/currentSecrets 45 ${pkgs.gnutar}/bin/tar --strip-components 1 -C $TMP -xf /run/keys/secrets.tar
46 find ${location} -type d -exec chown root:keys {} \; -exec chmod o-rx {} \; 46 sha512sum /run/keys/secrets.tar > $TMP/currentSecrets
47 find $TMP -type d -exec chown root:keys {} \; -exec chmod o-rx {} \;
48 ${pkgs.rsync}/bin/rsync -O -c -av --delete $TMP/ ${location}
49 rm -rf $TMP
50 fi
47 fi 51 fi
48 fi 52 fi
49 ''; 53 '';