Skip to content

Commit

Permalink
jujutsu: fix config file location on Darwin
Browse files Browse the repository at this point in the history
jj looks for its config file in ~/Library/Application Support/jj on
Darwin. The previous module implementation unconditionally stored the
configuration file in $XDG_CONFIG_HOME/jj. This revision now uses the
correct location on Darwin.
  • Loading branch information
Aehmlo committed Jun 16, 2024
1 parent 8d5e27b commit 9ce3507
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion modules/programs/jujutsu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ let

cfg = config.programs.jujutsu;
tomlFormat = pkgs.formats.toml { };
configDir = if pkgs.stdenv.isDarwin then
"Library/Application Support"
else
config.xdg.configHome;

in {
meta.maintainers = [ maintainers.shikanime ];
Expand Down Expand Up @@ -51,7 +55,7 @@ in {
config = mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."jj/config.toml" = mkIf (cfg.settings != { }) {
home.file."${configDir}/jj/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "jujutsu-config" (cfg.settings
// optionalAttrs (cfg.ediff) (let
emacsDiffScript = pkgs.writeShellScriptBin "emacs-ediff" ''
Expand Down
1 change: 1 addition & 0 deletions tests/modules/programs/jujutsu/empty-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

nmt.script = ''
assertPathNotExists home-files/.config/jj/config.toml
assertPathNotExists "home-files/Library/Application Support/jj/config.toml"
'';
}
14 changes: 10 additions & 4 deletions tests/modules/programs/jujutsu/example-config.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{ config, ... }:
{ config, pkgs, ... }:

{
let
configFile = if pkgs.stdenv.isDarwin then
"home-files/Library/Application Support/jj/config.toml"
else
"home-files/.config/jj/config.toml";

in {
programs.jujutsu = {
enable = true;
package = config.lib.test.mkStubPackage { };
Expand All @@ -13,9 +19,9 @@
};

nmt.script = ''
assertFileExists home-files/.config/jj/config.toml
assertFileExists "${configFile}"
assertFileContent \
home-files/.config/jj/config.toml \
"${configFile}" \
${
builtins.toFile "expected.toml" ''
[user]
Expand Down

0 comments on commit 9ce3507

Please sign in to comment.