From c82bc787b8990c89f2f7d57df652ce2424129b92 Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 19 Nov 2021 09:14:11 +0800 Subject: [PATCH] xdg: fix typo and add test --- modules/misc/xdg.nix | 2 +- tests/modules/misc/xdg/default-locations.nix | 35 ++++++++++++++++++++ tests/modules/misc/xdg/default.nix | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/modules/misc/xdg/default-locations.nix diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 1790b87d..5961cac3 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -108,7 +108,7 @@ in { xdg.cacheHome = mkDefault defaultCacheHome; xdg.configHome = mkDefault defaultConfigHome; xdg.dataHome = mkDefault defaultDataHome; - xdg.stateHome = mkDefault stateHome; + xdg.stateHome = mkDefault defaultStateHome; }) { diff --git a/tests/modules/misc/xdg/default-locations.nix b/tests/modules/misc/xdg/default-locations.nix new file mode 100644 index 00000000..1f6b36cc --- /dev/null +++ b/tests/modules/misc/xdg/default-locations.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + # Test fallback behavior for stateVersion >= 20.09, which is pure. + xdg.enable = lib.mkForce false; + home.stateVersion = "20.09"; + + xdg.configFile.test.text = "config"; + xdg.dataFile.test.text = "data"; + home.file."${config.xdg.cacheHome}/test".text = "cache"; + home.file."${config.xdg.stateHome}/test".text = "state"; + + nmt.script = '' + assertFileExists home-files/.config/test + assertFileExists home-files/.local/share/test + assertFileExists home-files/.cache/test + assertFileExists home-files/.local/state/test + assertFileContent \ + home-files/.config/test \ + ${builtins.toFile "test" "config"} + assertFileContent \ + home-files/.local/share/test \ + ${builtins.toFile "test" "data"} + assertFileContent \ + home-files/.cache/test \ + ${builtins.toFile "test" "cache"} + assertFileContent \ + home-files/.local/state/test \ + ${builtins.toFile "test" "state"} + ''; + }; +} diff --git a/tests/modules/misc/xdg/default.nix b/tests/modules/misc/xdg/default.nix index e3104dd9..f3fef092 100644 --- a/tests/modules/misc/xdg/default.nix +++ b/tests/modules/misc/xdg/default.nix @@ -3,4 +3,5 @@ xdg-system-dirs = ./system-dirs.nix; xdg-desktop-entries = ./desktop-entries.nix; xdg-file-gen = ./file-gen.nix; + xdg-default-locations = ./default-locations.nix; }