Skip to content

Commit

Permalink
nixos-rebuild: Prefer the module lib when available
Browse files Browse the repository at this point in the history
pkgs.lib and lib need not match, so prefer the one that the modules get.

For example:

```nix
nix-repl> :lf nixpkgs
nix-repl> (lib.nixosSystem { modules = [ ({ lib, ... }: assert lib?nixosSystem; { nixpkgs.hostPlatform = "x86_64-linux"; }) ]; }).pkgs.lib?nixosSystem
false
```

The code is backwards compatible, for the case where you evaluate a
config whose nixpkgs doesn't have the preceding commit yet.
  • Loading branch information
roberth committed Jan 14, 2024
1 parent 8e93465 commit 8be5259
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ if [ "$action" = repl ]; then
configuration._module.specialArgs //
{
inherit (configuration) config options;
inherit (configuration.pkgs) lib;
lib = configuration.lib or configuration.pkgs.lib;
inherit flake;
};
in builtins.seq scope builtins.trace motd scope
Expand Down

0 comments on commit 8be5259

Please sign in to comment.