diff options
author | Robert Hensing <robert@roberthensing.nl> | 2018-11-04 23:09:43 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2018-11-04 23:09:43 +0100 |
commit | b682778366f91bd3a2b5746cfc951ad429904f16 (patch) | |
tree | 503d514660fa9b91fdf11ad66f31b79156bbfdd9 /nixos/modules | |
parent | 51c6f51390ba3c0bfefc1bf8437cb265c92395f4 (diff) |
nixos/../nixpkgs.nix: Add assertions to check pkgs' system
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/misc/nixpkgs.nix | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index 461a3b68ed61..2bebbdcad94a 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -218,5 +218,24 @@ in _module.args = { pkgs = finalPkgs; }; + + assertions = [ + ( + let + nixosExpectedSystem = + if config.nixpkgs.crossSystem != null + then config.nixpkgs.crossSystem.system + else config.nixpkgs.localSystem.system; + nixosOption = + if config.nixpkgs.crossSystem != null + then "nixpkgs.crossSystem" + else "nixpkgs.localSystem"; + pkgsSystem = finalPkgs.stdenv.targetPlatform.system; + in { + assertion = nixosExpectedSystem == pkgsSystem; + message = "The NixOS nixpkgs.pkgs option was set to a Nixpkgs invocation that compiles to target system ${pkgsSystem} but NixOS was configured for system ${nixosExpectedSystem} via NixOS option ${nixosOption}. The NixOS system settings must match the Nixpkgs target system."; + } + ) + ]; }; } |