Skip to content

Clarify override configuration in README #13

Description

@leana8959

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions