• Stars
    star
    383
  • Rank 111,995 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Review pull-requests on https://github.com/NixOS/nixpkgs

nixpkgs-review

Build Status

Review pull-requests on https://github.com/NixOS/nixpkgs. nixpkgs-review automatically builds packages changed in the pull requests.

Features

  • ofborg support: reuses evaluation output of CI to skip local evaluation, but also falls back if ofborg is not finished
  • provides a nix-shell with all packages that did not fail to build
  • remote builder support
  • allows to build a subset of packages (great for mass-rebuilds)
  • allow to build nixos tests
  • markdown reports
  • GitHub integration:
    • post PR comments with results
    • approve or merge PRs (the last one requires maintainer permission)
    • show PR comments/reviews
  • logs per built or failed package
  • symlinks built packages to result directory for inspection

Installation

nixpkgs-review is included in nixpkgs.

To use it without installing it, use:

$ nix run 'nixpkgs#nixpkgs-review'

To run it from the git repository:

$ nix-build
$ ./result/bin/nixpkgs-review

Development Environment

For IDEs:

$ nix-build -A env -o .venv

or just use:

./bin/nixpkgs-review

Usage

First, change to your local nixpkgs repository directory, i.e.:

cd ~/git/nixpkgs

Note that your local checkout git will not be affected by nixpkgs-review, since it will use git-worktree to perform fast checkouts.

Then run nixpkgs-review by providing the pull request number…

$ nixpkgs-review pr 37242

…or the full pull request URL:

$ nixpkgs-review pr https://github.com/NixOS/nixpkgs/pull/37242

The output will then look as follows:

$ git fetch --force https://github.com/NixOS/nixpkgs pull/37242/head:refs/nixpkgs-review/0
$ git worktree add /home/joerg/git/nixpkgs/.review/pr-37242 1cb9f643480612696de93fb2f2a2f3340d0e3156
Preparing /home/joerg/git/nixpkgs/.review/pr-37242 (identifier pr-37242)
Checking out files: 100% (14825/14825), done.
HEAD is now at 1cb9f643480 redis: 4.0.7 -> 4.0.8
Building in /tmp/nox-review-4ml2epyy: redis
$ nix-build --no-out-link --keep-going --max-jobs 4 --option build-use-sandbox true <nixpkgs> -A redis
/nix/store/jbp7m1gshmk8an8sb14glwijgw1chvvq-redis-4.0.8
$ nix-shell -p redis
[nix-shell:~/git/nixpkgs]$ /nix/store/jbp7m1gshmk8an8sb14glwijgw1chvvq-redis-4.0.8/bin/redis-cli --version
redis-cli 4.0.8

To review a local commit without pull request, use the following command:

$ nixpkgs-review rev HEAD

Instead of HEAD a commit or branch can also be given.

To review uncommitted changes, use the following command:

$ nixpkgs-review wip

Staged changes can be reviewed like this:

$ nixpkgs-review wip --staged

If you'd like to post the nixpkgs-review results as a formatted PR comment, pass the --post-result flag:

$ nixpkgs-review pr --post-result 37242

Instead of posting a PR comment, nixpkgs-review can also print the report to the terminal using the --print-result flag. This flag will work for the rev and wip command..

$ nixpkgs-review pr --print-result 37242

Often, after reviewing a diff on a pull request, you may want to say "This diff looks good to me, approve/merge it provided that there are no package build failures". To do so, run the following subcommands from within the nix-shell provided by nixpkgs-review.

$ nixpkgs-review pr 37242
nix-shell> nixpkgs-review approve
# Or, if you have maintainer access and would like to merge (provided no build failures):
nix-shell> nixpkgs-review merge
# It is also possible to upload the result report from here
nix-shell> nixpkgs-review post-result
# Review-comments can also be shown
nix-shell> nixpkgs-review comments

nixpkgs-review will by default use nix-output-monitor if found in $PATH. If you have nom installed but don't want to use it, you can pass nix to --build-graph to use nix build instead of nom build.

Some pull requests may require configuration for nixpkgs to test out. You can use the --extra-nixpkgs-config flag to supply extra configuration for nixpkgs.

$ nixpkgs-review pr 37242 --extra-nixpkgs-config '{ cudaSupport = true; }'

Using nixpkgs-review in scripts or other programs

After building, nixpkgs-review will normally start a nix-shell with the packages built, to allow for interactive testing. To use nixpkgs-review non-interactively in scripts, use the --no-shell command, which can allow for batch processing of multiple reviews or use in scripts/bots.

Example testing multiple unrelated PRs and posting the build results as PR comments for later review:

for pr in 807{60..70}; do
    nixpkgs-review pr --no-shell --post-result $pr && echo "PR $pr succeeded" || echo "PR $pr failed"
done

nixpkgs-review also accepts a --run flag that allows to run a custom command inside the nix-shell instead of an interactive session:

$ nixpkgs-review pr --run 'jq < report.json' 113814
# ...
{
  "blacklisted": [],
  "broken": [],
  "built": [
    "cargo-deny"
  ],
  "failed": [],
  "non-existent": [],
  "pr": 113814,
  "system": "x86_64-linux",
  "tests": []
}

Review multiple pull requests at once

nixpkgs-review accept multiple pull request numbers at once:

$ nixpkgs-review pr 94524 94494 94522 94493 94520

This will first evaluate & build all pull requests in serial. Then a nix-shell will be opened for each of them after the previous shell has been closed.

Tip: Since it's hard to keep track of the numbers, for each opened shell the corresponding pull request URL is shown.

Remote builder

Nixpkgs-review will pass all arguments given in --build-arg to nix-build:

$ nixpkgs-review pr --build-args="--builders 'ssh://[email protected]'" 37244

As an alternative, one can also specify remote builder as usual in /etc/nix/machines or via the nix.buildMachines nixos options in configuration.nix. This allows to parallelize builds across multiple machines.

GitHub api token

Some commands (i.e., post-result or merge) require a GitHub API token, and even for read-only calls, GitHub returns 403 error messages if your IP hits the rate limit for unauthenticated calls.

To use a token, first create a personal access token. If you plan to post comments with the reports generated, you need to add the repo:public_repo scope.

Then use either the GITHUB_TOKEN environment variable or the --token parameter of the pr subcommand.

$ GITHUB_TOKEN=5ae04810f1e9f17c3297ee4c9e25f3ac1f437c26 nixpkgs-review pr  37244

Additionally, nixpkgs-review will also read the oauth_token stored by hub and gh.

Checkout strategy (recommend for r-ryantm + cachix)

By default, nixpkgs-review pr will merge the pull request into the pull request's target branch (most commonly master). However, at times mass-rebuilding commits have been applied in the target branch, but not yet built by hydra. Often those are not relevant for the current review, but will significantly increase the local build time. For this case, the --checkout option can be specified to override the default behavior (merge). By setting its value to commit, nixpkgs-review will checkout the user's pull request branch without merging it:

$ nixpkgs-review pr --checkout commit 44534

Only building a subset of packages

To build only certain packages, use the --package (or -p) flag.

$ nixpkgs-review pr -p openjpeg -p ImageMagick 49262

There is also the --package-regex option that takes a regular expression to match against the attribute name.

# build only linux kernels but not the packages
$ nixpkgs-review pr --package-regex 'linux_' 51292

To skip building certain packages, use the --skip-package (or -P) flag.

$ nixpkgs-review pr -P ImageMagick 49262

There is also the --skip-package-regex option that takes a regular expression to match against the attribute name. Unlike the --package-regex option, a full match is required, which means you probably want to work with .* or \w+.

# skip building linux kernels but not the packages
$ nixpkgs-review pr --skip-package-regex 'linux_.*' 51292

-p, -P, --package-regex and --skip-package-regex can be used together, in which case the matching packages will be merged.

Full documentation for regex matching syntax can be found here.

Running tests

NixOS tests can be run by using the --package feature and our nixosTests attribute set:

$ nixpkgs-review pr -p nixosTests.ferm 47077

Ignoring ofborg evaluations

By default, nixpkgs-review will use ofborg's evaluation result if available to figure out what packages need to be rebuilt. This can be turned off using --eval local, which is useful if ofborg's evaluation result is outdated. Even if using --eval ofborg, nixpkgs-review will fall back to local evaluation if ofborg's result is not (yet) available.

Review changes in personal forks

Both the rev and the wip subcommand support a --remote argument to overwrite the upstream repository URL (defaults to https://github.com/NixOS/nixpkgs). The following example will use mayflower's nixpkgs fork to fetch the branch where the changes will be merged into:

$ nixpkgs-review --remote https://github.com/mayflower/nixpkgs wip

Note that this has been not yet implemented for pull requests, i.e., pr subcommand.

Review changes for other operating systems/architectures

The --system flag allows setting a system different from the current one. Note that the result nix-shell may not be able to execute all hooks correctly since the architecture/operating system mismatches.

$ nixpkgs-review pr --system aarch64-linux 98734

Review changes inside sandbox [EXPERIMENTAL]

The --sandbox flag setups a sandbox using bubblewrap. This is the same tool used by Flatpak and OSTree, and offers an unprivileged sandbox based on user namespaces.

Keep in mind that --sandbox flag is not necessary tuned for privacy or security. Instead, it uses a pretty lax sandbox where it is possible to leak data sensitive by environment variables or stateful filesystems (like /run). The reason for this is because many packages would break otherwise, and this would make this flag useless for review purposes.

The objective of --sandbox is to protect your system against accidental modification and to offer a clean(ish) system state where packages can be tested. For example, it mounts a tmpfs in-place of your HOME directory, avoiding situations where a dirty configuration on your HOME directory can lead to a broken package during testing. It also protects your HOME and system against undesired files created during package testing.

This flag is still in an experimental stage. Please note that it isn't exhaustive tested against nixpkgs, so some packages may break under it. Before disapproving a PR because the program is broken under the sandbox, try without this flag first to make sure that the issue is not the sandbox. If the issue is caused because of the sandbox, please open an issue including the PR number in nixpkgs so we can try to fix this issue.

$ nix-shell -p bubblewrap # or install it using NixOS/Home-Manager/etc.
$ nixpkgs-review --sandbox pr 98734

Roadmap

  • build on multiple platforms
  • test backports
  • show pull request description + diff during review

Run tests

To run tests use:

$ pytest

We also use python3's type hints. To check them, use mypy:

$ mypy nixpkgs_review

Related projects:

  • nox-review:
    • works but is as slow as a snail: the checkout process of nox-review is slow since it requires multiple git fetches. Also it cannot make use of ofborg's evaluation
    • it only builds all packages without providing a nix-shell for review
  • niff:
    • only provides a list of packages that have changed, but does not build packages
    • also needs to evaluate changed attributes locally instead of using ofborg

More Repositories

1

sops-nix

Atomic secret provisioning for NixOS based on sops
Nix
1,439
star
2

cntr

A container debugging tool based on FUSE
Rust
542
star
3

nix-update

Swiss-knife for updating nix packages.
Python
459
star
4

nixos-shell

Spawns lightweight nixos vms in a shell
Nix
423
star
5

nix-ld

Run unpatched dynamic binaries on NixOS
C
422
star
6

python-mpd2

Python library which provides a client interface for the Music Player Daemon.
Python
353
star
7

dotfiles

My NixOS dotfiles
Nix
299
star
8

nix-fast-build

Combine the power of nix-eval-jobs with nix-output-monitor to speed-up your evaluation and building process.
Python
210
star
9

envfs

Fuse filesystem that returns symlinks to executables based on the PATH of the requesting process.
Rust
133
star
10

vmsh

Shell into a virtualized linux, with your own tools
Rust
132
star
11

mina-sidekiq

Tasks to deploy Sidekiq with mina.
Ruby
91
star
12

nix-build-uncached

A CI friendly wrapper around nix-build.
Go
72
star
13

zig.ko

Linux kernel module written in Zig
Makefile
70
star
14

nixos-aarch64-images

Build NixOS images for various ARM single computer boards
Python
49
star
15

x86_64-linux-cheatsheats

Plain files for syscalls, errnos, signals, registers and x86_64 instructions
Python
49
star
16

pry.py

pry.py - an interactive drop in shell for python, similar to binding.pry in ruby
Python
49
star
17

ssh-to-age

Convert SSH Ed25519 keys to age keys. This is useful for usage in sops-nix and sops
Go
47
star
18

hue-ble-ctl

Control your Phillips Hue light bulb over bluetooth
Python
33
star
19

pythonix

Eval nix code from python
C++
32
star
20

awesome-dotfiles

Configuration files of the window manager awesome
Lua
28
star
21

fast-flake-update

Update flake.lock with the latest commit of a local checkout
Python
27
star
22

nur-packages

My personal NUR repository
Nix
23
star
23

flake-linter

Find duplicate dependencies in flakes
Python
18
star
24

ansible-lxc

Ansible Connection Plugin for lxc containers (https://linuxcontainers.org/)
Python
17
star
25

iana-etc

Build /etc/protocols and /etc/services files from IANA's Assigned Internet Protocol Numbers
Python
17
star
26

lognotify

log watcher for awesome wm
Lua
14
star
27

nix-sysdig

Wrapper to debug sysdig builds
Python
13
star
28

github-tags

sinatra app to generate rss feeds with the latest git tags of a project on github
Ruby
12
star
29

nixican-standoff

Benchmark between nix, lix and tvix
Python
12
star
30

whois42d

Whois server for the dn42 registry
Go
11
star
31

ssh-to-pgp

Convert SSH RSA keys to GPG keys
Go
11
star
32

utils

A set of lua modules I use in awesome wm.
Lua
9
star
33

stockholm

Mirror of https://git.thalheim.io/Mic92/stockholm/
Nix
9
star
34

bing-gpt-server

HTML
8
star
35

flake-templates

Personal templates i like to use.
Nix
7
star
36

valauncher

A fast dmenu-like gtk3 application launcher
CMake
7
star
37

dlopen-resolver

Python
7
star
38

openvpn-ddns

Maintain dns records for connecting openvpn clients
Ruby
7
star
39

dream2nix-home-assistant

Packaging experiments with dream2nix to package home-assistant with all dependencies.
Nix
5
star
40

kvm-pirate

Attach to kvm-based VMs
Python
5
star
41

mechanical-keyboards

Configuration of my collections of keyboards
Nix
4
star
42

systemd-ta

http://c3d2.de/news/ta-systemd.html
JavaScript
4
star
43

nix-build-shell

Rust
4
star
44

robolab

Simulator for the course Robolab at TU Dresden
4
star
45

nixos-test-example

Nix
4
star
46

retiolum

Mirror of https://git.thalheim.io/Mic92/retiolum
Nix
4
star
47

server-bookings

Rust
3
star
48

Algebra-I

Das inoffizielle Skript zur Vorlesung bei Prof. Schmidt
Ruby
3
star
49

nix-fmt

abandoned in favor of https://github.com/orivej/go-nix and https://gitlab.com/jD91mZM2/rnix
OCaml
3
star
50

imap-notify

IMAP notifier using IMAP's NOTIFY SET
Python
3
star
51

docker-pid

Resolve container id/name to container's process id
Go
3
star
52

nftables

Mirror of netfilter/nftables
C
3
star
53

nixos-configuration

The content of this repo has been integrated into https://github.com/Mic92/dotfiles/
3
star
54

mpdtools

Usefull tools for MPD: mpdadd - Link and play files outside of the MPD directory to MPD. mpdmark - bookmark songs
Ruby
3
star
55

nsattach

attach to linux namespaces
C
3
star
56

bors-gen-config

Generate bors.toml for github repositories
Python
2
star
57

int3

Better debugger breakpoints
Python
2
star
58

vtune-nix

Vtune nix package
Nix
2
star
59

live-net-info

My adventures using the bubbletea framework.
Go
2
star
60

blog

Source of my blog
Shell
2
star
61

themenabend-nixos

Folien und Code zum Themenabend über Nix/Nixos
JavaScript
2
star
62

lxc-machined-start

Integrate lxc container into machined
M4
2
star
63

company-tmux

emacs auto complete with content of tmux panes
Emacs Lisp
2
star
64

pgp-verify

Verify pgp signatures of files.
Go
2
star
65

build-system-koans

C
2
star
66

SWT_And_Programming

Programs/Stubs created during exercises at university.
Java
2
star
67

mpdstated

Auto restore recent position for each podcast in mpd.
Vala
2
star
68

bme680-mqtt

Publish BME680 sensor data to home-assistant via MQTT
Python
2
star
69

container-pid

Rust crate to resolve a container names/ids to PID
Rust
2
star
70

nixcon2023-nixos-anywhere

Presentation slides for NixCon 2023 presentation on nixos-anywhere
JavaScript
2
star
71

systemd-user-units

2
star
72

nixos-wiki-redirector

JavaScript
2
star
73

disko-yubikey-demo

Nix
2
star
74

scripts

All my tiny scripts and stubs
Shell
1
star
75

lualdap

fork of https://git.zx2c4.com/lualdap/ with lua5.3 support
C
1
star
76

pcap-preload

Rust
1
star
77

nixpkgs-committers

Repository for nominating maintainers for Nixpkgs commit access
1
star
78

mic92.github.com

1
star
79

phd-website

HTML
1
star
80

ports

my freebsd ports
Makefile
1
star
81

drone-convert-nix

Go
1
star
82

webscraping-workshop

Folien und Code zum Webscraping workshop auf den Datenspuren 2015
JavaScript
1
star
83

qtile-config

Python
1
star
84

semeion

A DynDNS Server interface in Haskell and Yesod
Haskell
1
star
85

hadoop-exercise

MapReduce Assignment 2015 at System Engineering II (TU Dresden)
Java
1
star
86

xfstests-cntr

Fork of xfstests with support for cntr
Shell
1
star
87

fuidshift

Move Filesystem ownership into other subordinated uid ranges
Go
1
star
88

android-notifier

Automatically exported from code.google.com/p/android-notifier
Java
1
star
89

fft

FFT Implementation for Tensilica DSP Processors
C
1
star
90

userborn-with-impermanence

Nix
1
star
91

drone-nix-scheduler

Schedule nix jobsets in drone ci
Python
1
star
92

arch-package-feed

bottle.py based project to provide a more advanced arch package feed.
Python
1
star
93

PKGBUILDs

My PKGBUILDs of Packages I maintain in Archlinux AUR
Shell
1
star
94

tracedump

System service to dump Intel processor trace + memory after a crash.
Python
1
star
95

Japanese-sum-solver

A solver for the logic game Japsum
JavaScript
1
star
96

clusterssh

wrapper arround go-ssh to execute commands in a cluster
Go
1
star