pub-solar-os/lib/devos/mkHosts.nix

114 lines
2.7 KiB
Nix
Raw Normal View History

2021-04-19 02:45:08 +00:00
{ lib }:
{ userFlakeNixOS, userFlakeInputs, userFlakeSelf }:
{ dir, extern, suites, overrides, multiPkgs }:
let
defaultSystem = "x86_64-linux";
experimentalFeatures = [
"flakes"
"nix-command"
"ca-references"
"ca-derivations"
];
modules = {
modOverrides = { config, overrideModulesPath, ... }:
let
inherit (overrides) modules disabledModules;
in
{
disabledModules = modules ++ disabledModules;
imports = map
(path: "${overrideModulesPath}/${path}")
modules;
};
global = { config, pkgs, ... }: {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
2021-04-19 00:35:11 +00:00
sharedModules = extern.userModules ++ (builtins.attrValues userFlakeSelf.homeModules);
};
users.mutableUsers = lib.mkDefault false;
hardware.enableRedistributableFirmware = lib.mkDefault true;
nix.nixPath = [
2021-04-19 02:45:08 +00:00
"nixpkgs=${userFlakeNixOS}"
2021-04-19 05:02:29 +00:00
"nixos-config=${userFlakeSelf}/lib/compat/nixos"
2021-04-18 01:46:20 +00:00
"home-manager=${userFlakeInputs.home}"
];
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
nix.registry = {
2021-04-19 00:35:11 +00:00
devos.flake = userFlakeSelf;
2021-04-19 02:45:08 +00:00
nixos.flake = userFlakeNixOS;
2021-04-18 01:46:20 +00:00
override.flake = userFlakeInputs.override;
};
nix.package = pkgs.nixFlakes;
nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';
2021-04-19 00:35:11 +00:00
system.configurationRevision = lib.mkIf (userFlakeSelf ? rev) userFlakeSelf.rev;
};
# Everything in `./modules/list.nix`.
2021-04-19 00:35:11 +00:00
flakeModules = { imports = builtins.attrValues userFlakeSelf.nixosModules ++ extern.modules; };
2021-03-23 17:25:42 +00:00
2021-04-19 05:02:29 +00:00
cachix = let rootCachix = "${userFlakeSelf}/cachix.nix"; in
if builtins.pathExists rootCachix
then rootCachix
else { }
;
};
specialArgs = extern.specialArgs // { suites = suites.system; };
mkHostConfig = hostName:
let
local = {
require = [
"${dir}/${hostName}.nix"
];
networking = { inherit hostName; };
_module.args = {
2021-04-19 00:35:11 +00:00
self = userFlakeSelf;
hosts = builtins.mapAttrs (_: host: host.config)
(removeAttrs hosts [ hostName ]);
};
2021-04-19 04:48:19 +00:00
lib = { inherit specialArgs; };
lib.testModule = {
imports = builtins.attrValues modules;
};
2021-04-19 04:48:19 +00:00
};
in
2021-04-18 01:35:05 +00:00
lib.os.devosSystem {
inherit userFlakeNixOS userFlakeInputs userFlakeSelf;
} {
inherit specialArgs;
system = defaultSystem;
2021-04-19 04:48:19 +00:00
modules = modules // { inherit local; };
};
2021-04-18 01:35:05 +00:00
hosts = lib.os.recImport
{
inherit dir;
_import = mkHostConfig;
};
2020-07-31 04:17:28 +00:00
in
hosts