lib/builders.nix: add default nixpkgs hostplatform to mkSystem

This commit is contained in:
Charlie Root 2024-08-31 10:39:12 +02:00
commit 0cd9acc0a7
2 changed files with 16 additions and 4 deletions

View file

@ -1,6 +1,8 @@
{inputs, ...}: let {inputs, ...}: let
inherit (inputs) self nixpkgs; inherit (inputs) self nixpkgs;
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
inherit (lib) mkDefault nixosSystem recursiveUpdate singleton;
inherit (builtins) concatLists;
in { in {
mkSystem = { mkSystem = {
withSystem, withSystem,
@ -13,17 +15,27 @@ in {
self', self',
... ...
}: }:
lib.nixosSystem { nixosSystem {
inherit system; inherit system;
specialArgs = specialArgs =
lib.recursiveUpdate recursiveUpdate
{ {
inherit lib; inherit lib;
inherit inputs inputs'; inherit inputs inputs';
inherit self self'; inherit self self';
} }
(args.specialArgs or {}); (args.specialArgs or {});
inherit (args) modules; modules = concatLists [
# This is used to pre-emptively set the hostPlatform for nixpkgs.
# We need a singleton here since we concatenate lists, and a singleton
# generates a list with a single element.
(singleton {
nixpkgs.hostPlatform = mkDefault args.system;
})
# We pass our modules from the arguments
(args.modules or [])
];
} }
); );
} }

View file

@ -44,6 +44,6 @@ in {
# `flake.lib` is set. # `flake.lib` is set.
flake = { flake = {
lib = extendedLib; lib = extendedLib;
_module.args.lib = extendedLib; # _module.args.lib = extendedLib;
}; };
} }