summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/permown.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-09-16 21:55:09 +0200
committermakefu <github@syntax-fehler.de>2020-09-16 21:55:09 +0200
commitc64fb07027b49a3825b6f0814ebeb17782b8266a (patch)
treee1b4681fd93a4d3257b556dd8d579464d653ef77 /krebs/3modules/permown.nix
parent1394ae1bd4bc3dcfb77b0daee996e75f8092fc5b (diff)
parent88a9183d1d36424977b0cd8ed513109433b779b2 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'krebs/3modules/permown.nix')
-rw-r--r--krebs/3modules/permown.nix20
1 files changed, 17 insertions, 3 deletions
diff --git a/krebs/3modules/permown.nix b/krebs/3modules/permown.nix
index fe293810c..ca81e2ea5 100644
--- a/krebs/3modules/permown.nix
+++ b/krebs/3modules/permown.nix
@@ -18,6 +18,15 @@ with import <stockholm/lib>;
default = null;
type = types.nullOr types.groupname;
};
+ keepGoing = mkOption {
+ default = false;
+ type = types.bool;
+ description = ''
+ Whether to keep going when chowning or chmodding fails.
+ If set to false, then errors will cause the service to restart
+ instead.
+ '';
+ };
owner = mkOption {
type = types.username;
};
@@ -43,7 +52,12 @@ with import <stockholm/lib>;
'';
in concatMapStrings mkdir plans;
- systemd.services = genAttrs' plans (plan: {
+ systemd.services = genAttrs' plans (plan: let
+ continuable = command:
+ if plan.keepGoing
+ then /* sh */ "{ ${command}; } || :"
+ else command;
+ in {
name = "permown.${replaceStrings ["/"] ["_"] plan.path}";
value = {
environment = {
@@ -82,9 +96,9 @@ with import <stockholm/lib>;
cleanup
exec "$0" "$@"
fi
- chown -h "$OWNER_GROUP" "$path"
+ ${continuable /* sh */ ''chown -h "$OWNER_GROUP" "$path"''}
if test -f "$path"; then
- chmod "$FILE_MODE" "$path"
+ ${continuable /* sh */ ''chmod "$FILE_MODE" "$path"''}
fi
done < "$paths"
'';