about summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorEmery Hemingway <ehmry@posteo.net>2024-02-08 11:41:25 +0100
committerEmery Hemingway <ehmry@posteo.net>2024-02-23 11:08:02 +0000
commit28ffcffcbf225c368500b4746864d6496703046d (patch)
treeaa2f82330da92a95098239ef68669fc2f0aaa0a9 /nixos/modules/programs
parentd843ec4e3d651e42a5d1b0d251984199bbbf149d (diff)
downloadnixlib-28ffcffcbf225c368500b4746864d6496703046d.tar
nixlib-28ffcffcbf225c368500b4746864d6496703046d.tar.gz
nixlib-28ffcffcbf225c368500b4746864d6496703046d.tar.bz2
nixlib-28ffcffcbf225c368500b4746864d6496703046d.tar.lz
nixlib-28ffcffcbf225c368500b4746864d6496703046d.tar.xz
nixlib-28ffcffcbf225c368500b4746864d6496703046d.tar.zst
nixlib-28ffcffcbf225c368500b4746864d6496703046d.zip
nixos/ccache: add options to set ownership of cache dir
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/ccache.nix17
1 files changed, 13 insertions, 4 deletions
diff --git a/nixos/modules/programs/ccache.nix b/nixos/modules/programs/ccache.nix
index 628123b0ddf0..7972b2ac4a56 100644
--- a/nixos/modules/programs/ccache.nix
+++ b/nixos/modules/programs/ccache.nix
@@ -18,17 +18,26 @@ in {
       default = [];
       example = [ "wxGTK32" "ffmpeg" "libav_all" ];
     };
+    owner = lib.mkOption {
+      type = lib.types.str;
+      default = "root";
+      description = lib.mdDoc "Owner of CCache directory";
+    };
+    group = lib.mkOption {
+      type = lib.types.str;
+      default = "nixbld";
+      description = lib.mdDoc "Group owner of CCache directory";
+    };
   };
 
   config = lib.mkMerge [
     # host configuration
     (lib.mkIf cfg.enable {
-      systemd.tmpfiles.rules = [ "d ${cfg.cacheDir} 0770 root nixbld -" ];
+      systemd.tmpfiles.rules = [ "d ${cfg.cacheDir} 0770 ${cfg.owner} ${cfg.group} -" ];
 
       # "nix-ccache --show-stats" and "nix-ccache --clear"
       security.wrappers.nix-ccache = {
-        owner = "root";
-        group = "nixbld";
+        inherit (cfg) owner group;
         setuid = false;
         setgid = true;
         source = pkgs.writeScript "nix-ccache.pl" ''
@@ -64,7 +73,7 @@ in {
                 echo "Directory '$CCACHE_DIR' does not exist"
                 echo "Please create it with:"
                 echo "  sudo mkdir -m0770 '$CCACHE_DIR'"
-                echo "  sudo chown root:nixbld '$CCACHE_DIR'"
+                echo "  sudo chown ${cfg.owner}:${cfg.group} '$CCACHE_DIR'"
                 echo "====="
                 exit 1
               fi