Hello everyone!
It’s my first post here and I very recently on boarded Nix and NixOS, so please be patient if I miss something obvious.
What I am trying to achieve is the following:
Use a flake in a GitHub repo to declare the whole state and configuration of my infrastructure (currently 1 raspberry pi and 2 VPSs), with the ability to reconfigure or build disk images for each of the machine.
To automate partitioning and image creation I decided use “disko” from nix-community.
Everything is working flawlessly and I love that setup!
Now my problems arise from the fact that I couldn’t resist from the temptation to fork nixpkgs and make some changes to nixos core modules. Let’s say for instance that these two changes resulted in two PRs on github (branch feature1 and feature2 in my nixpkgs fork).
I would like to keep feature1 and feature2 rebased to nixpkgs master upstream, but at the same time use these features in my infrastructure (following nixos-unstable).
For the moment the only viable workflow I found is to periodically run the following:
- Clone my nixpkgs fork locally
- Rebase fork/feature1 and fork/feature2 to upstream/master and force push (to keep in sync for PRs)
- Checkout upstream/nixos-unstable
- Create and checkout branch fork/infra-production
- Cherry-pick all commits between master…feature1 and between master…feature2
- Force push fork/infra-production
- Use fork/infra-production as nixpkgs input in my flake.nix
This seems incredibly inefficient and tedious! As an alternative, I considered creating a patches/ folder in my infra flake repositories, where to add a feature1.patch and feature2.patch file, then create a patched-nixpkgs derivation using the applyPatches function in flake.nix.
However, this approach runs into issues because my flake.nix has a second input, “disko”, whose input is set to follow the version of nixpkgs in my flake. It would continue to use the “unpatched” version, while I want to use the patched nixpkgs as input for the disko flake!
So here’s my question: Is there any way to completely “replace” nixpkgs with its patched version without creating a new nixpkgs branch? And if creating a new nixpkgs branch is really necessary, is there a more efficient way to do it (like using git shallow clones)?
Sorry for that long first post and huge thanks to the wonderful Nix community!