1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

glab: init module (#8066)

This commit is contained in:
Benedikt M. Rips 2025-10-27 02:59:05 +01:00 committed by GitHub
parent 988f25531d
commit bbaeb9f1c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,9 @@
{
time = "2025-10-26T23:33:43+00:00";
condition = true;
message = ''
A new module is available: 'programs.glab'.
`glab` is an open source GitLab CLI tool that brings GitLab to your terminal.
'';
}

52
modules/programs/glab.nix Normal file
View file

@ -0,0 +1,52 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.glab;
yaml = pkgs.formats.yaml { };
in
{
meta.maintainers = [ lib.maintainers.bmrips ];
options.programs.glab = {
enable = lib.mkEnableOption "{command}`glab`.";
package = lib.mkPackageOption pkgs "glab" { nullable = true; };
aliases = lib.mkOption {
type = with lib.types; attrsOf str;
default = { };
description = "Aliases written to {file}`$XDG_CONFIG_HOME/glab-cli/aliases.yml`.";
example.co = "mr checkout";
};
settings = lib.mkOption {
inherit (yaml) type;
default = { };
description = "Configuration written to {file}`$XDG_CONFIG_HOME/glab-cli/config.yml`.";
example.check_update = false;
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
# Use `systemd-tmpfiles` since glab requires its configuration file to have
# mode 0600.
systemd.user.tmpfiles.rules =
let
target = "${config.xdg.configHome}/glab-cli/config.yml";
in
lib.mkIf (cfg.settings != { }) [
"C+ ${target} - - - - ${yaml.generate "glab-config" cfg.settings}"
"z ${target} 0600"
];
xdg.configFile."glab-cli/aliases.yml" = lib.mkIf (cfg.aliases != { }) {
source = yaml.generate "glab-aliases" cfg.aliases;
};
};
}

View file

@ -0,0 +1,16 @@
{ pkgs, ... }:
{
programs.glab = {
enable = true;
aliases.co = "mr checkout";
};
nmt.script = ''
aliasesFile=home-files/.config/glab-cli/aliases.yml
assertFileExists $aliasesFile
assertFileContent $aliasesFile ${pkgs.writeText "glab-aliases.expected" ''
co: mr checkout
''}
'';
}

View file

@ -0,0 +1,3 @@
{
glab-aliases = ./aliases.nix;
}