mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 21:25:30 +03:00
nixos/containers: support nixpkgs.hostPlatform
Use hostPlatform if both the host and the containers nixpkgs supports hostPlatform, otherwise fall back to localSystem. This preseves backwards compatibility.
This commit is contained in:
parent
707c915886
commit
f4ccaa51e0
1 changed files with 6 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }@host:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -284,7 +284,6 @@ let
|
||||||
DeviceAllow = map (d: "${d.node} ${d.modifier}") cfg.allowedDevices;
|
DeviceAllow = map (d: "${d.node} ${d.modifier}") cfg.allowedDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (config.nixpkgs) localSystem;
|
|
||||||
kernelVersion = config.boot.kernelPackages.kernel.version;
|
kernelVersion = config.boot.kernelPackages.kernel.version;
|
||||||
|
|
||||||
bindMountOpts = { name, ... }: {
|
bindMountOpts = { name, ... }: {
|
||||||
|
@ -480,10 +479,13 @@ in
|
||||||
merge = loc: defs: (import "${toString config.nixpkgs}/nixos/lib/eval-config.nix" {
|
merge = loc: defs: (import "${toString config.nixpkgs}/nixos/lib/eval-config.nix" {
|
||||||
modules =
|
modules =
|
||||||
let
|
let
|
||||||
extraConfig = {
|
extraConfig = { options, ... }: {
|
||||||
_file = "module at ${__curPos.file}:${toString __curPos.line}";
|
_file = "module at ${__curPos.file}:${toString __curPos.line}";
|
||||||
config = {
|
config = {
|
||||||
nixpkgs = { inherit localSystem; };
|
nixpkgs = if options.nixpkgs?hostPlatform && host.options.nixpkgs.hostPlatform.isDefined
|
||||||
|
then { inherit (host.config.nixpkgs) hostPlatform; }
|
||||||
|
else { inherit (host.config.nixpkgs) localSystem; }
|
||||||
|
;
|
||||||
boot.isContainer = true;
|
boot.isContainer = true;
|
||||||
networking.hostName = mkDefault name;
|
networking.hostName = mkDefault name;
|
||||||
networking.useDHCP = false;
|
networking.useDHCP = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue