mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 21:29:48 +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
3dfe0c7602
commit
6ea6f0fbbb
3 changed files with 23 additions and 1 deletions
|
@ -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:
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
co: pr checkout
|
co: pr checkout
|
||||||
editor: vim
|
editor: vim
|
||||||
git_protocol: https
|
git_protocol: https
|
||||||
|
version: '1'
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
co: pr checkout
|
co: pr checkout
|
||||||
editor: vim
|
editor: vim
|
||||||
git_protocol: https
|
git_protocol: https
|
||||||
|
version: '1'
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue