about summary refs log tree commit diff
path: root/nix/modules
diff options
context:
space:
mode:
authorEmile <git@emile.space>2025-01-22 23:58:51 +0100
committerEmile <git@emile.space>2025-01-23 00:01:49 +0100
commitc2ab96592854b7a9cf1212ee9b0e985463407e1b (patch)
tree2b31fe7fc9b41cada1be09448c40fcb7210b0097 /nix/modules
parent6d1ae7bd2228ff74fc1021f657053d7ccbf7c6e5 (diff)
(lampadas): added filebrowser and wrote a module for it
Diffstat (limited to 'nix/modules')
-rw-r--r--nix/modules/filebrowser/default.nix57
-rw-r--r--nix/modules/x86_64-linux.nix1
2 files changed, 58 insertions, 0 deletions
diff --git a/nix/modules/filebrowser/default.nix b/nix/modules/filebrowser/default.nix
new file mode 100644
index 0000000..d78eafe
--- /dev/null
+++ b/nix/modules/filebrowser/default.nix
@@ -0,0 +1,57 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}:
+
+let
+  cfg = config.services.emile.filebrowser;
+in
+with lib;
+{
+  options.services.emile.filebrowser = {
+    enable = mkEnableOption "Enable filebrowser";
+
+    # ip and port to listen on
+    address = mkOption {
+      type = types.str;
+      default = "127.0.0.1";
+      example = "0.0.0.0";
+      description = "The address the service listens on";
+    };
+
+    port = mkOption {
+      type = types.int;
+      default = 8080;
+      example = 8080;
+      description = "The port the service listens on";
+    };
+
+    root = mkOption {
+      type = types.str;
+      default = null;
+      example = "/data";
+      description = "The directory to serve";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.filebrowser = {
+      wantedBy = [ "multi-user.target" ];
+      serviceConfig = {
+        RestartSec = 5;
+        Restart = "always";
+      };
+      path = [ pkgs.filebrowser pkgs.getent ];
+
+      # don't want the filebrowser.db to appear in the root? change it here (after --database)
+      serviceConfig.ExecStart = ''${pkgs.filebrowser}/bin/filebrowser \
+        -a ${cfg.address} \
+        -p ${toString cfg.port} \
+        --database ${cfg.root}/filebrowser.db \
+        -r ${cfg.root}
+      '';
+    };
+  };
+}
diff --git a/nix/modules/x86_64-linux.nix b/nix/modules/x86_64-linux.nix
index 8737083..b913c68 100644
--- a/nix/modules/x86_64-linux.nix
+++ b/nix/modules/x86_64-linux.nix
@@ -3,5 +3,6 @@
     ./ports
     ./r2wars-web
     ./remarvin
+    ./filebrowser
   ];
 }