1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-22 18:29:39 +01:00

jujutsu: evaluate the settings after merging with other options (#6775)

* jujutsu: evaluate the settings after merging with other options

* jujutsu: add ediff to the test
This commit is contained in:
Matthieu Coudron 2025-04-11 10:34:17 +02:00 committed by GitHub
parent f1ffd097e7
commit da624eaad0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 17 deletions

View file

@ -66,10 +66,9 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = mkIf (cfg.package != null) [ cfg.package ]; home.packages = mkIf (cfg.package != null) [ cfg.package ];
home.file."${configDir}/jj/config.toml" = mkIf (cfg.settings != { }) { programs.jujutsu.settings = lib.mkMerge [
source = tomlFormat.generate "jujutsu-config" ( (lib.mkIf cfg.ediff {
cfg.settings merge-tools.ediff =
// lib.optionalAttrs (cfg.ediff) (
let let
emacsDiffScript = pkgs.writeShellScriptBin "emacs-ediff" '' emacsDiffScript = pkgs.writeShellScriptBin "emacs-ediff" ''
set -euxo pipefail set -euxo pipefail
@ -77,7 +76,6 @@ in
''; '';
in in
{ {
merge-tools.ediff = {
program = lib.getExe emacsDiffScript; program = lib.getExe emacsDiffScript;
merge-args = [ merge-args = [
"$left" "$left"
@ -86,9 +84,11 @@ in
"$output" "$output"
]; ];
}; };
} })
) ];
);
home.file."${configDir}/jj/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "jujutsu-config" cfg.settings;
}; };
}; };
} }

View file

@ -7,6 +7,7 @@ in
programs.jujutsu = { programs.jujutsu = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { }; package = config.lib.test.mkStubPackage { };
ediff = true;
settings = { settings = {
user = { user = {
name = "John Doe"; name = "John Doe";
@ -17,8 +18,12 @@ in
nmt.script = '' nmt.script = ''
assertFileExists 'home-files/${configDir}/jj/config.toml' assertFileExists 'home-files/${configDir}/jj/config.toml'
assertFileContent 'home-files/${configDir}/jj/config.toml' \ assertFileContent $(normalizeStorePaths 'home-files/${configDir}/jj/config.toml') \
${builtins.toFile "expected.toml" '' ${builtins.toFile "expected.toml" ''
[merge-tools.ediff]
merge-args = ["$left", "$right", "$base", "$output"]
program = "/nix/store/00000000000000000000000000000000-emacs-ediff/bin/emacs-ediff"
[user] [user]
email = "jdoe@example.org" email = "jdoe@example.org"
name = "John Doe" name = "John Doe"