From 6852dc2359784c34941270d3f9532b0d7cfcd225 Mon Sep 17 00:00:00 2001 From: nikstur Date: Mon, 15 May 2023 14:06:26 +0200 Subject: [PATCH 1/2] nixos/rshim: fix shell escape Using escapeShellArg does not make sense here because (a) it turned the list into a string, so the entire service failed and (b) because systemd does not use the same escaping mechanism as bash. --- nixos/modules/services/misc/rshim.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/misc/rshim.nix b/nixos/modules/services/misc/rshim.nix index 169f1fa5793b..0fef2cc228c9 100644 --- a/nixos/modules/services/misc/rshim.nix +++ b/nixos/modules/services/misc/rshim.nix @@ -3,11 +3,11 @@ let cfg = config.services.rshim; - rshimCommand = lib.escapeShellArgs ([ "${cfg.package}/bin/rshim" ] + rshimCommand = [ "${cfg.package}/bin/rshim" ] ++ lib.optionals (cfg.backend != null) [ "--backend ${cfg.backend}" ] ++ lib.optionals (cfg.device != null) [ "--device ${cfg.device}" ] ++ lib.optionals (cfg.index != null) [ "--index ${builtins.toString cfg.index}" ] - ++ [ "--log-level ${builtins.toString cfg.log-level}" ]) + ++ [ "--log-level ${builtins.toString cfg.log-level}" ] ; in { From 46dfed6010a624a7aec49bbc63752847ae3ff15a Mon Sep 17 00:00:00 2001 From: nikstur Date: Mon, 15 May 2023 14:09:28 +0200 Subject: [PATCH 2/2] nixos/tests/rshim: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/rshim.nix | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 nixos/tests/rshim.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 008dfbe39377..81c5e8dd9f3a 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -644,6 +644,7 @@ in { retroarch = handleTest ./retroarch.nix {}; robustirc-bridge = handleTest ./robustirc-bridge.nix {}; roundcube = handleTest ./roundcube.nix {}; + rshim = handleTest ./rshim.nix {}; rspamd = handleTest ./rspamd.nix {}; rss2email = handleTest ./rss2email.nix {}; rstudio-server = handleTest ./rstudio-server.nix {}; diff --git a/nixos/tests/rshim.nix b/nixos/tests/rshim.nix new file mode 100644 index 000000000000..bb5cce028ae7 --- /dev/null +++ b/nixos/tests/rshim.nix @@ -0,0 +1,25 @@ +{ system ? builtins.currentSystem +, config ? { } +, pkgs ? import ../.. { inherit system config; } +}: + +with import ../lib/testing-python.nix { inherit system pkgs; }; +with pkgs.lib; + +{ + basic = makeTest { + name = "rshim"; + meta.maintainers = with maintainers; [ nikstur ]; + + nodes.machine = { config, pkgs, ... }: { + services.rshim.enable = true; + }; + + testScript = { nodes, ... }: '' + machine.start() + machine.wait_for_unit("multi-user.target") + + print(machine.succeed("systemctl status rshim.service")) + ''; + }; +}