diff --git a/modules/wrapper-manager/default.nix b/modules/wrapper-manager/default.nix index 171cc576..1f722aa9 100644 --- a/modules/wrapper-manager/default.nix +++ b/modules/wrapper-manager/default.nix @@ -3,6 +3,7 @@ ./programs/blender.nix ./programs/zellij.nix ./programs/neovim.nix + ./programs/jujutsu.nix ./nixgl.nix ./dconf.nix ./sandboxing diff --git a/modules/wrapper-manager/programs/jujutsu.nix b/modules/wrapper-manager/programs/jujutsu.nix new file mode 100644 index 00000000..1bc8eb4b --- /dev/null +++ b/modules/wrapper-manager/programs/jujutsu.nix @@ -0,0 +1,71 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.jujutsu; + + settingsFormat = pkgs.formats.toml { }; +in +{ + options.programs.jujutsu = { + enable = lib.mkEnableOption "Jujutsu, a Git-compatible DVCS"; + + package = lib.mkPackageOption pkgs "jujutsu" { }; + + executableName = lib.mkOption { + type = lib.types.nonEmptyStr; + description = '' + The name of the executable Jujutsu wrapper. + ''; + default = "jj"; + example = "jj-custom"; + }; + + settings = lib.mkOption { + type = settingsFormat.type; + description = '' + Nix-configured settings to be used by the wrapper. This option is + ignored if {option}`programs.jujutsu.configFile` is not `null`. + ''; + default = { }; + example = lib.literalExpression '' + { + user.name = "Your Name"; + user.email = "youremail@example.com"; + ui.color = "never"; + ui.diff.tool = "vimdiff"; + merge-tools.vimdiff.diff-invocation-mode = "file-by-file"; + } + ''; + }; + + configFile = lib.mkOption { + type = with lib.types; nullOr path; + description = '' + The configuration file to be used for the Jujutsu wrapper. If the value + is `null`, it will generate one from + {option}`programs.jujutsu.settings`. + ''; + default = null; + example = lib.literalExpression "./config/jujutsu.toml"; + }; + }; + + config = lib.mkIf cfg.enable { + basePackages = [ cfg.package ]; + wrappers.jujutsu = lib.mkMerge [ + { + inherit (cfg) executableName; + arg0 = lib.getExe' cfg.package "jj"; + } + + (lib.mkIf (cfg.configFile != null) { + env.JJ_CONFIG.value = cfg.configFile; + }) + + (lib.mkIf (cfg.settings != { } && cfg.configFile == null) { + env.JJ_CONFIG.value = + settingsFormat.generate "wrapper-manager-jujutsu-config" cfg.settings; + }) + ]; + }; +} diff --git a/tests/modules/wrapper-manager/default.nix b/tests/modules/wrapper-manager/default.nix index ac11c9b0..1ea67a0f 100644 --- a/tests/modules/wrapper-manager/default.nix +++ b/tests/modules/wrapper-manager/default.nix @@ -20,4 +20,5 @@ in bubblewrap = runTests ./sandboxing/bubblewrap { }; boxxy = runTests ./sandboxing/boxxy { }; zellij = runTests ./programs/zellij { }; + jujutsu = runTests ./programs/jujutsu { }; } diff --git a/tests/modules/wrapper-manager/programs/jujutsu/basic.nix b/tests/modules/wrapper-manager/programs/jujutsu/basic.nix new file mode 100644 index 00000000..19fdb285 --- /dev/null +++ b/tests/modules/wrapper-manager/programs/jujutsu/basic.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +{ + programs.jujutsu = { + enable = true; + settings = { + user.name = "Your name"; + user.email = "yourname@example.com"; + }; + }; + + build.extraPassthru.tests = { + runWithJujutsu = let + wrapper = config.build.toplevel; + in pkgs.runCommand '' + [ -x ${lib.getExe' wrapper "jj"} ] && touch $out + ''; + }; +} + + diff --git a/tests/modules/wrapper-manager/programs/jujutsu/default.nix b/tests/modules/wrapper-manager/programs/jujutsu/default.nix new file mode 100644 index 00000000..7fff7787 --- /dev/null +++ b/tests/modules/wrapper-manager/programs/jujutsu/default.nix @@ -0,0 +1,3 @@ +{ + basic = ./basic.nix; +}