From 6fc82e56971523acfe1a61dbcb20f4bb969b3990 Mon Sep 17 00:00:00 2001 From: amesgen Date: Sun, 7 May 2023 13:42:55 +0200 Subject: [PATCH] i3status-rust: revert #3938 (#3957) * Revert "i3status-rust: satisfy new 0.31 TOML output requirements (#3938)" This reverts commit 0e4c33d76006c9080d2f228ba1c2308e3e4d7be6. * i3status-rust: assertion for unsupported versions --- modules/programs/i3status-rust.nix | 19 +++++++------------ .../programs/i3status-rust/default.nix | 1 + .../programs/i3status-rust/with-custom.nix | 4 ++-- .../programs/i3status-rust/with-default.nix | 6 +++--- .../i3status-rust/with-extra-settings.nix | 4 ++-- .../i3status-rust/with-multiple-bars.nix | 4 ++-- .../i3status-rust/with-version-02xx.nix | 4 ++-- .../i3status-rust/with-version-0311.nix | 13 +++++++++++++ 8 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 tests/modules/programs/i3status-rust/with-version-0311.nix diff --git a/modules/programs/i3status-rust.nix b/modules/programs/i3status-rust.nix index 1f9c2bb6d..237afd818 100644 --- a/modules/programs/i3status-rust.nix +++ b/modules/programs/i3status-rust.nix @@ -6,18 +6,7 @@ let cfg = config.programs.i3status-rust; - settingsFormat = pkgs.formats.toml { } // { - # Since 0.31, the "block" key has to be first in the TOML output. - generate = name: value: - pkgs.runCommand name { - nativeBuildInputs = [ pkgs.jq pkgs.remarshal ]; - value = builtins.toJSON value; - passAsFile = [ "value" ]; - } '' - jq '.block |= map({block: .block} + del(.block))' "$valuePath" \ - | json2toml --preserve-key-order > "$out" - ''; - }; + settingsFormat = pkgs.formats.toml { }; in { meta.maintainers = with lib.maintainers; [ farlion thiagokokada ]; @@ -248,6 +237,12 @@ in { assertions = [ (hm.assertions.assertPlatform "programs.i3status-rust" pkgs platforms.linux) + { + assertion = lib.versionOlder cfg.package.version "0.31.0" + || lib.versionAtLeast cfg.package.version "0.31.2"; + message = + "Only i3status-rust <0.31.0 or ≥0.31.2 is supported due to a config format incompatibility."; + } ]; home.packages = [ cfg.package ]; diff --git a/tests/modules/programs/i3status-rust/default.nix b/tests/modules/programs/i3status-rust/default.nix index 4002f4b4c..d99b0156a 100644 --- a/tests/modules/programs/i3status-rust/default.nix +++ b/tests/modules/programs/i3status-rust/default.nix @@ -4,4 +4,5 @@ i3status-rust-with-extra-settings = ./with-extra-settings.nix; i3status-rust-with-multiple-bars = ./with-multiple-bars.nix; i3status-rust-with-version-02xx = ./with-version-02xx.nix; + i3status-rust-with-version-0311 = ./with-version-0311.nix; } diff --git a/tests/modules/programs/i3status-rust/with-custom.nix b/tests/modules/programs/i3status-rust/with-custom.nix index 564e7eb31..46887a58e 100644 --- a/tests/modules/programs/i3status-rust/with-custom.nix +++ b/tests/modules/programs/i3status-rust/with-custom.nix @@ -105,12 +105,12 @@ ${ pkgs.writeText "i3status-rust-expected-config" '' [[block]] + alert = 10.0 block = "disk_space" - alert = 10 info_type = "available" interval = 60 path = "/" - warning = 20 + warning = 20.0 [[block]] block = "memory" diff --git a/tests/modules/programs/i3status-rust/with-default.nix b/tests/modules/programs/i3status-rust/with-default.nix index f083358d6..3b5b2213a 100644 --- a/tests/modules/programs/i3status-rust/with-default.nix +++ b/tests/modules/programs/i3status-rust/with-default.nix @@ -4,7 +4,7 @@ config = { programs.i3status-rust = { enable = true; }; - test.stubs.i3status-rust = { version = "0.30.0"; }; + test.stubs.i3status-rust = { version = "0.31.2"; }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-default.toml @@ -12,12 +12,12 @@ ${ pkgs.writeText "i3status-rust-expected-config" '' [[block]] + alert = 10.0 block = "disk_space" - alert = 10 info_type = "available" interval = 60 path = "/" - warning = 20 + warning = 20.0 [[block]] block = "memory" diff --git a/tests/modules/programs/i3status-rust/with-extra-settings.nix b/tests/modules/programs/i3status-rust/with-extra-settings.nix index f5f89b1e0..0d8b4663b 100644 --- a/tests/modules/programs/i3status-rust/with-extra-settings.nix +++ b/tests/modules/programs/i3status-rust/with-extra-settings.nix @@ -115,12 +115,12 @@ ${ pkgs.writeText "i3status-rust-expected-config" '' [[block]] + alert = 10.0 block = "disk_space" - alert = 10 info_type = "available" interval = 60 path = "/" - warning = 20 + warning = 20.0 [[block]] block = "memory" diff --git a/tests/modules/programs/i3status-rust/with-multiple-bars.nix b/tests/modules/programs/i3status-rust/with-multiple-bars.nix index 93c43c755..2a56d6a9c 100644 --- a/tests/modules/programs/i3status-rust/with-multiple-bars.nix +++ b/tests/modules/programs/i3status-rust/with-multiple-bars.nix @@ -54,11 +54,11 @@ ${ pkgs.writeText "i3status-rust-expected-config" '' [[block]] + alert = 10.0 block = "disk_space" - alert = 10 info_type = "available" interval = 60 - warning = 20 + warning = 20.0 [[block]] block = "memory" diff --git a/tests/modules/programs/i3status-rust/with-version-02xx.nix b/tests/modules/programs/i3status-rust/with-version-02xx.nix index 870519f87..ec8c2f9a9 100644 --- a/tests/modules/programs/i3status-rust/with-version-02xx.nix +++ b/tests/modules/programs/i3status-rust/with-version-02xx.nix @@ -14,12 +14,12 @@ icons = "none" theme = "plain" [[block]] + alert = 10.0 block = "disk_space" - alert = 10 info_type = "available" interval = 60 path = "/" - warning = 20 + warning = 20.0 [[block]] block = "memory" diff --git a/tests/modules/programs/i3status-rust/with-version-0311.nix b/tests/modules/programs/i3status-rust/with-version-0311.nix new file mode 100644 index 000000000..d84cdd7cc --- /dev/null +++ b/tests/modules/programs/i3status-rust/with-version-0311.nix @@ -0,0 +1,13 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + programs.i3status-rust = { enable = true; }; + + test.stubs.i3status-rust = { version = "0.31.1"; }; + + test.asserts.assertions.expected = [ + "Only i3status-rust <0.31.0 or ≥0.31.2 is supported due to a config format incompatibility." + ]; + }; +}