From 9bf1f40af124573a54fd208b1f539eb694ef31a6 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sun, 11 Oct 2020 17:22:58 -0700 Subject: [PATCH] xdg: disambiguate `home.file` attribute names --- modules/misc/xdg.nix | 12 +++++----- tests/modules/misc/xdg/default.nix | 5 ++++- tests/modules/misc/xdg/file-attr-names.nix | 26 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 tests/modules/misc/xdg/file-attr-names.nix diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index 7420e8e92..f207d7d35 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -101,11 +101,13 @@ in { home.file = mkMerge [ - cfg.configFile - cfg.dataFile - { - "${config.xdg.cacheHome}/.keep".text = ""; - } + (mapAttrs' + (name: file: nameValuePair "${config.xdg.configHome}/${name}" file) + cfg.configFile) + (mapAttrs' + (name: file: nameValuePair "${config.xdg.dataHome}/${name}" file) + cfg.dataFile) + { "${config.xdg.cacheHome}/.keep".text = ""; } ]; } ]; diff --git a/tests/modules/misc/xdg/default.nix b/tests/modules/misc/xdg/default.nix index e5d015759..813a25202 100644 --- a/tests/modules/misc/xdg/default.nix +++ b/tests/modules/misc/xdg/default.nix @@ -1 +1,4 @@ -{ xdg-mime-apps-basics = ./mime-apps-basics.nix; } +{ + xdg-mime-apps-basics = ./mime-apps-basics.nix; + xdg-file-attr-names = ./file-attr-names.nix; +} diff --git a/tests/modules/misc/xdg/file-attr-names.nix b/tests/modules/misc/xdg/file-attr-names.nix new file mode 100644 index 000000000..0aa8fcffe --- /dev/null +++ b/tests/modules/misc/xdg/file-attr-names.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + xdg.configFile.test.text = "config"; + xdg.dataFile.test.text = "data"; + home.file.test.text = "home"; + + nmt.script = '' + assertFileExists home-files/.config/test + assertFileExists home-files/.local/share/test + assertFileExists home-files/test + assertFileContent \ + home-files/.config/test \ + ${builtins.toFile "test" "config"} + assertFileContent \ + home-files/.local/share/test \ + ${builtins.toFile "test" "data"} + assertFileContent \ + home-files/test \ + ${builtins.toFile "test" "home"} + ''; + }; +}