Merge pull request #49256 from roberth/nixos-nixpkgs-pkgs-use-overlays
NixOS: use overlays when nixpkgs.pkgs is set
This commit is contained in:
commit
dd3aca2d0b
@ -147,6 +147,14 @@
|
|||||||
make sure to update your configuration if you want to keep <literal>proglodyte-wasm</literal>
|
make sure to update your configuration if you want to keep <literal>proglodyte-wasm</literal>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
When the <literal>nixpkgs.pkgs</literal> option is set, NixOS will no
|
||||||
|
longer ignore the <literal>nixpkgs.overlays</literal> option. The old
|
||||||
|
behavior can be recovered by setting <literal>nixpkgs.overlays =
|
||||||
|
lib.mkForce [];</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
OpenSMTPD has been upgraded to version 6.4.0p1. This release makes
|
OpenSMTPD has been upgraded to version 6.4.0p1. This release makes
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.nixpkgs;
|
cfg = config.nixpkgs;
|
||||||
|
opt = options.nixpkgs;
|
||||||
|
|
||||||
isConfig = x:
|
isConfig = x:
|
||||||
builtins.isAttrs x || lib.isFunction x;
|
builtins.isAttrs x || lib.isFunction x;
|
||||||
@ -54,6 +55,12 @@ let
|
|||||||
check = builtins.isAttrs;
|
check = builtins.isAttrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultPkgs = import ../../../pkgs/top-level/default.nix {
|
||||||
|
inherit (cfg) config overlays localSystem crossSystem;
|
||||||
|
};
|
||||||
|
|
||||||
|
finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -61,21 +68,25 @@ in
|
|||||||
|
|
||||||
pkgs = mkOption {
|
pkgs = mkOption {
|
||||||
defaultText = literalExample
|
defaultText = literalExample
|
||||||
''import "''${nixos}/.." {
|
''import "''${nixos}/../pkgs/top-level" {
|
||||||
inherit (cfg) config overlays localSystem crossSystem;
|
inherit (cfg) config overlays localSystem crossSystem;
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
default = import ../../.. {
|
|
||||||
inherit (cfg) config overlays localSystem crossSystem;
|
|
||||||
};
|
|
||||||
type = pkgsType;
|
type = pkgsType;
|
||||||
example = literalExample ''import <nixpkgs> {}'';
|
example = literalExample ''import <nixpkgs> {}'';
|
||||||
description = ''
|
description = ''
|
||||||
This is the evaluation of Nixpkgs that will be provided to
|
If set, the pkgs argument to all NixOS modules is the value of
|
||||||
all NixOS modules. Defining this option has the effect of
|
this option, extended with <code>nixpkgs.overlays</code>, if
|
||||||
ignoring the other options that would otherwise be used to
|
that is also set. Either <code>nixpkgs.crossSystem</code> or
|
||||||
evaluate Nixpkgs, because those are arguments to the default
|
<code>nixpkgs.localSystem</code> will be used in an assertion
|
||||||
value. The default value imports the Nixpkgs source files
|
to check that the NixOS and Nixpkgs architectures match. Any
|
||||||
|
other options in <code>nixpkgs.*</code>, notably <code>config</code>,
|
||||||
|
will be ignored.
|
||||||
|
|
||||||
|
If unset, the pkgs argument to all NixOS modules is determined
|
||||||
|
as shown in the default value for this option.
|
||||||
|
|
||||||
|
The default value imports the Nixpkgs source files
|
||||||
relative to the location of this NixOS module, because
|
relative to the location of this NixOS module, because
|
||||||
NixOS and Nixpkgs are distributed together for consistency,
|
NixOS and Nixpkgs are distributed together for consistency,
|
||||||
so the <code>nixos</code> in the default value is in fact a
|
so the <code>nixos</code> in the default value is in fact a
|
||||||
@ -128,12 +139,14 @@ in
|
|||||||
description = ''
|
description = ''
|
||||||
List of overlays to use with the Nix Packages collection.
|
List of overlays to use with the Nix Packages collection.
|
||||||
(For details, see the Nixpkgs documentation.) It allows
|
(For details, see the Nixpkgs documentation.) It allows
|
||||||
you to override packages globally. This is a function that
|
you to override packages globally. Each function in the list
|
||||||
takes as an argument the <emphasis>original</emphasis> Nixpkgs.
|
takes as an argument the <emphasis>original</emphasis> Nixpkgs.
|
||||||
The first argument should be used for finding dependencies, and
|
The first argument should be used for finding dependencies, and
|
||||||
the second should be used for overriding recipes.
|
the second should be used for overriding recipes.
|
||||||
|
|
||||||
Ignored when <code>nixpkgs.pkgs</code> is set.
|
If <code>nixpkgs.pkgs</code> is set, overlays specified here
|
||||||
|
will be applied after the overlays that were already present
|
||||||
|
in <code>nixpkgs.pkgs</code>.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -207,7 +220,26 @@ in
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
_module.args = {
|
_module.args = {
|
||||||
pkgs = cfg.pkgs;
|
pkgs = finalPkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
assertions = [
|
||||||
|
(
|
||||||
|
let
|
||||||
|
nixosExpectedSystem =
|
||||||
|
if config.nixpkgs.crossSystem != null
|
||||||
|
then config.nixpkgs.crossSystem.system
|
||||||
|
else config.nixpkgs.localSystem.system;
|
||||||
|
nixosOption =
|
||||||
|
if config.nixpkgs.crossSystem != null
|
||||||
|
then "nixpkgs.crossSystem"
|
||||||
|
else "nixpkgs.localSystem";
|
||||||
|
pkgsSystem = finalPkgs.stdenv.targetPlatform.system;
|
||||||
|
in {
|
||||||
|
assertion = nixosExpectedSystem == pkgsSystem;
|
||||||
|
message = "The NixOS nixpkgs.pkgs option was set to a Nixpkgs invocation that compiles to target system ${pkgsSystem} but NixOS was configured for system ${nixosExpectedSystem} via NixOS option ${nixosOption}. The NixOS system settings must match the Nixpkgs target system.";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -22212,7 +22212,7 @@ with pkgs;
|
|||||||
in
|
in
|
||||||
myOS.run-nginx
|
myOS.run-nginx
|
||||||
|
|
||||||
Unlike in plain NixOS, the nixpkgs.config, nixpkgs.overlays and
|
Unlike in plain NixOS, the nixpkgs.config and
|
||||||
nixpkgs.system options will be ignored by default. Instead,
|
nixpkgs.system options will be ignored by default. Instead,
|
||||||
nixpkgs.pkgs will have the default value of pkgs as it was
|
nixpkgs.pkgs will have the default value of pkgs as it was
|
||||||
constructed right after invoking the nixpkgs function (e.g. the
|
constructed right after invoking the nixpkgs function (e.g. the
|
||||||
|
@ -164,7 +164,9 @@ let
|
|||||||
# preexisting overlays. Prefer to initialize with the right overlays
|
# preexisting overlays. Prefer to initialize with the right overlays
|
||||||
# in one go when calling Nixpkgs, for performance and simplicity.
|
# in one go when calling Nixpkgs, for performance and simplicity.
|
||||||
appendOverlays = extraOverlays:
|
appendOverlays = extraOverlays:
|
||||||
import ./stage.nix (args // { overlays = args.overlays ++ extraOverlays; });
|
if extraOverlays == []
|
||||||
|
then self
|
||||||
|
else import ./stage.nix (args // { overlays = args.overlays ++ extraOverlays; });
|
||||||
|
|
||||||
# Extend the package set with a single overlay. This preserves
|
# Extend the package set with a single overlay. This preserves
|
||||||
# preexisting overlays. Prefer to initialize with the right overlays
|
# preexisting overlays. Prefer to initialize with the right overlays
|
||||||
|
Loading…
x
Reference in New Issue
Block a user