1
0

mergerfs.nix 1.0 KB

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