No matter what nix you override for nixos-rebuild and its siblings, it'll be overridden again in nixos module https://github.com/NixOS/nixpkgs/blob/89dbf01df72eb5ebe3b24a86334b12c27d68016a/nixos/modules/installer/tools/tools.nix#L70-L76. There's also no way to set the nixos-rebuild package, I suppose this is done to ensure that nix.package option is used.
We have two options:
The first is to only set nix.package and know that it takes precedence because it's the last call to override. However we don't always want this (c.f. #12).
The second option is to hack the override function so that it does the following for a given derivation that uses nix:
- overrides the nix input as nix-monitored
- any override changing the nix input will change that to nix-monitored
I suggest that we update the README so it reflects this when using this project, or just ship this combinator to hack the .override so it does what (I consider) is sane.
Here's the implementation:
use-nix-monitored =
drv:
let
drv' = drv.override { nix = nix-monitored; };
in
drv'
// rec {
override =
args:
let
args' =
if args ? nix then
args
// {
nix = nix-monitored.override { inherit (args) nix; };
}
else
args;
in
(drv'.override args') // { inherit override; };
};
We can then used it as such:
final: prev: {
nixos-rebuild = use-nix-monitored prev.nixos-rebuild;
}
No matter what nix you override for
nixos-rebuildand its siblings, it'll be overridden again in nixos module https://github.com/NixOS/nixpkgs/blob/89dbf01df72eb5ebe3b24a86334b12c27d68016a/nixos/modules/installer/tools/tools.nix#L70-L76. There's also no way to set thenixos-rebuildpackage, I suppose this is done to ensure thatnix.packageoption is used.We have two options:
The first is to only set
nix.packageand know that it takes precedence because it's the last call to override. However we don't always want this (c.f. #12).The second option is to hack the override function so that it does the following for a given derivation that uses nix:
I suggest that we update the README so it reflects this when using this project, or just ship this combinator to hack the
.overrideso it does what (I consider) is sane.Here's the implementation:
We can then used it as such: