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.
main
Alyssa Ross 2 years ago
parent 612defb824
commit c3c0dd00d8
  1. 4
      nixos/modules/virtualisation/nixos-containers.nix
  2. 3
      nixos/tests/containers-imperative.nix
  3. 2
      pkgs/top-level/all-packages.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;

@ -18,8 +18,9 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
# container available within the VM, because we don't have network access.
virtualisation.additionalPaths = let
emptyContainer = import ../lib/eval-config.nix {
inherit (config.nixpkgs.localSystem) system;
modules = lib.singleton {
nixpkgs = { inherit (config.nixpkgs) localSystem; };
containers.foo.config = {
system.stateVersion = "18.03";
};

@ -34253,11 +34253,11 @@ with pkgs;
configuration:
let
c = import (path + "/nixos/lib/eval-config.nix") {
inherit (stdenv.hostPlatform) system;
modules =
[(
{ lib, ... }: {
config.nixpkgs.pkgs = lib.mkDefault pkgs;
config.nixpkgs.localSystem = lib.mkDefault stdenv.hostPlatform;
}
)] ++ (
if builtins.isList configuration

Loading…
Cancel
Save