-
-
Save lorenzleutgeb/239214f1d60b1cf8c79e7b0dc0483deb to your computer and use it in GitHub Desktop.
| #! /usr/bin/env nix-shell | |
| #! nix-shell -i bash -p bash gh | |
| set -eu | |
| # MIT No Attribution (SPDX Identifier: MIT-0) | |
| # | |
| # Copyright 2023-2025 Lorenz Leutgeb, Peder Bergebakken Sundt | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy of this | |
| # software and associated documentation files (the "Software"), to deal in the Software | |
| # without restriction, including without limitation the rights to use, copy, modify, | |
| # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | |
| # permit persons to whom the Software is furnished to do so. | |
| # | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
| # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
| # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
| # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
| # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
| # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| # See <https://gist.github.com/lorenzleutgeb/239214f1d60b1cf8c79e7b0dc0483deb>. | |
| # Will exit non-zero if not logged in. | |
| gh auth status | |
| if [ $# == 1 ] | |
| then | |
| # Pass GitHub login name as commandline argument. | |
| LOGIN=$1 | |
| else | |
| # Default to currently logged in user. | |
| LOGIN=$(gh api user --jq .login) | |
| fi | |
| BASE="gh pr list --repo NixOS/nixpkgs --json id --jq length --limit 2000" | |
| MERGED=$($BASE --author "$LOGIN" --state merged) | |
| REVIEWED=$($BASE --search "reviewed-by:$LOGIN -author:$LOGIN" --state all) | |
| COMMENTED=$($BASE --search "commenter:$LOGIN -reviewed-by:$LOGIN -author:$LOGIN" --state all) | |
| INVOLVED=$($BASE --search "involves:$LOGIN -commenter:$LOGIN -reviewed-by:$LOGIN -author:$LOGIN" --state all) | |
| REVIEWED_SANS_BOT=$($BASE --search "reviewed-by:$LOGIN -author:$LOGIN -author:r-ryantm" --state all) | |
| COMMENTED_SANS_BOT=$($BASE --search "commenter:$LOGIN -reviewed-by:$LOGIN -author:$LOGIN -author:r-ryantm" --state all) | |
| INVOLVED_SANS_BOT=$($BASE --search "involves:$LOGIN -commenter:$LOGIN -reviewed-by:$LOGIN -author:$LOGIN -author:r-ryantm" --state all) | |
| cat << EOM | |
| ―――――――――― | |
| - [$MERGED PRs merged](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+is%3Amerged+author%3A$LOGIN) | |
| - [$REVIEWED PRs reviewed](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+reviewed-by%3A$LOGIN+-author%3A$LOGIN) | |
| - [$COMMENTED PRs otherwise commented](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+commenter%3A$LOGIN+-reviewed-by%3A$LOGIN+-author%3A$LOGIN) | |
| - [$INVOLVED PRs otherwise involved](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+involves%3A$LOGIN+-commenter%3A$LOGIN+-reviewed-by%3A$LOGIN+-author%3A$LOGIN) | |
| - [$REVIEWED_SANS_BOT PRs reviewed](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+reviewed-by%3A$LOGIN+-author%3A$LOGIN+-author%3Ar-ryantm) not opened by \`@r-ryantm\` | |
| - [$COMMENTED_SANS_BOT PRs otherwise commented](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+commenter%3A$LOGIN+-reviewed-by%3A$LOGIN+-author%3A$LOGIN+-author%3Ar-ryantm) not opened by \`@r-ryantm\` | |
| - [$INVOLVED_SANS_BOT PRs otherwise involved](https://github.com/NixOS/nixpkgs/issues?q=is%3Apr+involves%3A$LOGIN+-commenter%3A$LOGIN+-reviewed-by%3A$LOGIN+-author%3A$LOGIN+-author%3Ar-ryantm) not opened by \`@r-ryantm\` | |
| EOM |
How about adding the nix-shell headers ? :)
I tried to do that (also before you commented :P), but get:
error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'shell'
whose name attribute is located at /nix/store/ld2hqh00hjm7ixi8ylqv2i4kkxxnydsp-nixos-20.09.2674.a058d005b3c/nixos/pkgs/build-support/trivial-builders.nix:7:7
… while evaluating attribute 'buildInputs' of derivation 'shell'
at /nix/store/ld2hqh00hjm7ixi8ylqv2i4kkxxnydsp-nixos-20.09.2674.a058d005b3c/nixos/pkgs/stdenv/generic/make-derivation.nix:221:11:
220| depsHostHost = lib.elemAt (lib.elemAt dependencies 1) 0;
221| buildInputs = lib.elemAt (lib.elemAt dependencies 1) 1;
| ^
222| depsTargetTarget = lib.elemAt (lib.elemAt dependencies 2) 0;
error: undefined variable 'gh'
at «string»:1:114:
1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (bash) (gh) ]; } ""
|
How about adding the nix-shell headers ? :)
I tried to do that (also before you commented :P), but get:
error: … while calling the 'derivationStrict' builtin at /builtin/derivation.nix:9:12: (source not available) … while evaluating derivation 'shell' whose name attribute is located at /nix/store/ld2hqh00hjm7ixi8ylqv2i4kkxxnydsp-nixos-20.09.2674.a058d005b3c/nixos/pkgs/build-support/trivial-builders.nix:7:7 … while evaluating attribute 'buildInputs' of derivation 'shell' at /nix/store/ld2hqh00hjm7ixi8ylqv2i4kkxxnydsp-nixos-20.09.2674.a058d005b3c/nixos/pkgs/stdenv/generic/make-derivation.nix:221:11: 220| depsHostHost = lib.elemAt (lib.elemAt dependencies 1) 0; 221| buildInputs = lib.elemAt (lib.elemAt dependencies 1) 1; | ^ 222| depsTargetTarget = lib.elemAt (lib.elemAt dependencies 2) 0; error: undefined variable 'gh' at «string»:1:114: 1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (bash) (gh) ]; } "" |
nixos-20.09
That's a very old release, please update. (the package was called github-cli back then but now it's a alias)
If you're using flakes or something else instead of channels add this to your config and remove the nix-channels
environment.etc."nix/inputs/nixpkgs".source = pkgs.path;
nix.nixPath = [ "nixpkgs=/etc/nix/inputs/nixpkgs" ];
Once you use the lines advised by @Artturin, use the
replas such:nix repl "/etc/nix/inputs/nixpkgs"
No need to use that since NIX_PATH is set
nix repl --file "<nixpkgs>" works
If you want to use the flake then pin the registry too
nix.registry = {
nixpkgs.to = {
type = "path";
path = pkgs.path;
};
};nix repl nixpkgs (flake repl is currently a experimental feature)
That doesn't work here...
❯ nix repl --file "<nixpkgs>"
Welcome to Nix 2.17.0. Type :? for help.
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
at «none»:0: (source not available)
That doesn't work here...
❯ nix repl --file "<nixpkgs>" Welcome to Nix 2.17.0. Type :? for help. warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I) at «none»:0: (source not available)
Did you relogin so the env var gets updated
Nope... trying.
It works! Thanks once again !
Great work @lorenzleutgeb ! Works very nicely for me !
@lorenzleutgeb Maybe add a link this gist as a reference to the source in the script?
@lorenzleutgeb is this licensed? I am adding it to Nixpkgs but unsure about what license to put.
i think we should also look at involves:, since not all review efforts take the form of reviewed-by:.
proposed change in https://gist.github.com/pbsds/7af827a53c103cd3d40902f9b0b21843
@pbsds I have added most of your changes. Thanks! To answer @ethancedwards8's question, I would like to license as MIT-0, @pbsds would you be okay with that, since it now also carries your work?
👍
How about adding the nix-shell headers ? :)
I think this is just enough: