From 977c55de24046386e907bbbccd8d1f88e7286d5c Mon Sep 17 00:00:00 2001 From: MayNiklas Date: Wed, 20 Aug 2025 22:39:14 +0200 Subject: [PATCH 1/2] spoolman: init service --- .../manual/release-notes/rl-2511.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/spoolman.nix | 75 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 nixos/modules/services/misc/spoolman.nix diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index b13dac4e5e6e..dc876c5274cb 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -94,6 +94,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). + ## Backward Incompatibilities {#sec-release-25.11-incompatibilities} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8713082efb4c..bf74048af1ef 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..3421a66d4123 --- /dev/null +++ b/nixos/modules/services/misc/spoolman.nix @@ -0,0 +1,75 @@ +{ + 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 = { }; + description = '' + Environment variables to be passed to the spoolman service. + ''; + }; + + 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 ]; + }; +} From a949c93c68caa9b1cf424b9de79772a90d027b97 Mon Sep 17 00:00:00 2001 From: MayNiklas Date: Mon, 1 Sep 2025 22:19:40 +0200 Subject: [PATCH 2/2] spoolman: add doc for env variables --- nixos/modules/services/misc/spoolman.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/services/misc/spoolman.nix b/nixos/modules/services/misc/spoolman.nix index 3421a66d4123..6c115c8ca815 100644 --- a/nixos/modules/services/misc/spoolman.nix +++ b/nixos/modules/services/misc/spoolman.nix @@ -16,8 +16,17 @@ in 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. ''; };