Skip to content

Commit

Permalink
Configure GitLab cli (#356)
Browse files Browse the repository at this point in the history
* Configure GitLab cli

* Scope clone commands for gh and glab-cli under their own directory
  • Loading branch information
francishamel authored Jan 11, 2025
1 parent 11003ec commit 3c1bcbd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/home-manager/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
./modules/fonts.nix
./modules/fzf.nix
./modules/git.nix
./modules/glab.nix
./modules/gui.nix
./modules/helix.nix
./modules/jq.nix
Expand Down
5 changes: 4 additions & 1 deletion modules/home-manager/modules/1password/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ let
inherit (lib) mkOption types;

cfg = config.hm._1password;

opCommand = "op plugin run --";
in
{
options = {
Expand Down Expand Up @@ -32,7 +34,8 @@ in
'';

zsh.shellAliases = {
gh = lib.mkIf config.programs.gh.enable "op plugin run -- gh";
gh = lib.mkIf config.programs.gh.enable "${opCommand} gh";
glab = "${opCommand} glab";
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion modules/home-manager/modules/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"prc" = "pr create --web --assignee @me";
"prd" = "pr create --draft --assignee @me";
"prv" = "pr view --web";
"rc" = "repo clone $1 ${config.home.homeDirectory}/src/$1";
"rc" = "repo clone $1 ${config.home.homeDirectory}/src/gh/$1";
};
git_protocol = "ssh";
};
Expand Down
42 changes: 42 additions & 0 deletions modules/home-manager/modules/glab.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ config, pkgs, ... }:

{
home.packages = [ pkgs.glab ];

xdg.configFile."glab-cli/hm_aliases.yml" = {
text = ''
rc: repo clone $1 ${config.home.homeDirectory}/src/glab-cli/$1
'';
# HACK: necessary since glab-cli requires the permissions of the file to be 600 and
# home-manager creates a symlink with 444 permissions.
onChange = ''
rm -f ${config.xdg.configHome}/glab-cli/aliases.yml
cp ${config.xdg.configHome}/glab-cli/hm_aliases.yml ${config.xdg.configHome}/glab-cli/aliases.yml
chmod 600 ${config.xdg.configHome}/glab-cli/aliases.yml
'';
};

xdg.configFile."glab-cli/hm_config.yml" = {
text = ''
git_protocol: ssh
editor:
browser:
glamour_style: dark
check_update: false
display_hyperlinks: true
host: gitlab.com
no_prompt: false
hosts:
gitlab.com:
api_protocol: https
api_host: gitlab.com
'';
# HACK: necessary since glab-cli requires the permissions of the file to be 600 and
# home-manager creates a symlink with 444 permissions.
onChange = ''
rm -f ${config.xdg.configHome}/glab-cli/config.yml
cp ${config.xdg.configHome}/glab-cli/hm_config.yml ${config.xdg.configHome}/glab-cli/config.yml
chmod 600 ${config.xdg.configHome}/glab-cli/config.yml
'';
};
}

0 comments on commit 3c1bcbd

Please sign in to comment.