wrapper-manager/programs/jujutsu: init

This commit is contained in:
Gabriel Arazas 2024-08-22 19:26:08 +08:00
parent 30b2f192e4
commit 5ca6749d50
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
5 changed files with 97 additions and 0 deletions

View File

@ -3,6 +3,7 @@
./programs/blender.nix ./programs/blender.nix
./programs/zellij.nix ./programs/zellij.nix
./programs/neovim.nix ./programs/neovim.nix
./programs/jujutsu.nix
./nixgl.nix ./nixgl.nix
./dconf.nix ./dconf.nix
./sandboxing ./sandboxing

View File

@ -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;
})
];
};
}

View File

@ -20,4 +20,5 @@ in
bubblewrap = runTests ./sandboxing/bubblewrap { }; bubblewrap = runTests ./sandboxing/bubblewrap { };
boxxy = runTests ./sandboxing/boxxy { }; boxxy = runTests ./sandboxing/boxxy { };
zellij = runTests ./programs/zellij { }; zellij = runTests ./programs/zellij { };
jujutsu = runTests ./programs/jujutsu { };
} }

View File

@ -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
'';
};
}

View File

@ -0,0 +1,3 @@
{
basic = ./basic.nix;
}