Motivation
After a few small dissatisfactions from nixpkgs-patcher by @gepbird, and after encountering substantial issues with nix-patcher, I created a setup that avoids many of the drawbacks of the above two solutions.
This solution is based upon a periodic GH action that runs on your fork of Nixpkgs. It updates a branch on your fork called channel/personal-stable (name can be changed of course) with commits from PRs listed in the GH action’s workflow yml file. With this branch, you can use the following in your NixOS flake.nix:
inputs.nixpkgs.url = "https://github.com/$GITHUB_NAMESPACE/nixpkgs/channel/personal-stable
Full Details & Instructions
- Create a
channel/fork-masterbranch on your fork:
git checkout master
# Assuming branch `master` follows `origin/master` and `origin` is `NixOS/nixpkgs`:
git pull
git checkout -b channel/fork-master
# Assuming $GITHUB_NAMESPACE is the remote name for your fork:
git push -u $GITHUB_NAMESPACE
- Now add the workflow file. Use the following as a basis (put yours in the same directory as well):
- Commit the above file to the already checked out
channel/fork-masterbranch, and push it. - Make
channel/fork-masterthe default branch of your fork. Use the link:https://github.com/$GITHUB_NAMESPACE/nixpkgs/settings. nix flake updateyour NixOS configurations repository’sflake.lockfile pointing to yourchannel/personal-stablebranch.
Implementation Details
- This workflow implementation uses the hash and date of the
nixos-unstablebranch on the fork to decide whether to apply the PRs’ commits to thechannel/personal-stablebranch. - The above means that if the
nixos-unstablebranch on the fork is pointing to the same commit asnixos-unstableon theNixOSnamespace, thechannel/personal-stablebranch won’t be updated at all. - To force the workflow to update the
channel/personal-stablebranch, you can use this action:
Which is also triggered by editing the PR_URLS list in the update-personal-stable.yml, once pushed to the channel/fork-master branch.
Related Discussions:
- Including nixpkgs PRs for your system has never been easier!
- GitHub - gepbird/nixpkgs-patcher: Using nixpkgs pull requests that haven't landed into your channel has never been easier!
- Every `nix search nixpkgs` causes copying the patched nixpkgs to `/nix/store`? · Issue #9 · gepbird/nixpkgs-patcher · GitHub
With nix-patcher I encountered substantial issues I didn’t bother reporting as it seems the project as abandoned.