mergerfs.nix 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. { config
  2. , pkgs
  3. , ...
  4. }:
  5. {
  6. environment.systemPackages = with pkgs; [
  7. mergerfs
  8. mergerfs-tools
  9. ];
  10. users.groups.storage.gid = 992;
  11. fileSystems."/mnt/storage" = {
  12. device = "/mnt/data*";
  13. options = [
  14. "category.create=mfs"
  15. "defaults"
  16. "allow_other"
  17. "use_ino"
  18. "moveonenospc=true"
  19. "minfreespace=25G"
  20. "func.getattr=newest"
  21. "func.create=ff"
  22. "fsname=storage"
  23. "gid=${toString config.users.groups.storage.gid}"
  24. ];
  25. fsType = "fuse.mergerfs";
  26. };
  27. systemd.services."chown-storage" = {
  28. description = "Ensure correct group ownership on the storage pool";
  29. wantedBy = [ "local-fs.target" ];
  30. after = [ "local-fs.target" ];
  31. script = ''
  32. ${pkgs.coreutils}/bin/chown -R :storage /mnt/data*
  33. ${pkgs.coreutils}/bin/chmod -R 0775 /mnt/data*
  34. ${pkgs.coreutils}/bin/chown -R :storage /mnt/parity*
  35. ${pkgs.coreutils}/bin/chmod -R 0775 /mnt/parity*
  36. '';
  37. serviceConfig = {
  38. Type = "oneshot";
  39. RemainAfterExit = "yes";
  40. };
  41. };
  42. }