mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
jjui: init module
Add a module for configuring the jjui program.
This commit is contained in:
9
modules/misc/news/2025/09/2025-09-12_10-02-45.nix
Normal file
9
modules/misc/news/2025/09/2025-09-12_10-02-45.nix
Normal 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
65
modules/programs/jjui.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
5
tests/modules/programs/jjui/default.nix
Normal file
5
tests/modules/programs/jjui/default.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
jjui-empty-settings = ./empty-settings.nix;
|
||||
jjui-example-settings = ./example-settings.nix;
|
||||
jjui-null-package = ./null-package.nix;
|
||||
}
|
||||
9
tests/modules/programs/jjui/empty-settings.nix
Normal file
9
tests/modules/programs/jjui/empty-settings.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
config = {
|
||||
programs.jjui.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/jjui
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
[revisions]
|
||||
revset = "ancestors(@ | heads(remote_branches())) ~ empty()"
|
||||
template = "builtin_log_compact"
|
||||
29
tests/modules/programs/jjui/example-settings.nix
Normal file
29
tests/modules/programs/jjui/example-settings.nix
Normal 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}
|
||||
'';
|
||||
};
|
||||
}
|
||||
30
tests/modules/programs/jjui/null-package.nix
Normal file
30
tests/modules/programs/jjui/null-package.nix
Normal 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"
|
||||
''}
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user