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/git.nix b/modules/home-manager/modules/git.nix index aa38828..5bb6bb5 100644 --- a/modules/home-manager/modules/git.nix +++ b/modules/home-manager/modules/git.nix @@ -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"; }; diff --git a/modules/home-manager/modules/glab.nix b/modules/home-manager/modules/glab.nix new file mode 100644 index 0000000..cbd89b0 --- /dev/null +++ b/modules/home-manager/modules/glab.nix @@ -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 + ''; + }; +}