Skip to content

Commit

Permalink
jujutsu: support darwin guidelines for config placement
Browse files Browse the repository at this point in the history
Follow up to #5207, fixing jujutsu module on darwin targets.
  • Loading branch information
mrnossiom authored Jul 28, 2024
1 parent 9fdadb1 commit ea72cf5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
7 changes: 6 additions & 1 deletion modules/programs/jujutsu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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 +56,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
9 changes: 6 additions & 3 deletions tests/modules/programs/jujutsu/empty-config.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{ ... }:
{ pkgs, ... }:

{
let
configDir =
if pkgs.stdenv.isDarwin then "Library/Application Support" else ".config";
in {
programs.jujutsu.enable = true;

test.stubs.jujutsu = { };

nmt.script = ''
assertPathNotExists home-files/.config/jj/config.toml
assertPathNotExists 'home-files/${configDir}/jj/config.toml'
'';
}
12 changes: 7 additions & 5 deletions tests/modules/programs/jujutsu/example-config.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{ config, ... }:
{ pkgs, config, ... }:

{
let
configDir =
if pkgs.stdenv.isDarwin then "Library/Application Support" else ".config";
in {
programs.jujutsu = {
enable = true;
package = config.lib.test.mkStubPackage { };
Expand All @@ -13,9 +16,8 @@
};

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

0 comments on commit ea72cf5

Please sign in to comment.