From b768ad0ca4208e8b3588b881067c43d85246e967 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Fri, 2 Oct 2026 11:23:45 -0500 Subject: experiment with modular services; more unix domain sockets, clean up old code --- modules/services/nixos/dufs.nix | 73 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 modules/services/nixos/dufs.nix (limited to 'modules/services/nixos/dufs.nix') 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"; + }; + } -- cgit v1.3.1