Skip to content

Instantly share code, notes, and snippets.

@b-rodrigues
Created October 1, 2024 05:30
Show Gist options
  • Save b-rodrigues/06d2fac15c80b7b6bc8495a935fe4281 to your computer and use it in GitHub Desktop.
Save b-rodrigues/06d2fac15c80b7b6bc8495a935fe4281 to your computer and use it in GitHub Desktop.
Testing PRs for Nixpkgs
# How to test packages to be included in nixpkgs
Thank you for helping us test packages to be included in nixpkgs!
If you want to test a PR, first, you need to fork the nixpkgs
Repository.
To follow along, you first need to have Nix installed on your system.
I recommend the installer from Determinate Systems, which you can find
here: https://github.com/DeterminateSystems/nix-installer
Simply run:
```
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```
in a terminal (Linux, macOS, or WSL2 if on Windows) to use it.
# Fork nixpkgs repository
Go to https://github.com/NixOS/nixpkgs and fork it.
# Clone your fork locally
On your machine, clone the nixpkgs repo. It is massive, so it’ll
take some time (make sure to clone the ssh link, not http, as
shown in the command line below):
```
git clone [email protected]:YOUR_USERNAME/nixpkgs.git
```
# Add the PR author’s fork as a remote
Now, because you want to review a PR, you also need to add
the fork of the PR’s author as a remote. Let’s suppose you
want to review this PR: https://github.com/NixOS/nixpkgs/pull/345140
To add the author’s for as a remote, use the following:
```
cd nixpkgs # move into the right folder: all the next commands should be run in there
git remote add detroyejr https://github.com/detroyejr/nixpkgs
```
(`detroyejr` is the author’s handle on Github). You can now check
your remotes:
```
git remote -v
```
You should at the very least see `origin` and `detroyejr`.
# Checkout out the right branch
We now need to checkout the branch that was used to open the PR. If you look at the PR,
you’ll see that the branch is `positron`, so to check it out, first fetch `detroyejr`’s
branches:
```
git fetch detroyejr
```
then checkout the branch:
```
git checkout detroyejr/positron
```
You are now ready to test building the package! In this example, the package
that interests us is `positron` so run the following in your terminal
(still from the `nixpkgs` folder):
- First, allow building nonfree software as Positron’s license is nonfree (albeit
source-available):
```
export NIXPKGS_ALLOW_UNFREE=1
```
- then, run the following to install the required software and test it:
```
nix-shell -I nixpkgs=. -p R positron python312Packages.polars python312Packages.ipykernel
```
Once the build process is done, you should be dropped inside of a Nix shell. Run Positron
by typing `positron` in it and give it a shot!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment