diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 6172bac7..37951ce9 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -163,6 +163,9 @@ Makefile @thiagokokada
/modules/programs/just.nix @maximsmol
+/modules/programs/jujutsu.nix @shikanime
+/tests/modules/programs/jujutsu @shikanime
+
/modules/programs/k9s.nix @katexochen
/tests/modules/programs/k9s @katexochen
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index af413169..1869d556 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -994,6 +994,13 @@ in
A new module is available: 'programs.mr'.
'';
}
+
+ {
+ time = "2023-04-28T19:59:23+00:00";
+ message = ''
+ A new module is available: 'programs.jujutsu'.
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index 93238ce1..025667ca 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -100,6 +100,7 @@ let
./programs/irssi.nix
./programs/java.nix
./programs/jq.nix
+ ./programs/jujutsu.nix
./programs/just.nix
./programs/k9s.nix
./programs/kakoune.nix
diff --git a/modules/programs/jujutsu.nix b/modules/programs/jujutsu.nix
new file mode 100644
index 00000000..6f40064b
--- /dev/null
+++ b/modules/programs/jujutsu.nix
@@ -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 .jjconfig.toml file. See
+
+ 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
+ '';
+ };
+}
diff --git a/tests/default.nix b/tests/default.nix
index 04f72fe2..54ee6d13 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -81,6 +81,7 @@ import nmt {
./modules/programs/hyfetch
./modules/programs/i3status
./modules/programs/irssi
+ ./modules/programs/jujutsu
./modules/programs/k9s
./modules/programs/kakoune
./modules/programs/kitty
diff --git a/tests/modules/programs/jujutsu/default.nix b/tests/modules/programs/jujutsu/default.nix
new file mode 100644
index 00000000..56811133
--- /dev/null
+++ b/tests/modules/programs/jujutsu/default.nix
@@ -0,0 +1,4 @@
+{
+ jujutsu-example-config = ./example-config.nix;
+ jujutsu-empty-config = ./empty-config.nix;
+}
diff --git a/tests/modules/programs/jujutsu/empty-config.nix b/tests/modules/programs/jujutsu/empty-config.nix
new file mode 100644
index 00000000..12c4a2f5
--- /dev/null
+++ b/tests/modules/programs/jujutsu/empty-config.nix
@@ -0,0 +1,11 @@
+{ ... }:
+
+{
+ programs.jujutsu.enable = true;
+
+ test.stubs.jujutsu = { };
+
+ nmt.script = ''
+ assertPathNotExists home-files/.jjconfig.toml
+ '';
+}
diff --git a/tests/modules/programs/jujutsu/example-config.nix b/tests/modules/programs/jujutsu/example-config.nix
new file mode 100644
index 00000000..06b68f18
--- /dev/null
+++ b/tests/modules/programs/jujutsu/example-config.nix
@@ -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"
+ ''
+ }
+ '';
+}