jjui: init module

Add a module for configuring the jjui program.
This commit is contained in:
Austin Horstman
2025-09-12 08:35:46 -05:00
parent 9eab59f3e7
commit 69083b3cdd
7 changed files with 150 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
time = "2025-09-12T15:02:45+00:00";
condition = true;
message = ''
A new module is available: 'programs.jjui'
jjui is a terminal user interface for jujutsu version control system.
'';
}

65
modules/programs/jjui.nix Normal file
View File

@@ -0,0 +1,65 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkOption;
cfg = config.programs.jjui;
tomlFormat = pkgs.formats.toml { };
in
{
meta.maintainers = [ lib.maintainers.khaneliman ];
options.programs.jjui = {
enable = lib.mkEnableOption "jjui - A terminal user interface for jujutsu";
package = lib.mkPackageOption pkgs "jjui" { nullable = true; };
configDir = mkOption {
type = lib.types.str;
default =
let
dir = if pkgs.stdenv.isDarwin then "Library/Application Support" else config.xdg.configHome;
in
"${dir}/jjui";
defaultText = lib.literalExpression "Darwin: \"Library/Application Support/jjui\" \nLinux: \${config.xdg.configHome}/jjui";
example = lib.literalExpression "\${config.home.homeDirectory}/.jjui";
description = ''
The directory to contain jjui configuration files.
'';
};
settings = mkOption {
inherit (tomlFormat) type;
default = { };
example = {
revisions = {
template = "builtin_log_compact";
revset = "";
};
};
description = ''
Options to add to the {file}`config.toml` file. See
<https://github.com/idursun/jjui/wiki/Configuration>
for options.
'';
};
};
config = mkIf cfg.enable {
home = {
packages = mkIf (cfg.package != null) [ cfg.package ];
file."${cfg.configDir}/config.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "jjui-config" cfg.settings;
};
sessionVariables = {
JJUI_CONFIG_DIR = cfg.configDir;
};
};
};
}

View File

@@ -0,0 +1,5 @@
{
jjui-empty-settings = ./empty-settings.nix;
jjui-example-settings = ./example-settings.nix;
jjui-null-package = ./null-package.nix;
}

View File

@@ -0,0 +1,9 @@
{
config = {
programs.jjui.enable = true;
nmt.script = ''
assertPathNotExists home-files/.config/jjui
'';
};
}

View File

@@ -0,0 +1,3 @@
[revisions]
revset = "ancestors(@ | heads(remote_branches())) ~ empty()"
template = "builtin_log_compact"

View File

@@ -0,0 +1,29 @@
{
config,
pkgs,
...
}:
{
config = {
programs.jjui = {
enable = true;
settings = {
revisions = {
template = "builtin_log_compact";
revset = "ancestors(@ | heads(remote_branches())) ~ empty()";
};
};
};
nmt.script =
let
configDir = if !pkgs.stdenv.isDarwin then ".config/jjui" else "Library/Application Support/jjui";
in
''
assertFileContent \
"home-files/${configDir}/config.toml" \
${./example-settings-expected.toml}
'';
};
}

View File

@@ -0,0 +1,30 @@
{
config,
pkgs,
...
}:
{
config = {
programs.jjui = {
enable = true;
package = null;
settings = {
revisions.template = "builtin_log_oneline";
};
};
nmt.script =
let
configDir = if !pkgs.stdenv.isDarwin then ".config/jjui" else "Library/Application Support/jjui";
in
''
assertFileContent \
"home-files/${configDir}/config.toml" \
${pkgs.writeText "expected" ''
[revisions]
template = "builtin_log_oneline"
''}
'';
};
}