diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index da007f063797..a155ca4340e4 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -102,6 +102,8 @@ - [KMinion](https://github.com/redpanda-data/kminion), feature-rich Prometheus exporter for Apache Kafka. Available as [services.prometheus.exporters.kafka](options.html#opt-services.prometheus.exporters.kafka). +- [Spoolman](https://github.com/Donkie/Spoolman), a inventory management system for Filament spools. Available as [services.spoolman](#opt-services.spoolman.enable). + - [Temporal](https://temporal.io/), a durable execution platform that enables developers to build scalable applications without sacrificing productivity or reliability. Available as [services.temporal](#opt-services.temporal.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index ebc7a65058b3..3931662eaff8 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -930,6 +930,7 @@ ./services/misc/spice-autorandr.nix ./services/misc/spice-vdagentd.nix ./services/misc/spice-webdavd.nix + ./services/misc/spoolman.nix ./services/misc/sssd.nix ./services/misc/subsonic.nix ./services/misc/sundtek.nix diff --git a/nixos/modules/services/misc/spoolman.nix b/nixos/modules/services/misc/spoolman.nix new file mode 100644 index 000000000000..6c115c8ca815 --- /dev/null +++ b/nixos/modules/services/misc/spoolman.nix @@ -0,0 +1,84 @@ +{ + lib, + pkgs, + config, + ... +}: +let + cfg = config.services.spoolman; +in +{ + + options.services.spoolman = { + + enable = lib.mkEnableOption "Spoolman, a filament spool inventory management system."; + + environment = lib.mkOption { + type = lib.types.attrs; + default = { }; + example = { + SPOOLMAN_DB_TYPE = "sqlite"; + SPOOLMAN_LOGGING_LEVEL = "DEBUG"; + SPOOLMAN_AUTOMATIC_BACKUP = "TRUE"; + SPOOLMAN_BASE_PATH = "/spoolman"; + SPOOLMAN_METRICS_ENABLED = "TRUE"; + SPOOLMAN_CORS_ORIGIN = "source1.domain.com:p1, source2.domain.com:p2"; + }; + description = '' + Environment variables to be passed to the spoolman service. + Refer to https://github.com/Donkie/Spoolman/blob/master/.env.example for details on supported variables. + ''; + }; + + openFirewall = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Open the appropriate ports in the firewall for spoolman. + ''; + }; + + listen = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + example = "0.0.0.0"; + description = "The IP address to bind the spoolman server to."; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 7912; + description = '' + TCP port where spoolman web-gui listens. + ''; + }; + + }; + + config = lib.mkIf cfg.enable { + + systemd.services.spoolman = { + description = "A self-hosted filament spool inventory management system"; + wantedBy = [ "multi-user.target" ]; + environment = { + SPOOLMAN_DIR_DATA = "/var/lib/spoolman"; + } + // cfg.environment; + serviceConfig = lib.mkMerge [ + { + DynamicUser = true; + ExecStart = "${pkgs.spoolman}/bin/spoolman --host ${cfg.listen} --port ${toString cfg.port}"; + StateDirectory = "spoolman"; + } + ]; + }; + + networking.firewall = lib.mkIf cfg.openFirewall { + allowedTCPPorts = lib.optional (cfg.listen != "127.0.0.1") cfg.port; + }; + + }; + meta = { + maintainers = with lib.maintainers; [ MayNiklas ]; + }; +}