summary refs log tree commit diff
path: root/nixos/modules/virtualisation/nixos-containers.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-05-28 18:28:57 +0000
committerAlyssa Ross <hi@alyssa.is>2022-05-28 20:01:55 +0000
commitc3c0dd00d8f2a0bbfb5961be048ccc66dc87b133 (patch)
tree08e7b2dd936a9829d9d53b0d13da4e30a40e0418 /nixos/modules/virtualisation/nixos-containers.nix
parent612defb824d5b695aa3f5a6944fad5f7ee9c320c (diff)
downloadnixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.tar
nixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.tar.gz
nixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.tar.bz2
nixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.tar.lz
nixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.tar.xz
nixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.tar.zst
nixpkgs-c3c0dd00d8f2a0bbfb5961be048ccc66dc87b133.zip
treewide: fix loss of precision in NixOS systems
Prior to this patch:

	$ nix-instantiate --eval -E '
	>   with import ./. {
	>     localSystem.config = "aarch64-unknown-linux-musl";
	>   };
	>   (nixos {}).config.nixpkgs.localSystem.config
	> '
	"aarch64-unknown-linux-gnu"

Because only the system triple was being passed through, the Musl part
of the system specification was lost.  This patch fixes various
occurrences of NixOS evaluation when a Nixpkgs evaluation is already
available, to pass through the full elaborated system attribute set,
to avoid this loss of precision.
Diffstat (limited to 'nixos/modules/virtualisation/nixos-containers.nix')
-rw-r--r--nixos/modules/virtualisation/nixos-containers.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/nixos/modules/virtualisation/nixos-containers.nix b/nixos/modules/virtualisation/nixos-containers.nix
index 23228a109bc..b9301515712 100644
--- a/nixos/modules/virtualisation/nixos-containers.nix
+++ b/nixos/modules/virtualisation/nixos-containers.nix
@@ -284,7 +284,7 @@ let
     DeviceAllow = map (d: "${d.node} ${d.modifier}") cfg.allowedDevices;
   };
 
-  system = config.nixpkgs.localSystem.system;
+  inherit (config.nixpkgs) localSystem;
   kernelVersion = config.boot.kernelPackages.kernel.version;
 
   bindMountOpts = { name, ... }: {
@@ -478,12 +478,12 @@ in
               type = lib.mkOptionType {
                 name = "Toplevel NixOS config";
                 merge = loc: defs: (import "${toString config.nixpkgs}/nixos/lib/eval-config.nix" {
-                  inherit system;
                   modules =
                     let
                       extraConfig = {
                         _file = "module at ${__curPos.file}:${toString __curPos.line}";
                         config = {
+                          nixpkgs = { inherit localSystem; };
                           boot.isContainer = true;
                           networking.hostName = mkDefault name;
                           networking.useDHCP = false;