nixpkgs module: Clean up platform options
- `localSystem` is added, it strictly supercedes system - `crossSystem`'s description mentions `localSystem` (and vice versa). - No more weird special casing I don't even understand TEMP
This commit is contained in:
parent
15a2dca15c
commit
c6f7d43678
|
@ -201,7 +201,7 @@ rec {
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
types.system = mkOptionType {
|
types.parsedPlatform = mkOptionType {
|
||||||
name = "system";
|
name = "system";
|
||||||
description = "fully parsed representation of llvm- or nix-style platform tuple";
|
description = "fully parsed representation of llvm- or nix-style platform tuple";
|
||||||
merge = mergeOneOption;
|
merge = mergeOneOption;
|
||||||
|
@ -215,7 +215,7 @@ rec {
|
||||||
isSystem = isType "system";
|
isSystem = isType "system";
|
||||||
|
|
||||||
mkSystem = components:
|
mkSystem = components:
|
||||||
assert types.system.check components;
|
assert types.parsedPlatform.check components;
|
||||||
setType "system" components;
|
setType "system" components;
|
||||||
|
|
||||||
mkSkeletonFromList = l: {
|
mkSkeletonFromList = l: {
|
||||||
|
|
|
@ -40,7 +40,7 @@ points to the generated virtual network.
|
||||||
test1 = {pkgs, config, ...}:
|
test1 = {pkgs, config, ...}:
|
||||||
{
|
{
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
nixpkgs.system = "i686-linux";
|
nixpkgs.localSystem.system = "i686-linux";
|
||||||
deployment.targetHost = "test1.example.net";
|
deployment.targetHost = "test1.example.net";
|
||||||
|
|
||||||
# Other NixOS options
|
# Other NixOS options
|
||||||
|
@ -51,7 +51,7 @@ points to the generated virtual network.
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
services.httpd.enable = true;
|
services.httpd.enable = true;
|
||||||
environment.systemPackages = [ pkgs.lynx ];
|
environment.systemPackages = [ pkgs.lynx ];
|
||||||
nixpkgs.system = "x86_64-linux";
|
nixpkgs.localSystem.system = "x86_64-linux";
|
||||||
deployment.targetHost = "test2.example.net";
|
deployment.targetHost = "test2.example.net";
|
||||||
|
|
||||||
# Other NixOS options
|
# Other NixOS options
|
||||||
|
@ -66,7 +66,7 @@ In each NixOS configuration, two attributes have a special meaning.
|
||||||
The <varname>deployment.targetHost</varname> specifies the address
|
The <varname>deployment.targetHost</varname> specifies the address
|
||||||
(domain name or IP address)
|
(domain name or IP address)
|
||||||
of the system which is used by <command>ssh</command> to perform
|
of the system which is used by <command>ssh</command> to perform
|
||||||
remote deployment operations. The <varname>nixpkgs.system</varname>
|
remote deployment operations. The <varname>nixpkgs.localSystem.system</varname>
|
||||||
attribute can be used to specify an architecture for the target machine,
|
attribute can be used to specify an architecture for the target machine,
|
||||||
such as <varname>i686-linux</varname> which builds a 32-bit NixOS
|
such as <varname>i686-linux</varname> which builds a 32-bit NixOS
|
||||||
configuration. Omitting this property will build the configuration
|
configuration. Omitting this property will build the configuration
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
, lib ? import ../../lib
|
, lib ? import ../../lib
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let extraArgs_ = extraArgs; pkgs_ = pkgs; system_ = system;
|
let extraArgs_ = extraArgs; pkgs_ = pkgs;
|
||||||
extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH";
|
extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH";
|
||||||
in if e == "" then [] else [(import (builtins.toPath e))];
|
in if e == "" then [] else [(import (builtins.toPath e))];
|
||||||
in
|
in
|
||||||
|
@ -36,7 +36,7 @@ let
|
||||||
_file = ./eval-config.nix;
|
_file = ./eval-config.nix;
|
||||||
key = _file;
|
key = _file;
|
||||||
config = {
|
config = {
|
||||||
nixpkgs.system = lib.mkDefault system_;
|
nixpkgs.localSystem = lib.mkDefault { inherit system; };
|
||||||
_module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
|
_module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,10 +58,13 @@ in
|
||||||
pkgs = mkOption {
|
pkgs = mkOption {
|
||||||
defaultText = literalExample
|
defaultText = literalExample
|
||||||
''import "''${nixos}/.." {
|
''import "''${nixos}/.." {
|
||||||
inherit (config.nixpkgs) config overlays system;
|
inherit (config.nixpkgs) config overlays localSystem crossSystem;
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
default = import ../../.. { inherit (cfg) config overlays system crossSystem; };
|
default = import ../../.. {
|
||||||
|
localSystem = { inherit (cfg) system; } // cfg.localSystem;
|
||||||
|
inherit (cfg) config overlays crossSystem;
|
||||||
|
};
|
||||||
type = pkgsType;
|
type = pkgsType;
|
||||||
example = literalExample ''import <nixpkgs> {}'';
|
example = literalExample ''import <nixpkgs> {}'';
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -73,8 +76,9 @@ in
|
||||||
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
|
||||||
relative path. The <code>config</code>, <code>overlays</code>
|
relative path. The <code>config</code>, <code>overlays</code>,
|
||||||
and <code>system</code> come from this option's siblings.
|
<code>localSystem</code>, and <code>crossSystem</code> come
|
||||||
|
from this option's siblings.
|
||||||
|
|
||||||
This option can be used by applications like NixOps to increase
|
This option can be used by applications like NixOps to increase
|
||||||
the performance of evaluation, or to create packages that depend
|
the performance of evaluation, or to create packages that depend
|
||||||
|
@ -130,13 +134,40 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
crossSystem = mkOption {
|
localSystem = mkOption {
|
||||||
type = types.nullOr types.attrs;
|
type = types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||||
default = null;
|
default = { system = builtins.currentSystem; };
|
||||||
|
example = { system = "aarch64-linux"; config = "aarch64-unknown-linux-gnu"; };
|
||||||
|
defaultText = literalExample
|
||||||
|
''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
|
||||||
description = ''
|
description = ''
|
||||||
The description of the system we're cross-compiling to, or null
|
Specifies the platform on which NixOS should be built. When
|
||||||
if this isn't a cross-compile. See the description of the
|
<code>nixpkgs.crossSystem</code> is unset, it also specifies
|
||||||
crossSystem argument in the nixpkgs manual.
|
the platform <emphasis>for</emphasis> which NixOS should be
|
||||||
|
built. If this option is unset, it defaults to the platform
|
||||||
|
type of the machine where evaluation happens. Specifying this
|
||||||
|
option is useful when doing distributed multi-platform
|
||||||
|
deployment, or when building virtual machines. See its
|
||||||
|
description in the Nixpkgs manual for more details.
|
||||||
|
|
||||||
|
Ignored when <code>nixpkgs.pkgs</code> is set.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
crossSystem = mkOption {
|
||||||
|
type = types.nullOr types.attrs; # TODO utilize lib.systems.parsedPlatform
|
||||||
|
default = null;
|
||||||
|
example = { system = "aarch64-linux"; config = "aarch64-unknown-linux-gnu"; };
|
||||||
|
defaultText = literalExample
|
||||||
|
''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
|
||||||
|
description = ''
|
||||||
|
Specifies the platform for which NixOS should be
|
||||||
|
built. Specify this only if it is different from
|
||||||
|
<code>nixpkgs.localSystem</code>, the platform
|
||||||
|
<emphasis>on</emphasis> which NixOS should be built. In other
|
||||||
|
words, specify this to cross-compile NixOS. Otherwise it
|
||||||
|
should be set as null, the default. See its description in the
|
||||||
|
Nixpkgs manual for more details.
|
||||||
|
|
||||||
Ignored when <code>nixpkgs.pkgs</code> is set.
|
Ignored when <code>nixpkgs.pkgs</code> is set.
|
||||||
'';
|
'';
|
||||||
|
@ -146,10 +177,20 @@ in
|
||||||
type = types.str;
|
type = types.str;
|
||||||
example = "i686-linux";
|
example = "i686-linux";
|
||||||
description = ''
|
description = ''
|
||||||
Specifies the Nix platform type for which NixOS should be built.
|
Specifies the Nix platform type on which NixOS should be built.
|
||||||
If unset, it defaults to the platform type of your host system.
|
It is better to specify <code>nixpkgs.localSystem</code> instead.
|
||||||
Specifying this option is useful when doing distributed
|
<programlisting>
|
||||||
multi-platform deployment, or when building virtual machines.
|
{
|
||||||
|
nixpkgs.system = ..;
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
is the same as
|
||||||
|
<programlisting>
|
||||||
|
{
|
||||||
|
nixpkgs.localSystem.system = ..;
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
See <code>nixpkgs.localSystem</code> for more information.
|
||||||
|
|
||||||
Ignored when <code>nixpkgs.pkgs</code> is set.
|
Ignored when <code>nixpkgs.pkgs</code> is set.
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -158,7 +158,7 @@ in
|
||||||
|
|
||||||
services.dysnomia.properties = {
|
services.dysnomia.properties = {
|
||||||
hostname = config.networking.hostName;
|
hostname = config.networking.hostName;
|
||||||
system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system;
|
inherit (config.nixpkgs.localSystem) system;
|
||||||
|
|
||||||
supportedTypes = (import "${pkgs.stdenv.mkDerivation {
|
supportedTypes = (import "${pkgs.stdenv.mkDerivation {
|
||||||
name = "supportedtypes";
|
name = "supportedtypes";
|
||||||
|
|
|
@ -23,7 +23,7 @@ let
|
||||||
options =
|
options =
|
||||||
let
|
let
|
||||||
scrubbedEval = evalModules {
|
scrubbedEval = evalModules {
|
||||||
modules = [ { nixpkgs.system = config.nixpkgs.system; } ] ++ baseModules;
|
modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ baseModules;
|
||||||
args = (config._module.args) // { modules = [ ]; };
|
args = (config._module.args) // { modules = [ ]; };
|
||||||
specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
|
specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,7 +112,7 @@ let
|
||||||
|
|
||||||
# If the host is 64-bit and the container is 32-bit, add a
|
# If the host is 64-bit and the container is 32-bit, add a
|
||||||
# --personality flag.
|
# --personality flag.
|
||||||
${optionalString (config.nixpkgs.system == "x86_64-linux") ''
|
${optionalString (config.nixpkgs.localSystem.system == "x86_64-linux") ''
|
||||||
if [ "$(< ''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system)" = i686-linux ]; then
|
if [ "$(< ''${SYSTEM_PATH:-/nix/var/nix/profiles/per-container/$INSTANCE/system}/system)" = i686-linux ]; then
|
||||||
extraFlags+=" --personality=x86"
|
extraFlags+=" --personality=x86"
|
||||||
fi
|
fi
|
||||||
|
@ -255,7 +255,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
system = config.nixpkgs.system;
|
system = config.nixpkgs.localSystem.system;
|
||||||
|
|
||||||
bindMountOpts = { name, config, ... }: {
|
bindMountOpts = { name, config, ... }: {
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ let
|
||||||
license = either (listOf lib.types.attrs) (either lib.types.attrs str);
|
license = either (listOf lib.types.attrs) (either lib.types.attrs str);
|
||||||
maintainers = listOf (attrsOf str);
|
maintainers = listOf (attrsOf str);
|
||||||
priority = int;
|
priority = int;
|
||||||
platforms = listOf (either str lib.systems.parsed.types.system);
|
platforms = listOf (either str lib.systems.parsedPlatform.types.system);
|
||||||
hydraPlatforms = listOf str;
|
hydraPlatforms = listOf str;
|
||||||
broken = bool;
|
broken = bool;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue