ark/lib/devos/mkHosts.nix

106 lines
2.5 KiB
Nix
Raw Normal View History

2021-04-02 05:10:24 +03:00
{ lib, dev, nixpkgs, inputs, self, ... }:
{ 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; };
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
};
users.mutableUsers = lib.mkDefault false;
hardware.enableRedistributableFirmware = lib.mkDefault true;
nix.nixPath = [
2021-04-02 05:10:24 +03:00
"nixpkgs=${nixpkgs}"
"nixos-config=${self}/compat/nixos"
"home-manager=${inputs.home}"
];
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
nix.registry = {
devos.flake = self;
2021-04-02 05:10:24 +03:00
nixos.flake = nixpkgs;
override.flake = inputs.override;
};
nix.package = pkgs.nixFlakes;
nix.extraOptions = ''
experimental-features = ${lib.concatStringsSep " "
experimentalFeatures
}
'';
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
# Everything in `./modules/list.nix`.
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
2021-03-23 20:25:42 +03:00
cachix = ../../cachix.nix;
};
specialArgs = extern.specialArgs // { suites = suites.system; };
mkHostConfig = hostName:
let
local = {
require = [
"${dir}/${hostName}.nix"
];
networking = { inherit hostName; };
_module.args = {
inherit self;
hosts = builtins.mapAttrs (_: host: host.config)
(removeAttrs hosts [ hostName ]);
};
};
lib = {
lib = { inherit specialArgs; };
lib.testModule = {
imports = builtins.attrValues modules;
};
};
in
dev.os.devosSystem {
inherit specialArgs;
system = defaultSystem;
modules = modules // { inherit local lib; };
};
hosts = dev.os.recImport
{
inherit dir;
_import = mkHostConfig;
};
2020-07-31 07:17:28 +03:00
in
hosts