From 8017dec82d5eb7664393da364fac0b05190cdbc6 Mon Sep 17 00:00:00 2001 From: Daniel Thwaites Date: Wed, 23 Jul 2025 20:59:28 +0100 Subject: [PATCH] stylix/testbed: make path escaping test actually contain a space Previously the space was sanitized away by `fetchurl` because it was part of the derivation name. Also, the path with a space was not used in the `schemeless` theme, which is where the bug happened. --- stylix/testbed/images.nix | 26 +++++++++++++++++++------- stylix/testbed/themes/schemeless.nix | 4 ++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/stylix/testbed/images.nix b/stylix/testbed/images.nix index 03e1aafc..1b5bde79 100644 --- a/stylix/testbed/images.nix +++ b/stylix/testbed/images.nix @@ -1,5 +1,6 @@ { fetchurl, + runCommandLocal, }: { dark = fetchurl { @@ -8,11 +9,22 @@ hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58="; }; - light = fetchurl { - # Includes a space to make sure the path is properly quoted via - # `lib.escapeShellArg` when used as a shell argument. - name = "three bicycles.jpg"; - url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true"; - hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA="; - }; + light = + let + image = fetchurl { + name = "three-bicycles.jpg"; + url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true"; + hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA="; + }; + + # Create a path containing a space to test that `stylix.image` is + # correctly quoted when used as a shell argument. We have to use a + # directory as the parent because derivation names themselves cannot + # contain spaces. + directory = runCommandLocal "three-bicycles" { } '' + mkdir "$out" + cp ${image} "$out/three bicycles.jpg" + ''; + in + "${directory}/three bicycles.jpg"; } diff --git a/stylix/testbed/themes/schemeless.nix b/stylix/testbed/themes/schemeless.nix index f656f781..91c6789d 100644 --- a/stylix/testbed/themes/schemeless.nix +++ b/stylix/testbed/themes/schemeless.nix @@ -5,8 +5,8 @@ in { stylix = { enable = true; - image = images.dark; - polarity = "dark"; + image = images.light; + polarity = "light"; cursor = { name = "Vanilla-DMZ"; package = pkgs.vanilla-dmz;