From 74a5f772749c7ccd9b4f111a6194598e4fc81de5 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Thu, 19 Sep 2024 16:39:48 -0700 Subject: [PATCH 1/2] switch-to-configuration-ng: update rust-ini to support multi-line INI values --- pkgs/by-name/sw/switch-to-configuration-ng/package.nix | 5 ++++- pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.lock | 5 ++--- pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.toml | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/package.nix b/pkgs/by-name/sw/switch-to-configuration-ng/package.nix index 50694aa1dd94..2bc473b2f093 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/package.nix +++ b/pkgs/by-name/sw/switch-to-configuration-ng/package.nix @@ -12,7 +12,10 @@ rustPlatform.buildRustPackage { src = ./src; - cargoLock.lockFile = ./src/Cargo.lock; + cargoLock = { + lockFile = ./src/Cargo.lock; + outputHashes."rust-ini-0.21.1" = "sha256-0nSBhme/g+mVsYdiq0Ash0ek9WEdvbf/b9FRxA7sauk="; + }; nativeBuildInputs = [ pkg-config ]; buildInputs = [ dbus ]; diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.lock b/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.lock index 9b70ccfe23b3..56913a9158c3 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.lock +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.lock @@ -337,9 +337,8 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rust-ini" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d625ed57d8f49af6cfa514c42e1a71fadcff60eb0b1c517ff82fe41aa025b41" +version = "0.21.1" +source = "git+https://github.com/zonyitoo/rust-ini?rev=5748ae57a178216a920b88dfac1296618e967447#5748ae57a178216a920b88dfac1296618e967447" dependencies = [ "cfg-if", "ordered-multimap", diff --git a/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.toml b/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.toml index 51d805dcd959..37ca687b3f1b 100644 --- a/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.toml +++ b/pkgs/by-name/sw/switch-to-configuration-ng/src/Cargo.toml @@ -12,7 +12,9 @@ glob = "0.3.1" log = "0.4.21" nix = { version = "0.28.0", features = ["fs", "signal"] } regex = "1.10.4" -rust-ini = "0.21.0" +rust-ini = { git = "https://github.com/zonyitoo/rust-ini", rev = "5748ae57a178216a920b88dfac1296618e967447", features = [ + "inline-comment", +] } syslog = "6.1.1" [build-dependencies] From f6fed8b8317bf6f8ee8101c211f5a44787f2d97d Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 20 Sep 2024 17:18:32 -0700 Subject: [PATCH 2/2] nixos/switch-test: add test for multi-line unit values --- nixos/tests/switch-test.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix index 84c6e90689b3..e00c22b81682 100644 --- a/nixos/tests/switch-test.nix +++ b/nixos/tests/switch-test.nix @@ -260,6 +260,15 @@ in { systemd.services."escaped\\x2ddash".serviceConfig.X-Test = "test"; }; + unitWithMultilineValue.configuration = { + systemd.services.test.serviceConfig.ExecStart = '' + ${pkgs.coreutils}/bin/true \ + # ignored + ; ignored + blah blah + ''; + }; + unitStartingWithDash.configuration = { systemd.services."-" = { wantedBy = [ "multi-user.target" ]; @@ -874,9 +883,16 @@ in { machine.succeed("! test -e /run/current-system/dry-activate") machine.succeed("! test -e /run/current-system/bin/switch-to-configuration") + # Ensure units with multiline values work + out = switch_to_specialisation("${machine}", "unitWithMultilineValue") + assert_lacks(out, "NOT restarting the following changed units:") + assert_lacks(out, "reloading the following units:") + assert_lacks(out, "restarting the following units:") + assert_lacks(out, "the following new units were started:") + assert_contains(out, "starting the following units: test.service") + # Ensure \ works in unit names out = switch_to_specialisation("${machine}", "unitWithBackslash") - assert_contains(out, "stopping the following units: test.service\n") assert_lacks(out, "NOT restarting the following changed units:") assert_lacks(out, "reloading the following units:") assert_lacks(out, "\nrestarting the following units:")