about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorFelix Buehler <account@buehler.rocks>2024-02-28 21:25:05 +0100
committerFelix Buehler <account@buehler.rocks>2024-04-15 20:41:44 +0200
commite9570410a1a9d0f5fea3fe06486d65acfb0f0866 (patch)
tree0c0f4da490e98ee95daca882e41ce197403e9a72 /nixos/modules
parentb607b9427a68154f71dd58cba2d7375249c7b482 (diff)
nixos/postsrsd: prefer 'install' over 'chmod/chown'
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/mail/postsrsd.nix9
1 files changed, 2 insertions, 7 deletions
diff --git a/nixos/modules/services/mail/postsrsd.nix b/nixos/modules/services/mail/postsrsd.nix
index 41301c8697d7c..fae5524bdf249 100644
--- a/nixos/modules/services/mail/postsrsd.nix
+++ b/nixos/modules/services/mail/postsrsd.nix
@@ -120,14 +120,9 @@ in {
         if [ ! -e "${cfg.secretsFile}" ]; then
           echo "WARNING: secrets file not found, autogenerating!"
           DIR="$(dirname "${cfg.secretsFile}")"
-          if [ ! -d "$DIR" ]; then
-            mkdir -p -m750 "$DIR"
-            chown "${cfg.user}:${cfg.group}" "$DIR"
-          fi
-          dd if=/dev/random bs=18 count=1 | base64 > "${cfg.secretsFile}"
-          chmod 600 "${cfg.secretsFile}"
+          install -m 750 -o ${cfg.user} -g ${cfg.group} -d "$DIR"
+          install -m 600 -o ${cfg.user} -g ${cfg.group} <(dd if=/dev/random bs=18 count=1 | base64) "${cfg.secretsFile}"
         fi
-        chown "${cfg.user}:${cfg.group}" "${cfg.secretsFile}"
       '';
     };