diff options
Diffstat (limited to 'system/worldWritableDirs.nix')
-rw-r--r-- | system/worldWritableDirs.nix | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/system/worldWritableDirs.nix b/system/worldWritableDirs.nix new file mode 100644 index 0000000..9899696 --- /dev/null +++ b/system/worldWritableDirs.nix @@ -0,0 +1,25 @@ +{ config, pkgs, lib, ... }: +let + dirs = config.nixsap.system.worldWritableDirs; + +in { + options.nixsap.system.worldWritableDirs = lib.mkOption { + type = lib.types.listOf lib.types.path; + description = "These dirs will be chmod'ed 1777"; + default = [ "/tmp" "/var/tmp" ]; + }; + + config = lib.mkIf (dirs != []) { + systemd.services.chmod1777 = { + description = "Make some dirs world-writable"; + unitConfig.RequiresMountsFor = dirs; + before = [ "local-fs.target" ]; + wantedBy = [ "local-fs.target" ]; + serviceConfig = { + ExecStart = "${pkgs.coreutils}/bin/chmod -c 1777 ${lib.concatStringsSep " " dirs}"; + Type = "oneshot"; + RemainAfterExit = true; + }; + }; + }; +} |