nixpkgs: support buildPlatform, hostPlatform, and overlays (#184)
This commit is contained in:
parent
c9e35e9b7d
commit
489c060d2e
2 changed files with 30 additions and 3 deletions
19
nix/lib.nix
19
nix/lib.nix
|
|
@ -20,6 +20,7 @@ let
|
|||
makeSystemConfig =
|
||||
{
|
||||
modules,
|
||||
overlays ? [ ],
|
||||
extraSpecialArgs ? { },
|
||||
}:
|
||||
let
|
||||
|
|
@ -34,7 +35,23 @@ let
|
|||
{
|
||||
_file = "${self.printAttrPos (builtins.unsafeGetAttrPos "a" { a = null; })}: inline module";
|
||||
_module.args = {
|
||||
pkgs = import nixpkgs { system = config.nixpkgs.hostPlatform; inherit (config.nixpkgs) config; };
|
||||
pkgs = let
|
||||
cfg = config.nixpkgs;
|
||||
systemArgs =
|
||||
if cfg.buildPlatform != cfg.hostPlatform then
|
||||
{
|
||||
localSystem = cfg.buildPlatform;
|
||||
crossSystem = cfg.hostPlatform;
|
||||
}
|
||||
else
|
||||
{
|
||||
system = cfg.hostPlatform;
|
||||
};
|
||||
in
|
||||
import nixpkgs ({
|
||||
overlays = overlays ++ cfg.overlays;
|
||||
inherit (config.nixpkgs) config;
|
||||
} // systemArgs);
|
||||
utils = import "${nixos}/lib/utils.nix" {
|
||||
inherit lib config pkgs;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,13 +20,23 @@
|
|||
in
|
||||
{
|
||||
nixpkgs = {
|
||||
# TODO: switch to lib.systems.parsedPlatform
|
||||
hostPlatform = lib.mkOption {
|
||||
buildPlatform = lib.mkOption {
|
||||
type = types.str;
|
||||
example = "x86_64-linux";
|
||||
default = config.nixpkgs.hostPlatform;
|
||||
};
|
||||
|
||||
hostPlatform = lib.mkOption {
|
||||
type = with types; either str attrs;
|
||||
example = "x86_64-linux";
|
||||
default = throw "the option nixpkgs.hostPlatform needs to be set.";
|
||||
};
|
||||
|
||||
overlays = lib.mkOption {
|
||||
type = with types; listOf anything;
|
||||
default = [];
|
||||
};
|
||||
|
||||
config = lib.mkOption {
|
||||
type = types.attrs;
|
||||
description = ''Configuration used to instantiate nixpkgs.'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue