1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-26 03:39:47 +01:00

gh: include version in settings

Also add an activation script block for allowing gh version 2.40.0 and
later to perform account migration.
This commit is contained in:
Harsh Shandilya 2023-12-08 19:33:19 +05:30 committed by Mikilio
parent 3dfe0c7602
commit 6ea6f0fbbb
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
3 changed files with 23 additions and 1 deletions

View file

@ -126,7 +126,27 @@ in {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."gh/config.yml".source = xdg.configFile."gh/config.yml".source =
yamlFormat.generate "gh-config.yml" cfg.settings; yamlFormat.generate "gh-config.yml" ({ version = "1"; } // cfg.settings);
# Version 2.40.0+ of gh needs to migrate account formats, this needs to
# happen before the version = 1 is placed in the configuration file. Running
# `gh help` is sufficient to perform the migration. If the migration already
# has occurred, then this is a no-op.
#
# See https://github.com/nix-community/home-manager/issues/4744 for details.
home.activation.migrateGhAccounts =
hm.dag.entryBetween [ "linkGeneration" ] [ "writeBoundary" ] ''
if [[ -e "${config.xdg.configHome}/gh/config.yml" ]]; then
(
TMP_DIR=$(mktemp -d)
trap "rm --force --recursive $TMP_DIR" EXIT
cp "${config.xdg.configHome}/gh/hosts.yml" $TMP_DIR/
export GH_CONFIG_DIR=$TMP_DIR
$DRY_RUN_CMD ${getExe cfg.package} help 2>&1 > $DRY_RUN_NULL
cp $TMP_DIR/hosts.yml "${config.xdg.configHome}/gh/hosts.yml"
)
fi
'';
programs.git.extraConfig.credential = mkIf cfg.gitCredentialHelper.enable programs.git.extraConfig.credential = mkIf cfg.gitCredentialHelper.enable
(builtins.listToAttrs (map (host: (builtins.listToAttrs (map (host:

View file

@ -18,6 +18,7 @@
co: pr checkout co: pr checkout
editor: vim editor: vim
git_protocol: https git_protocol: https
version: '1'
'' ''
} }
''; '';

View file

@ -28,6 +28,7 @@
co: pr checkout co: pr checkout
editor: vim editor: vim
git_protocol: https git_protocol: https
version: '1'
'' ''
} }
''; '';