Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure GitLab cli #356

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
'';
};
}
Loading