Skip to content

Commit 99e84ee

Browse files
authored
pistol: revert config path for macOS (#9798)
1 parent f404edb commit 99e84ee

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

modules/programs/pistol.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ let
1010
cfg = config.programs.pistol;
1111

1212
configDir =
13-
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Preferences" else config.xdg.configHome;
13+
# NOTE: This intentionally diverges from the documentation
14+
# pistol's README claims that the default is Library/Preferences
15+
# However, this is part of a default set for XDG_CONFIG_DIRS,
16+
# which gets overwritten by, e.g., nix-darwin.
17+
# In such cases, the only directory checked is `XDG_CONFIG_HOME`,
18+
# which falls back to Library/Application Support/.
19+
if pkgs.stdenv.hostPlatform.isDarwin && !config.xdg.enable then
20+
"Library/Application Support"
21+
else
22+
config.xdg.configHome;
1423

1524
configFile = lib.concatStringsSep "\n" (
1625
map (

tests/modules/programs/pistol/associations.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
];
2020
};
2121

22+
xdg.enable = false;
23+
2224
nmt.script =
2325
let
2426
expected = builtins.toFile "config-expected" ''
@@ -27,7 +29,7 @@
2729
fpath .*.md$ sh: bat --paging=never --color=always %pistol-filename% | head -8'';
2830
path =
2931
if pkgs.stdenv.hostPlatform.isDarwin then
30-
"home-files/Library/Preferences/pistol/pistol.conf"
32+
"home-files/Library/Application Support/pistol/pistol.conf"
3133
else
3234
"home-files/.config/pistol/pistol.conf";
3335
in

tests/modules/programs/pistol/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
pistol-associations = ./associations.nix;
33
pistol-config = ./config.nix;
44
pistol-double-association = ./double-association.nix;
5+
pistol-honors-xdg = ./honors-xdg.nix;
56
pistol-missing-association = ./missing-association.nix;
67
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
_: {
2+
programs.pistol = {
3+
enable = true;
4+
associations = [
5+
{
6+
mime = "application/json";
7+
command = "bat %pistol-filename%";
8+
}
9+
];
10+
};
11+
12+
xdg.enable = true;
13+
14+
nmt.script =
15+
let
16+
expected = builtins.toFile "config-expected" "application/json bat %pistol-filename%";
17+
path = "home-files/.config/pistol/pistol.conf";
18+
in
19+
''
20+
assertFileExists '${path}'
21+
assertFileContent '${path}' '${expected}'
22+
'';
23+
}

0 commit comments

Comments
 (0)