aboutsummaryrefslogtreecommitdiff
path: root/modules/services/nixos/dufs.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/services/nixos/dufs.nix')
-rw-r--r--modules/services/nixos/dufs.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/modules/services/nixos/dufs.nix b/modules/services/nixos/dufs.nix
new file mode 100644
index 0000000..966d973
--- /dev/null
+++ b/modules/services/nixos/dufs.nix
@@ -0,0 +1,73 @@
+{
+ lib,
+ pkgs,
+ config,
+ ...
+}: let
+ cfg = config.collinux.services.dufs;
+
+ modularService = {
+ lib,
+ config,
+ options,
+ ...
+ }: let
+ cfg = config.dufs;
+ in {
+ options.dufs = {
+ package = lib.mkOption {
+ description = "the `dufs` package";
+ type = lib.types.package;
+ };
+ dir = lib.mkOption {
+ description = "root directory of the fileserver";
+ type = lib.types.str;
+ };
+ };
+ config =
+ {process.argv = [(lib.getExe cfg.package) cfg.dir "--bind" "/run/dufs/dufs.sock"];}
+ // lib.optionalAttrs (options ? systemd) {
+ systemd.service = {
+ wants = ["network-online.target"];
+ after = ["network-online.target"];
+ wantedBy = ["multi-user.target"];
+
+ serviceConfig = {
+ DynamicUser = true;
+ Group = "caddy";
+ SupplementaryGroups = "fileserver";
+
+ RuntimeDirectory = "dufs";
+ RuntimeDirectoryMode = "0750";
+ UMask = "0002";
+
+ ProtectSystem = "strict";
+ ProtectHome = true;
+ PrivateTmp = true;
+ NoNewPrivileges = true;
+ };
+ };
+ };
+ };
+in
+ lib.mkIf cfg.enable {
+ users.groups."fileserver" = {};
+
+ system.services."dufs" = {
+ imports = [modularService];
+ dufs = {
+ package = pkgs.dufs;
+ dir = "/media";
+ };
+ };
+
+ services.caddy.virtualHosts."files.ganymede".extraConfig = ''
+ tls internal
+ reverse_proxy unix//run/dufs/dufs.sock
+ '';
+
+ collinux.services.glance.homelabServices."files" = {
+ url = "https://files.ganymede";
+ icon = "mdi:folder";
+ };
+ }