1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

jujutsu: add module

This commit is contained in:
William Phetsinorath 2023-01-27 22:15:17 +01:00 committed by Robert Helgesson
parent f2d6291150
commit c4f3a37071
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
8 changed files with 130 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -163,6 +163,9 @@ Makefile @thiagokokada
/modules/programs/just.nix @maximsmol /modules/programs/just.nix @maximsmol
/modules/programs/jujutsu.nix @shikanime
/tests/modules/programs/jujutsu @shikanime
/modules/programs/k9s.nix @katexochen /modules/programs/k9s.nix @katexochen
/tests/modules/programs/k9s @katexochen /tests/modules/programs/k9s @katexochen

View file

@ -994,6 +994,13 @@ in
A new module is available: 'programs.mr'. A new module is available: 'programs.mr'.
''; '';
} }
{
time = "2023-04-28T19:59:23+00:00";
message = ''
A new module is available: 'programs.jujutsu'.
'';
}
]; ];
}; };
} }

View file

@ -100,6 +100,7 @@ let
./programs/irssi.nix ./programs/irssi.nix
./programs/java.nix ./programs/java.nix
./programs/jq.nix ./programs/jq.nix
./programs/jujutsu.nix
./programs/just.nix ./programs/just.nix
./programs/k9s.nix ./programs/k9s.nix
./programs/kakoune.nix ./programs/kakoune.nix

View file

@ -0,0 +1,76 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.jujutsu;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ maintainers.shikanime ];
options.programs.jujutsu = {
enable =
mkEnableOption "a Git-compatible DVCS that is both simple and powerful";
package = mkPackageOption pkgs "jujutsu" { };
settings = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
{
user = {
name = "John Doe";
email = "jdoe@example.org";
};
}
'';
description = ''
Options to add to the <filename>.jjconfig.toml</filename> file. See
<link xlink:href="https://github.com/martinvonz/jj/blob/main/docs/config.md"/>
for options.
'';
};
enableBashIntegration = mkOption {
type = types.bool;
default = true;
description = "Whether to enable Bash integration.";
};
enableZshIntegration = mkOption {
type = types.bool;
default = true;
description = "Whether to enable Zsh integration.";
};
enableFishIntegration = mkOption {
type = types.bool;
default = true;
description = "Whether to enable Fish integration.";
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file.".jjconfig.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "jujutsu-config" cfg.settings;
};
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
source <(${pkgs.jujutsu}/bin/jj debug completion)
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
source <(${pkgs.jujutsu}/bin/jj debug completion --zsh | sed '$d')
compdef _jj ${pkgs.jujutsu}/bin/jj
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
${pkgs.jujutsu}/bin/jj debug completion --fish | source
'';
};
}

View file

@ -81,6 +81,7 @@ import nmt {
./modules/programs/hyfetch ./modules/programs/hyfetch
./modules/programs/i3status ./modules/programs/i3status
./modules/programs/irssi ./modules/programs/irssi
./modules/programs/jujutsu
./modules/programs/k9s ./modules/programs/k9s
./modules/programs/kakoune ./modules/programs/kakoune
./modules/programs/kitty ./modules/programs/kitty

View file

@ -0,0 +1,4 @@
{
jujutsu-example-config = ./example-config.nix;
jujutsu-empty-config = ./empty-config.nix;
}

View file

@ -0,0 +1,11 @@
{ ... }:
{
programs.jujutsu.enable = true;
test.stubs.jujutsu = { };
nmt.script = ''
assertPathNotExists home-files/.jjconfig.toml
'';
}

View file

@ -0,0 +1,27 @@
{ config, ... }:
{
programs.jujutsu = {
enable = true;
package = config.lib.test.mkStubPackage { };
settings = {
user = {
name = "John Doe";
email = "jdoe@example.org";
};
};
};
nmt.script = ''
assertFileExists home-files/.jjconfig.toml
assertFileContent \
home-files/.jjconfig.toml \
${
builtins.toFile "expected.toml" ''
[user]
email = "jdoe@example.org"
name = "John Doe"
''
}
'';
}