nixos/nixpkgs: remove with lib;
This commit is contained in:
parent
6af918a564
commit
609e57485d
@ -1,7 +1,4 @@
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.nixpkgs;
|
||||
opt = options.nixpkgs;
|
||||
@ -19,19 +16,19 @@ let
|
||||
lhs = optCall lhs_ { inherit pkgs; };
|
||||
rhs = optCall rhs_ { inherit pkgs; };
|
||||
in
|
||||
recursiveUpdate lhs rhs //
|
||||
optionalAttrs (lhs ? packageOverrides) {
|
||||
lib.recursiveUpdate lhs rhs //
|
||||
lib.optionalAttrs (lhs ? packageOverrides) {
|
||||
packageOverrides = pkgs:
|
||||
optCall lhs.packageOverrides pkgs //
|
||||
optCall (attrByPath [ "packageOverrides" ] { } rhs) pkgs;
|
||||
optCall (lib.attrByPath [ "packageOverrides" ] { } rhs) pkgs;
|
||||
} //
|
||||
optionalAttrs (lhs ? perlPackageOverrides) {
|
||||
lib.optionalAttrs (lhs ? perlPackageOverrides) {
|
||||
perlPackageOverrides = pkgs:
|
||||
optCall lhs.perlPackageOverrides pkgs //
|
||||
optCall (attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs;
|
||||
optCall (lib.attrByPath [ "perlPackageOverrides" ] { } rhs) pkgs;
|
||||
};
|
||||
|
||||
configType = mkOptionType {
|
||||
configType = lib.mkOptionType {
|
||||
name = "nixpkgs-config";
|
||||
description = "nixpkgs config";
|
||||
check = x:
|
||||
@ -39,34 +36,34 @@ let
|
||||
if c x then true
|
||||
else lib.traceSeqN 1 x false;
|
||||
in traceXIfNot isConfig;
|
||||
merge = args: foldr (def: mergeConfig def.value) {};
|
||||
merge = args: lib.foldr (def: mergeConfig def.value) {};
|
||||
};
|
||||
|
||||
overlayType = mkOptionType {
|
||||
overlayType = lib.mkOptionType {
|
||||
name = "nixpkgs-overlay";
|
||||
description = "nixpkgs overlay";
|
||||
check = lib.isFunction;
|
||||
merge = lib.mergeOneOption;
|
||||
};
|
||||
|
||||
pkgsType = types.pkgs // {
|
||||
pkgsType = lib.types.pkgs // {
|
||||
# This type is only used by itself, so let's elaborate the description a bit
|
||||
# for the purpose of documentation.
|
||||
description = "An evaluation of Nixpkgs; the top level attribute set of packages";
|
||||
};
|
||||
|
||||
hasBuildPlatform = opt.buildPlatform.highestPrio < (mkOptionDefault {}).priority;
|
||||
hasBuildPlatform = opt.buildPlatform.highestPrio < (lib.mkOptionDefault {}).priority;
|
||||
hasHostPlatform = opt.hostPlatform.isDefined;
|
||||
hasPlatform = hasHostPlatform || hasBuildPlatform;
|
||||
|
||||
# Context for messages
|
||||
hostPlatformLine = optionalString hasHostPlatform "${showOptionWithDefLocs opt.hostPlatform}";
|
||||
buildPlatformLine = optionalString hasBuildPlatform "${showOptionWithDefLocs opt.buildPlatform}";
|
||||
hostPlatformLine = lib.optionalString hasHostPlatform "${lib.showOptionWithDefLocs opt.hostPlatform}";
|
||||
buildPlatformLine = lib.optionalString hasBuildPlatform "${lib.showOptionWithDefLocs opt.buildPlatform}";
|
||||
|
||||
legacyOptionsDefined =
|
||||
optional (opt.localSystem.highestPrio < (mkDefault {}).priority) opt.system
|
||||
++ optional (opt.localSystem.highestPrio < (mkOptionDefault {}).priority) opt.localSystem
|
||||
++ optional (opt.crossSystem.highestPrio < (mkOptionDefault {}).priority) opt.crossSystem
|
||||
lib.optional (opt.localSystem.highestPrio < (lib.mkDefault {}).priority) opt.system
|
||||
++ lib.optional (opt.localSystem.highestPrio < (lib.mkOptionDefault {}).priority) opt.localSystem
|
||||
++ lib.optional (opt.crossSystem.highestPrio < (lib.mkOptionDefault {}).priority) opt.crossSystem
|
||||
;
|
||||
|
||||
defaultPkgs =
|
||||
@ -99,19 +96,19 @@ in
|
||||
imports = [
|
||||
./assertions.nix
|
||||
./meta.nix
|
||||
(mkRemovedOptionModule [ "nixpkgs" "initialSystem" ] "The NixOS options `nesting.clone` and `nesting.children` have been deleted, and replaced with named specialisation. Therefore `nixpgks.initialSystem` has no effect anymore.")
|
||||
(lib.mkRemovedOptionModule [ "nixpkgs" "initialSystem" ] "The NixOS options `nesting.clone` and `nesting.children` have been deleted, and replaced with named specialisation. Therefore `nixpgks.initialSystem` has no effect lib.anymore.")
|
||||
];
|
||||
|
||||
options.nixpkgs = {
|
||||
|
||||
pkgs = mkOption {
|
||||
defaultText = literalExpression ''
|
||||
pkgs = lib.mkOption {
|
||||
defaultText = lib.literalExpression ''
|
||||
import "''${nixos}/.." {
|
||||
inherit (cfg) config overlays localSystem crossSystem;
|
||||
}
|
||||
'';
|
||||
type = pkgsType;
|
||||
example = literalExpression "import <nixpkgs> {}";
|
||||
example = lib.literalExpression "import <nixpkgs> {}";
|
||||
description = ''
|
||||
If set, the pkgs argument to all NixOS modules is the value of
|
||||
this option, extended with `nixpkgs.overlays`, if
|
||||
@ -145,9 +142,9 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
config = lib.mkOption {
|
||||
default = {};
|
||||
example = literalExpression
|
||||
example = lib.literalExpression
|
||||
''
|
||||
{ allowBroken = true; allowUnfree = true; }
|
||||
'';
|
||||
@ -160,9 +157,9 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
overlays = mkOption {
|
||||
overlays = lib.mkOption {
|
||||
default = [];
|
||||
example = literalExpression
|
||||
example = lib.literalExpression
|
||||
''
|
||||
[
|
||||
(self: super: {
|
||||
@ -173,7 +170,7 @@ in
|
||||
})
|
||||
]
|
||||
'';
|
||||
type = types.listOf overlayType;
|
||||
type = lib.types.listOf overlayType;
|
||||
description = ''
|
||||
List of overlays to apply to Nixpkgs.
|
||||
This option allows modifying the Nixpkgs package set accessed through the `pkgs` module argument.
|
||||
@ -184,13 +181,13 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
hostPlatform = mkOption {
|
||||
type = types.either types.str types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
hostPlatform = lib.mkOption {
|
||||
type = lib.types.either lib.types.str lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
example = { system = "aarch64-linux"; };
|
||||
# Make sure that the final value has all fields for sake of other modules
|
||||
# referring to this. TODO make `lib.systems` itself use the module system.
|
||||
apply = lib.systems.elaborate;
|
||||
defaultText = literalExpression
|
||||
defaultText = lib.literalExpression
|
||||
''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
|
||||
description = ''
|
||||
Specifies the platform where the NixOS configuration will run.
|
||||
@ -201,8 +198,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
buildPlatform = mkOption {
|
||||
type = types.either types.str types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
buildPlatform = lib.mkOption {
|
||||
type = lib.types.either lib.types.str lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
default = cfg.hostPlatform;
|
||||
example = { system = "x86_64-linux"; };
|
||||
# Make sure that the final value has all fields for sake of other modules
|
||||
@ -212,7 +209,7 @@ in
|
||||
in if lib.systems.equals elaborated cfg.hostPlatform
|
||||
then cfg.hostPlatform # make identical, so that `==` equality works; see https://github.com/NixOS/nixpkgs/issues/278001
|
||||
else elaborated;
|
||||
defaultText = literalExpression
|
||||
defaultText = lib.literalExpression
|
||||
''config.nixpkgs.hostPlatform'';
|
||||
description = ''
|
||||
Specifies the platform on which NixOS should be built.
|
||||
@ -228,14 +225,14 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
localSystem = mkOption {
|
||||
type = types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
localSystem = lib.mkOption {
|
||||
type = lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
default = { inherit (cfg) system; };
|
||||
example = { system = "aarch64-linux"; };
|
||||
# Make sure that the final value has all fields for sake of other modules
|
||||
# referring to this. TODO make `lib.systems` itself use the module system.
|
||||
apply = lib.systems.elaborate;
|
||||
defaultText = literalExpression
|
||||
defaultText = lib.literalExpression
|
||||
''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
|
||||
description = ''
|
||||
Systems with a recently generated `hardware-configuration.nix`
|
||||
@ -262,8 +259,8 @@ in
|
||||
# TODO deprecate. "crossSystem" is a nonsense identifier, because "cross"
|
||||
# is a relation between at least 2 systems in the context of a
|
||||
# specific build step, not a single system.
|
||||
crossSystem = mkOption {
|
||||
type = types.nullOr types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
crossSystem = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||
default = null;
|
||||
example = { system = "aarch64-linux"; };
|
||||
description = ''
|
||||
@ -283,8 +280,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
system = mkOption {
|
||||
type = types.str;
|
||||
system = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "i686-linux";
|
||||
default =
|
||||
if opt.hostPlatform.isDefined
|
||||
@ -372,12 +369,12 @@ in
|
||||
{
|
||||
assertion = constructedByMe -> hasPlatform -> legacyOptionsDefined == [];
|
||||
message = ''
|
||||
Your system configures nixpkgs with the platform parameter${optionalString hasBuildPlatform "s"}:
|
||||
Your system configures nixpkgs with the platform parameter${lib.optionalString hasBuildPlatform "s"}:
|
||||
${hostPlatformLine
|
||||
}${buildPlatformLine
|
||||
}
|
||||
However, it also defines the legacy options:
|
||||
${concatMapStrings showOptionWithDefLocs legacyOptionsDefined}
|
||||
${lib.concatMapStrings lib.showOptionWithDefLocs legacyOptionsDefined}
|
||||
For a future proof system configuration, we recommend to remove
|
||||
the legacy definitions.
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user