소스 검색

feat(odin): storage mount permissions

Zander Hawke 9 달 전
부모
커밋
3f9a03499e
1개의 변경된 파일26개의 추가작업 그리고 4개의 파일을 삭제
  1. 26 4
      hosts/odin/mergerfs.nix

+ 26 - 4
hosts/odin/mergerfs.nix

@@ -1,10 +1,15 @@
-{ pkgs, ... }:
+{ config
+, pkgs
+, ...
+}:
 {
   environment.systemPackages = with pkgs; [
     mergerfs
     mergerfs-tools
   ];
 
+  users.groups.storage.gid = 992;
+
   fileSystems."/mnt/storage" = {
     device = "/mnt/data*";
     options = [
@@ -16,10 +21,27 @@
       "minfreespace=25G"
       "func.getattr=newest"
       "fsname=storage"
-      "uid=1000"
-      "gid=1000"
-      "umask=002"
+      "gid=${toString config.users.groups.storage.gid}"
     ];
     fsType = "fuse.mergerfs";
   };
+
+  systemd.services."chown-storage" = {
+    description = "Ensure correct group ownership on the storage pool";
+
+    wantedBy = [ "local-fs.target" ];
+    after = [ "local-fs.target" ];
+
+    script = ''
+      ${pkgs.coreutils}/bin/chown -R :storage /mnt/data*
+      ${pkgs.coreutils}/bin/chmod -R 0775 /mnt/data*
+      ${pkgs.coreutils}/bin/chown -R :storage /mnt/parity*
+      ${pkgs.coreutils}/bin/chmod -R 0775 /mnt/parity*
+    '';
+
+    serviceConfig = {
+      Type = "oneshot";
+      RemainAfterExit = "yes";
+    };
+  };
 }