From 14b6fd270102b4a42527842a4cbc7c1ce4e488cd Mon Sep 17 00:00:00 2001 From: Francis Hamel <36383308+francishamel@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:31:23 -0500 Subject: [PATCH] Configure GitLab cli --- modules/home-manager/flake-module.nix | 1 + .../home-manager/modules/1password/common.nix | 5 ++- modules/home-manager/modules/glab.nix | 41 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 modules/home-manager/modules/glab.nix diff --git a/modules/home-manager/flake-module.nix b/modules/home-manager/flake-module.nix index 93f0234..a7f88e2 100644 --- a/modules/home-manager/flake-module.nix +++ b/modules/home-manager/flake-module.nix @@ -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 diff --git a/modules/home-manager/modules/1password/common.nix b/modules/home-manager/modules/1password/common.nix index f2a9b43..2c955ae 100644 --- a/modules/home-manager/modules/1password/common.nix +++ b/modules/home-manager/modules/1password/common.nix @@ -3,6 +3,8 @@ let inherit (lib) mkOption types; cfg = config.hm._1password; + + opCommand = "op plugin run --"; in { options = { @@ -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"; }; }; }; diff --git a/modules/home-manager/modules/glab.nix b/modules/home-manager/modules/glab.nix new file mode 100644 index 0000000..513349d --- /dev/null +++ b/modules/home-manager/modules/glab.nix @@ -0,0 +1,41 @@ +{ config, pkgs, ... }: + +{ + home.packages = [ pkgs.glab ]; + + xdg.configFile."glab-cli/hm_aliases.yml" = { + text = '' + ''; + # 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 + ''; + }; +}