How to try a package from a PR that's not yet merged?

I am trying to get 6DOF tracking to work on my HP Reverb G2 VR Headset. But it seems like it requires a package named basalt, there’s a PR for it but it’s not merged yet

Is there a proper way to try it early?

git cloning and doing nixpkgs-review pr 295107 doesn’t seem to work and throws this

$ git -c fetch.prune=false fetch --no-tags --force master:refs/nixpkgs-review/0 pull/295107/head:refs/nixpkgs-review/1
$ git worktree add /home/user/.cache/nixpkgs-review/pr-295107/nixpkgs b00f19626a7ef8bfb065c087370a32aba634d9b2
Preparing worktree (detached HEAD b00f19626a7e)
Updating files: 100% (41210/41210), done.
HEAD is now at b00f19626a7e Merge pull request #306891 from outlyer-net/fix-vcs-license
$ git merge --no-commit --no-ff d35b64c70ab67d2791da899e4ae77fb48d9e8c52
Auto-merging pkgs/top-level/all-packages.nix
CONFLICT (content): Merge conflict in pkgs/top-level/all-packages.nix
Automatic merge failed; fix conflicts and then commit the result. failed to build: Failed to merge d35b64c70ab67d2791da899e4ae77fb48d9e8c52 into /home/user/.cache/nixpkgs-review/pr-295107/nixpkgs. git merge failed with exit code 1
$ git worktree remove -f /home/user/.cache/nixpkgs-review/pr-295107/nixpkgs

If you just want to try it out: clone nixpkgs, checkout the PR branch with

git fetch upstream pull/295107/head; git checkout FETCH_HEAD

and then build the package with nix-build -A basalt-monado.

If you want to integrate it into your NixOS configuration, it’s trickier but it’s possible.
You can use github to generate patch of the PR and then to apply it to the Nixpkgs source used to build your system:

  nixpkgs.pkgs =
      patched-nixpkgs = pkgs.applyPatches
        { src = pkgs.path;
          patches = lib.singleton (pkgs.fetchpatch
            { url = "";
              hash = "sha256-ORKWmHYPr3zLmgqDXmXnfdQ5ZYVIzSlYhEAxPTeJ0RM=";
      import patched-nixpkgs { inherit (pkgs) config; };

this will build the new package and its dependencies consistently with the other your system.

If the patch doesn’t apply, you can import the whole of Nixpkgs at the point when the PR was made, build the package and then add it into your system:

  environment.systemPackages =
      nixpkgs-basalt = import (builtins.fetchTarball
        { url = "";
          sha256 = "1vy41751c3hryna1qz4gfg3mbq3z7rwc2z8fx777d5c3c3ygx5la";
        }) { };
      [ nixpkgs-basalt.basalt-monado ];

This should build the package exactly as the author of the PR, but it may be slightly incompatible with your system.

1 Like

If you have experimental nix-command enabled, it should also be possible to use:

nix run github:nixos/nixpkgs/pull/295107/head#basalt-monado