- enable option, jira/vault sub-enables - all config options matching config.py schema - generates ~/.config/work/config.toml via home.file - wires bash completion via programs.bash.initExtra - package installed from inputs.work-cli.packages
111 lines
2.3 KiB
Nix
111 lines
2.3 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
inputs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.work-cli;
|
|
workCliPkg = inputs.work-cli.packages.${pkgs.system}.default;
|
|
in
|
|
{
|
|
options.programs.work-cli = {
|
|
enable = lib.mkEnableOption "work-cli unified developer workflow CLI";
|
|
|
|
general = {
|
|
defaultBranch = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "main";
|
|
description = "Default git branch name";
|
|
};
|
|
};
|
|
|
|
gitlab = {
|
|
url = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "https://gitlab.com";
|
|
description = "GitLab instance URL";
|
|
};
|
|
|
|
project = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = "GitLab project path (namespace/repo)";
|
|
};
|
|
|
|
group = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = "GitLab group path";
|
|
};
|
|
};
|
|
|
|
jira = {
|
|
enable = lib.mkEnableOption "jira integration";
|
|
|
|
url = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = "Jira instance URL";
|
|
};
|
|
|
|
projectKey = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = "Jira project key";
|
|
};
|
|
};
|
|
|
|
vault = {
|
|
enable = lib.mkEnableOption "vault integration";
|
|
|
|
url = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = "Vault instance URL";
|
|
};
|
|
};
|
|
|
|
repos = {
|
|
path = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "~/work";
|
|
description = "Local path where repos are cloned";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = [ workCliPkg ];
|
|
|
|
home.file.".config/work/config.toml".text = ''
|
|
[general]
|
|
default_branch = "${cfg.general.defaultBranch}"
|
|
|
|
[gitlab]
|
|
url = "${cfg.gitlab.url}"
|
|
project = "${cfg.gitlab.project}"
|
|
group = "${cfg.gitlab.group}"
|
|
|
|
[repos]
|
|
path = "${cfg.repos.path}"
|
|
''
|
|
+ lib.optionalString cfg.jira.enable ''
|
|
|
|
[jira]
|
|
url = "${cfg.jira.url}"
|
|
project_key = "${cfg.jira.projectKey}"
|
|
''
|
|
+ lib.optionalString cfg.vault.enable ''
|
|
|
|
[vault]
|
|
url = "${cfg.vault.url}"
|
|
'';
|
|
|
|
programs.bash.initExtra = ''
|
|
eval "$(${workCliPkg}/bin/work --show-completion bash 2>/dev/null)"
|
|
'';
|
|
};
|
|
}
|