Install new version of service not in nixpkgs

I cloned nixpkgs to update the version of a service. I submitted a PR. I would like to test the new derivation system-wide.

I did a nix-env -f ~/my-nixpkgs-fork -iA myservice which built successfully. I end up with some new binaries for myservice in PATH which I can verify are the new version. But if I then add services.myservice = { enable = true; } in my /etc/nixos/configuration.nix and do a nixos-rebuild switch, the old version is launched. What am I missing?

If the services module has a package option, make that point to your changed derivation.

If it doesn’t, use an overlay to replace the original with your changes.

1 Like

Thanks. I set up an overlay in configuration.nix like so:

nixpkgs.overlays = [ ( 
final: prev: { dendrite = "/nix/store/adlxxwshqhwyz1pq8i76n1qribn4klv1-matrix-dendrite-0.6.0" }
) ];

This seems to update the service unit file and launch the new version. However I made changes not only to nixpkgs/pkgs but also nixpkgs/nixos/modules/services, changing some defaults in the service config options. These do not seem to propagate into a config file for the service though, and so the service fails to start due to bad config. I imagine I need something else in the overlay.

Or maybe this method is incorrect, I don’t see any examples of using the nix store path directly like this in overlays.

You usualy do not paste the store path directly, but instead use an expression that is equivalent to the changes you did in our fork, either by copying the relevant parts of the expression or by importing it or if thats enough, using override/overrideAttrs.

To replace the original module with the changes you made, you need to apply the technique used in NixOS - NixOS 21.11 manual with something that refers to your locally changed module.

We tend to have those changes as a sibling to the configuration until they got upstreamed properly, if at all.

An alternative, is not not do any of these but instead use the local clone/fork of nixpkgs as the systems base by pointing the nixos NIX_PATH entry to it. Unless you upstream your changes, this will require a lot of work by you to keeo that fork updated. Though I know some people who work that way.

Thanks. Using the example from the manual (disabledModules and imports) is working perfectly.