From d3c00006eafbd8ef31366179c28c265f8ab21ce4 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 28 Dec 2024 14:50:21 +0800 Subject: [PATCH] home-manager/services/openrefine: init --- modules/home-manager/default.nix | 1 + modules/home-manager/services/openrefine.nix | 52 +++++++++++++++++++ tests/modules/home-manager/default.nix | 1 + .../services/openrefine/basic.nix | 14 +++++ .../services/openrefine/default.nix | 3 ++ 5 files changed, 71 insertions(+) create mode 100644 modules/home-manager/services/openrefine.nix create mode 100644 tests/modules/home-manager/services/openrefine/basic.nix create mode 100644 tests/modules/home-manager/services/openrefine/default.nix diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 0caffb53..33bbcade 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -14,6 +14,7 @@ ./services/gonic.nix ./services/ludusavi.nix ./services/matcha.nix + ./services/openrefine.nix ./services/plover.nix ./services/yt-dlp.nix ]; diff --git a/modules/home-manager/services/openrefine.nix b/modules/home-manager/services/openrefine.nix new file mode 100644 index 00000000..7324010f --- /dev/null +++ b/modules/home-manager/services/openrefine.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.openrefine; + + settingsFormat = pkgs.formats.ini { }; +in +{ + options.services.openrefine = { + enable = lib.mkEnableOption "OpenRefine server"; + + package = lib.mkPackageOption pkgs "openrefine" { }; + + settings = lib.mkOption { + type = settingsFormat.type; + default = { }; + example = lib.literalExpression '' + ''; + }; + + extraFlags = lib.mkOption { + type = with lib.types; listOf str; + default = [ ]; + example = lib.literalExpression '' + [ + "--port" "29345" + ] + ''; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.user.services.openrefine = { + Unit = { + Description = "OpenRefine server"; + Documentation = [ "https://openrefine.org/docs" ]; + + After = [ + "network-online.target" + "default.target" + ]; + }; + + Service = { + ExecStart = '' + ${lib.getExe' cfg.package "refine"} ${lib.concatStringsSep " " cfg.extraFlags} + ''; + Restart = "on-failure"; + }; + }; + }; +} diff --git a/tests/modules/home-manager/default.nix b/tests/modules/home-manager/default.nix index 2f3a1e5a..a2c7e7d8 100644 --- a/tests/modules/home-manager/default.nix +++ b/tests/modules/home-manager/default.nix @@ -66,6 +66,7 @@ import nmt { ./services/gonic ./services/ludusavi ./services/matcha + ./services/openrefine ./services/plover ./services/yt-dlp ]); diff --git a/tests/modules/home-manager/services/openrefine/basic.nix b/tests/modules/home-manager/services/openrefine/basic.nix new file mode 100644 index 00000000..2e28a4d4 --- /dev/null +++ b/tests/modules/home-manager/services/openrefine/basic.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: + +{ + services.openrefine = { + enable = true; + package = pkgs.openrefine; + }; + + test.stubs.openrefine = { }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/openrefine.service + ''; +} diff --git a/tests/modules/home-manager/services/openrefine/default.nix b/tests/modules/home-manager/services/openrefine/default.nix new file mode 100644 index 00000000..e04989e7 --- /dev/null +++ b/tests/modules/home-manager/services/openrefine/default.nix @@ -0,0 +1,3 @@ +{ + openrefine-basic = ./basic.nix; +}