diff options
Diffstat (limited to 'nix/modules/filebrowser')
-rw-r--r-- | nix/modules/filebrowser/default.nix | 57 |
1 files changed, 57 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} + ''; + }; + }; +} |