diff options
author | Emile <git@emile.space> | 2025-01-22 23:58:51 +0100 |
---|---|---|
committer | Emile <git@emile.space> | 2025-01-23 00:01:49 +0100 |
commit | c2ab96592854b7a9cf1212ee9b0e985463407e1b (patch) | |
tree | 2b31fe7fc9b41cada1be09448c40fcb7210b0097 | |
parent | 6d1ae7bd2228ff74fc1021f657053d7ccbf7c6e5 (diff) |
(lampadas): added filebrowser and wrote a module for it
-rw-r--r-- | nix/hosts/lampadas/configuration.nix | 9 | ||||
-rw-r--r-- | nix/modules/filebrowser/default.nix | 57 | ||||
-rw-r--r-- | nix/modules/x86_64-linux.nix | 1 |
3 files changed, 67 insertions, 0 deletions
diff --git a/nix/hosts/lampadas/configuration.nix b/nix/hosts/lampadas/configuration.nix index 48df5d9..1d6a103 100644 --- a/nix/hosts/lampadas/configuration.nix +++ b/nix/hosts/lampadas/configuration.nix @@ -123,6 +123,15 @@ in programs.mosh.enable = true; services = { + emile = { + filebrowser = { + enable = true; + address = "192.168.1.196"; + port = 8080; + root = "/data"; + }; + }; + # traffic metrics vnstat.enable = true; 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 ]; } |