mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +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:
parent
80679ea507
commit
d1d950841d
3 changed files with 23 additions and 1 deletions
|
@ -126,7 +126,27 @@ in {
|
|||
home.packages = [ cfg.package ];
|
||||
|
||||
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
|
||||
(builtins.listToAttrs (map (host:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
co: pr checkout
|
||||
editor: vim
|
||||
git_protocol: https
|
||||
version: '1'
|
||||
''
|
||||
}
|
||||
'';
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
co: pr checkout
|
||||
editor: vim
|
||||
git_protocol: https
|
||||
version: '1'
|
||||
''
|
||||
}
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue