home/git: properly set url overrides and includes
This commit is contained in:
parent
2532fef033
commit
cd508d5337
|
@ -9,6 +9,18 @@
|
|||
"github" = {
|
||||
user = "git";
|
||||
hostname = "github.com";
|
||||
identityFile = [ "~/.ssh/id_ed25519" ];
|
||||
};
|
||||
"github-nordicsemi" = {
|
||||
user = "git";
|
||||
hostname = "github.com";
|
||||
identityFile = [ "~/.ssh/id_ed25519_nordicsemi" ];
|
||||
};
|
||||
"bitbucket-nordicsemi" = {
|
||||
user = "git";
|
||||
hostname = "bitbucket.nordicsemi.no";
|
||||
port = 7999;
|
||||
identityFile = [ "~/.ssh/id_ed25519_nordicsemi" ];
|
||||
};
|
||||
"gitlab.stud.idi.ntnu.no" = {
|
||||
user = "git";
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.git;
|
||||
|
||||
github-uri-prefixes = [
|
||||
# Preferred
|
||||
"github:"
|
||||
|
||||
# Alternative
|
||||
"https://github.com/"
|
||||
"ssh://git@github.com:"
|
||||
"git@github.com:"
|
||||
"github.com:"
|
||||
];
|
||||
in
|
||||
{
|
||||
programs.git = {
|
||||
# TODO: convert to template once nix-sops supports it in hm module
|
||||
sops.secrets."git/nordicsemi-config" = { };
|
||||
|
||||
programs.git = lib.mkMerge [
|
||||
{
|
||||
enable = true;
|
||||
package = pkgs.gitFull;
|
||||
|
||||
|
@ -117,20 +132,7 @@ in
|
|||
|
||||
github.user = "h7x4";
|
||||
|
||||
"url \"github:\"".insteadOf = [
|
||||
"https://github.com/"
|
||||
"ssh://git@github.com:"
|
||||
"git@github.com:"
|
||||
"github.com:"
|
||||
];
|
||||
|
||||
"url \"pvv-git:\"".insteadOf = [
|
||||
"https://git.pvv.org/"
|
||||
"ssh://gitea@git.pvv.ntnu.no:2222/"
|
||||
"gitea@git.pvv.ntnu.no:2222/"
|
||||
"gitea@git.pvv.ntnu.no:"
|
||||
"git.pvv.ntnu.no:"
|
||||
];
|
||||
"url \"${lib.head github-uri-prefixes}\"".insteadOf = lib.tail github-uri-prefixes;
|
||||
|
||||
web.browser = "google-chrome-stable";
|
||||
|
||||
|
@ -148,7 +150,77 @@ in
|
|||
".envrc"
|
||||
"shell.nix"
|
||||
];
|
||||
}
|
||||
|
||||
(let
|
||||
uri-prefixes = [
|
||||
# Preferred
|
||||
"pvv-git:"
|
||||
|
||||
# Alternative
|
||||
"https://git.pvv.org/"
|
||||
"ssh://gitea@git.pvv.ntnu.no:2222/"
|
||||
"gitea@git.pvv.ntnu.no:2222/"
|
||||
"gitea@git.pvv.ntnu.no:"
|
||||
"git.pvv.ntnu.no:"
|
||||
];
|
||||
|
||||
prefixes-per-org = let
|
||||
organizations = [
|
||||
"Drift"
|
||||
"Projects"
|
||||
];
|
||||
in lib.genAttrs organizations (org: map (uri-prefix: "${uri-prefix}${org}") uri-prefixes);
|
||||
in {
|
||||
extraConfig."url \"${lib.head uri-prefixes}\"".insteadOf = lib.tail uri-prefixes;
|
||||
|
||||
includes = map (x: {
|
||||
contentSuffix = "pvv.gitconfig";
|
||||
condition = "hasconfig:remote.*.url:${x}**";
|
||||
contents = {
|
||||
user = {
|
||||
email = "oysteikt@pvv.ntnu.no";
|
||||
name = "Øystein Tveit";
|
||||
};
|
||||
};
|
||||
}) (lib.flatten (lib.attrValues prefixes-per-org));
|
||||
})
|
||||
|
||||
(let
|
||||
bitbucket-uri-prefixes = [
|
||||
# Preferred
|
||||
"bitbucket-nordicsemi:"
|
||||
|
||||
# Alternative
|
||||
"ssh://git@bitbucket.nordicsemi.no:7999"
|
||||
"https://projecttools.nordicsemi.no/bitbucket/scm"
|
||||
];
|
||||
|
||||
prefixes-per-org = let
|
||||
organizations = [
|
||||
"NordicSemiconductor"
|
||||
"NordicPlayground"
|
||||
"nrfconnect"
|
||||
];
|
||||
in lib.genAttrs organizations (org: map (uri-prefix: "${uri-prefix}${org}") github-uri-prefixes);
|
||||
in {
|
||||
extraConfig = lib.mergeAttrs
|
||||
{
|
||||
"url \"${lib.head bitbucket-uri-prefixes}\"".insteadOf = lib.tail bitbucket-uri-prefixes;
|
||||
}
|
||||
(lib.mapAttrs' (org: uri-prefixes: {
|
||||
name = "url \"github-nordicsemi:${org}\"";
|
||||
value.insteadOf = uri-prefixes;
|
||||
}) prefixes-per-org)
|
||||
;
|
||||
|
||||
includes = map (x: {
|
||||
contentSuffix = "nordicsemi.gitconfig";
|
||||
condition = "hasconfig:remote.*.url:${x}/**";
|
||||
path = config.sops.secrets."git/nordicsemi-config".path;
|
||||
}) (bitbucket-uri-prefixes ++ (lib.flatten (lib.attrValues prefixes-per-org)));
|
||||
})
|
||||
];
|
||||
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
git:
|
||||
nordicsemi-config: ENC[AES256_GCM,data:ziuM41RTsxkiutxjj8Pl5YuoETkxQNWEbGKd2Y99E0kTV9fL67g+YeGjeVFXErraeB/+jBVpjitK3lSHxlpxZLWckZ0G6A7NAFNagY9cORCFlLb+egyKb44xu8vBt4V5eA==,iv:yG06oluENc038cm5A9tpmSQtaGjd6nYDi/FnBd3A8Rk=,tag:ky6bCsYLOZmWObHnJ816Zw==,type:str]
|
||||
ssh:
|
||||
secret-config: ENC[AES256_GCM,data:HFrGyBiqNJJOzWhoDBosh7Kub7zz2cJvE6FphapqFeZ3ZNqG27nVu6G9JsLiIZBtsSgBcne0WEV+vNY07d6QBHX/IHryNczhrIEkiI9yNBORBvIOVLS9J4bP/ueUBn4EmLVBQ5tW5/s+0RNSTw==,iv:6bhpPR5QjnnO44p0NCjXl9P/TVP+Tdi61gU3RddNCIU=,tag:QAWcPbwAW1Fmue7CzFWF8w==,type:str]
|
||||
secret-config: ""
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
|
@ -15,8 +17,8 @@ sops:
|
|||
QllyaVlIVEVrSlJDZzlwdFpoRlg3bmsKYBGLYmsfFu6GuRUPGsS0+vkUv1QzJXZl
|
||||
D9CFcRQw0Xzti0DvDj7cWrCJ32F1eYRp/9LWyG1CEjfoNEKyUJZ2qQ==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-07-08T12:56:35Z"
|
||||
mac: ENC[AES256_GCM,data:NOs6g8PKDBwbimZLumnde2ohhxRKxajORZMI1kraLgbow8uFUO9CreEMz5epRFMqesClFuWQXJfpki9dxONYs4zsIaPjuZWi9a1d3eUf+AGw5Ey6GKEh5z/oSQkfK3CCYH9g9E+iOeK8eCHPMYAwAPSyxCBumEoIuwOrUlgdGlQ=,iv:vXWOqw4ZPZkMktuKU5WmA8AAsBniyxbjfVaI+9TpH9M=,tag:MmHBM527T8egbIvpUNPiuQ==,type:str]
|
||||
lastmodified: "2024-07-08T13:25:35Z"
|
||||
mac: ENC[AES256_GCM,data:JUYECqv5+wtAhDWr+2pNSh/EXhh/gjjUFCjC6oH+3cXpZHacg23S/D5ol6nIXKH1+XUFaIX10YQOC0WaciZUcfgCP4t01MJRB3OE1iYcGllyeP+9gEIKfoeEajHVQdYWZHUql7T4EnQWs74uHiF7nt6jALnp98Wc4Pny6xvvZds=,iv:gDr7O566etB9oYAJB1RIK1PQJIc1NVcIlhZISidVmlA=,tag:bQ1iC1Xi5A+VbBgunHt02w==,type:str]
|
||||
pgp:
|
||||
- created_at: "2024-07-08T12:27:24Z"
|
||||
enc: |-
|
||||
|
|
Loading…
Reference in New Issue