From ca61200807fa6aceb07346ebf45e06d47f7c114b Mon Sep 17 00:00:00 2001 From: teutat3s Date: Wed, 31 May 2023 20:53:16 +0200 Subject: [PATCH] teutat3s: mnx: add prr, github API token, mnx git config Cleanup unused zshrc --- hosts/dumpyourvms/dumpyourvms.nix | 7 ++ .../prr-remote-origin-trailing-slash.patch | 13 +++ overlays/prr.nix | 32 ++++++ secrets/github-api-token.age | 13 +++ secrets/secrets.nix | 1 + users/teutat3s/.config/git/config.nix | 5 + users/teutat3s/.config/git/config_mnx.nix | 9 ++ users/teutat3s/home.nix | 4 + users/teutat3s/mnx.nix | 1 + users/teutat3s/zshrc.nix | 105 ------------------ 10 files changed, 85 insertions(+), 105 deletions(-) create mode 100644 overlays/prr-remote-origin-trailing-slash.patch create mode 100644 overlays/prr.nix create mode 100644 secrets/github-api-token.age create mode 100644 users/teutat3s/.config/git/config_mnx.nix delete mode 100644 users/teutat3s/zshrc.nix diff --git a/hosts/dumpyourvms/dumpyourvms.nix b/hosts/dumpyourvms/dumpyourvms.nix index f4c01e5a..0af3b04f 100644 --- a/hosts/dumpyourvms/dumpyourvms.nix +++ b/hosts/dumpyourvms/dumpyourvms.nix @@ -20,6 +20,13 @@ in { owner = "teutat3s"; }; + age.secrets.github-api-token = { + file = "${self}/secrets/github-api-token.age"; + mode = "600"; + owner = "teutat3s"; + path = "/home/${psCfg.user.name}/.local/share/github/api-token"; + }; + pub-solar = { audio.mopidy.enable = lib.mkForce false; core.hibernation = { diff --git a/overlays/prr-remote-origin-trailing-slash.patch b/overlays/prr-remote-origin-trailing-slash.patch new file mode 100644 index 00000000..5eadba80 --- /dev/null +++ b/overlays/prr-remote-origin-trailing-slash.patch @@ -0,0 +1,13 @@ +diff --git a/lib/prr.js b/lib/prr.js +index f654142..c1b0e41 100755 +--- a/lib/prr.js ++++ b/lib/prr.js +@@ -133,7 +133,7 @@ function determineGitRepo(args, cb) { + return; + } + +- var url = stdout.replace(/\n/, ''); ++ var url = stdout.replace(/\/?\n/, ''); + var gitUser = ''; + var gitRepoName = ''; + diff --git a/overlays/prr.nix b/overlays/prr.nix new file mode 100644 index 00000000..3765cbcd --- /dev/null +++ b/overlays/prr.nix @@ -0,0 +1,32 @@ +final: prev: { + prr = prev.buildNpmPackage { + pname = "prr"; + version = "unstable-2022-06-05"; + + src = prev.fetchFromGitHub { + owner = "TritonDataCenter"; + repo = "prr"; + rev = "bfbce27d955b6b75729ef647cec9f81dc04fea3c"; + hash = "sha256-Z5sKddpHmSJxzacMOuDOxMxBpjApS7FWCWRelHMi/4g="; + }; + + npmDepsHash = "sha256-wVh3WCuUn9l/gILx25tgxTwtwH0Q19lpXTU8gOHWsCg="; + + patches = [./prr-remote-origin-trailing-slash.patch]; + + dontBuild = true; + installPhase = '' + npmInstallHook + + mkdir -p $out/bin + ln -s $out/lib/node_modules/prr/bin/prr $out/bin/prr + ''; + + meta = with prev.lib; { + homepage = "https://github.com/TritonDataCenter/prr"; + description = "Tooling to assist with GitHub pull requests"; + platforms = ["x86_64-linux"]; + maintainers = with maintainers; [teutat3s]; + }; + }; +} diff --git a/secrets/github-api-token.age b/secrets/github-api-token.age new file mode 100644 index 00000000..bed19418 --- /dev/null +++ b/secrets/github-api-token.age @@ -0,0 +1,13 @@ +age-encryption.org/v1 +-> ssh-ed25519 Wp/X/Q CO4vIjn5gn0a8UIGQ8pTtd3bLimnlvXXFVHrIdvhhzE +vZT3aoWvnK4aPMR+yZn8hJ63F/1Ga7xx6Nq8UN4bsIM +-> ssh-ed25519 8U1+ng Nu+OuQ0jipmVBhUL5aJzgRYIP711yH9A/UwNxDCt8i0 +YW38h5abfi8EKnTrE4sLUAd5i+u4+qNno/Wzy9CReHM +-> ssh-ed25519 BVsyTA +um+6g0wccymBjOdKJs2FR58ReTClufGPFyHgQwR/RA +/Cv2hCYaV1E4dgzXY2oFyXhQt/m/u4KUaBByIv8Wfn8 +-> piv-p256 xGzyzw Ar9I/qIkystt/yiYJHut4D94ERTP1ZTh3WRBpV1cvZ1r +UjUpz3egN/5N4n/xabKy3DE/8rLWDsYGWgB4IE5BFxk +-> 7-grease aAc9hT yzd(M6l 1j> @y>y +iNZSjN0 +--- 2dlb9E0gTnsnkTNEK45p5/bSHDhp53Ni+J86mJYgRnY +3r$Aw,3WzLŝ66H eRX~x)g"'{4#igoQ \ No newline at end of file diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 044bd9da..89f4c488 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -12,6 +12,7 @@ let in { "example-secret.age".publicKeys = allKeys; "environment-secrets.age".publicKeys = allKeys; + "github-api-token.age".publicKeys = allKeys; "fwknoprc.age".publicKeys = allKeys; "cat-testenv.ovpn.age".publicKeys = allKeys; "docker-ci-runner-secrets.age".publicKeys = allKeys; diff --git a/users/teutat3s/.config/git/config.nix b/users/teutat3s/.config/git/config.nix index c3abe3df..c11cc60d 100644 --- a/users/teutat3s/.config/git/config.nix +++ b/users/teutat3s/.config/git/config.nix @@ -21,6 +21,11 @@ in [includeIf "gitdir:~/CodeRoom/greenbaum.cloud/"] path = ~/.config/git/config_greenbaum.cloud + [includeIf "gitdir:~/CodeRoom/github.com/TritonDataCenter/"] + path = ~/.config/git/config_mnx + [includeIf "gitdir:~/CodeRoom/github.com/mnx-solutions/"] + path = ~/.config/git/config_mnx + [includeIf "gitdir:~/CodeRoom/git.b12f.io/"] path = ~/.config/git/config_git.b12f.io [includeIf "gitdir:~/CodeRoom/git.pub.solar/"] diff --git a/users/teutat3s/.config/git/config_mnx.nix b/users/teutat3s/.config/git/config_mnx.nix new file mode 100644 index 00000000..b12aa0f3 --- /dev/null +++ b/users/teutat3s/.config/git/config_mnx.nix @@ -0,0 +1,9 @@ +{ + config, + pkgs, + ... +}: let +in '' [user] + name = Jhonas Wernery + email = jhonas.wernery@mnxsolutions.com + signingkey = 9C1D348ACDAFB311'' diff --git a/users/teutat3s/home.nix b/users/teutat3s/home.nix index 15bae983..32f28a17 100644 --- a/users/teutat3s/home.nix +++ b/users/teutat3s/home.nix @@ -45,6 +45,10 @@ in { inherit config; inherit pkgs; }; + xdg.configFile."git/config_mnx".text = import ./.config/git/config_mnx.nix { + inherit config; + inherit pkgs; + }; xdg.configFile."git/config_git.b12f.io".text = import ./.config/git/config_git.b12f.io.nix { inherit config; inherit pkgs; diff --git a/users/teutat3s/mnx.nix b/users/teutat3s/mnx.nix index 52d6873f..001fab09 100644 --- a/users/teutat3s/mnx.nix +++ b/users/teutat3s/mnx.nix @@ -27,6 +27,7 @@ in { home.packages = with pkgs; [ zoom-us slack + prr ]; }; }; diff --git a/users/teutat3s/zshrc.nix b/users/teutat3s/zshrc.nix deleted file mode 100644 index a677c67e..00000000 --- a/users/teutat3s/zshrc.nix +++ /dev/null @@ -1,105 +0,0 @@ -{ - config, - pkgs, - tritonshell, - ... -}: '' - bindkey "^[[1;3D" backward-word - bindkey "^[[1;3C" forward-word - bindkey "^[p" backward-word - bindkey "^[n" forward-word - - # make cursor jump to slash, period, dash, underscore, dollar sign, equals sign - # by default: export WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' - export WORDCHARS='*?[]~&;!#$%^(){}' - - # Alt+Backspace stops at / - bindkey "^[^?" backward-kill-word - backward-kill-dir () { - local WORDCHARS=''${WORDCHARS/\/} - zle backward-kill-word - } - zle -N backward-kill-dir - bindkey '^[^?' backward-kill-dir - - # git aliases - alias ga="git add" - alias gau="git add --update" - alias gb="git branch" - alias gbd="git branch --delete" - alias gc="git commit" - alias gcm="git commit --message" - alias gco="git checkout" - alias gcob="git checkout -b" - alias gd="git diff" - alias gm="git merge" - alias gma="git merge --abort" - alias gmc="git merge --continue" - alias gp="git pull" - alias gs="git status" - - # misc aliases - alias zshconfig="vim ~/.zshrc" - alias zshhistory="vim $XDG_DATA_HOME/zsh/zsh_history" - alias zshsource="source ~/.zshrc" - - alias tp="triton profile set" - alias tt="triton" - alias ttco="triton-compose" - alias tf="terraform" - - alias dstart="sudo systemctl start docker" - alias dstop="sudo systemctl stop docker" - alias lvstart="sudo systemctl start libvirtd" - alias lvstop="sudo systemctl stop libvirtd" - - - alias wg-up="sudo systemctl start wg-quick@wg0.service" - alias wg-down="sudo systemctl stop wg-quick@wg0.service" - - # Helper function for docker on triton - ttp() { - if [[ "$1" == "set" ]]; then - if [[ -n "$2" ]]; then - source ${tritonshell.packages.${pkgs.system}.triton-utils}/bin/unset-env.sh - triton profile set "$2" - fi - source ${tritonshell.packages.${pkgs.system}.triton-docker-env}/bin/triton-docker-env.sh - elif [[ "$1" == "unset" ]]; then - source ${tritonshell.packages.${pkgs.system}.triton-utils}/bin/unset-env.sh - elif [[ "$1" == "env" ]]; then - env | grep "DOCKER\|MANTA\|SDC\|TRITON" | sort - else - echo "this is a helper function to quickly switch triton profiles" - echo "and setup the required environment variables" - echo "for triton, manta and the remote docker host (API)" - echo - echo 'use "ttp set your-profile" to switch to a profile' - echo - echo 'use "ttp unset" to clear all environment variables used by these CLIs' - echo "useful if you'd like to run a docker command against the" - echo "local docker host" - echo - echo 'use "ttp env" to view the currently set environment variables' - echo "used by the triton & manta CLIs" - echo - echo 'use "ttp help" to view this help' - fi - } - - # remove @machine from prompt - DEFAULT_USER=$(whoami) - - # autocomplete cd .. - zstyle ':completion:*' special-dirs true - - autoload -U +X bashcompinit && bashcompinit - complete -o nospace -C ${pkgs.consul}/bin/consul consul - complete -o nospace -C ${pkgs.nomad_1_4}/bin/nomad nomad - complete -o nospace -C ${pkgs.vault}/bin/vault vault - complete -o nospace -C ${pkgs.terraform}/bin/terraform terraform - complete -o nospace -C ${pkgs.waypoint}/bin/waypoint waypoint - complete -C '${pkgs.awscli2}/bin/aws_completer' ${pkgs.awscli2}/bin/aws - - source ${config.age.secrets.environment-secrets.path} -''