pub-solar-os/hosts/default.nix

119 lines
3.1 KiB
Nix
Raw Normal View History

2021-01-19 08:00:41 +00:00
{ lib
, nixos
, master
, nixos-hardware
, pkgs
, self
, system
, externModules
, ...
}:
let
inherit (lib.flk) recImport;
2020-01-04 05:06:31 +00:00
inherit (builtins) attrValues removeAttrs;
unstableModules = [ ];
addToDisabledModules = [ ];
libExt = lib.extend (
final: prev: {
nixosSystemExtended = { modules, ... } @ args:
lib.nixosSystem (args // {
modules =
let
isoConfig = (
import (nixos + "/nixos/lib/eval-config.nix")
(
args // {
modules = modules ++ [
(nixos + "/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix")
({ config, ... }: {
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
networking.networkmanager.enable = lib.mkForce false; # confilcts with networking.wireless which might be slightly more useful on a stick
networking.wireless.iwd.enable = lib.mkForce false; # confilcts with networking.wireless
})
];
}
)
).config;
in
modules ++ [
{
system.build = {
iso = isoConfig.system.build.isoImage;
};
}
];
}
);
}
);
config = hostName:
libExt.nixosSystemExtended {
inherit system;
2020-12-31 20:42:49 +00:00
specialArgs =
{
unstableModulesPath = "${master}/nixos/modules";
hardware = nixos-hardware.nixosModules;
2020-12-31 20:42:49 +00:00
};
2020-07-31 04:17:28 +00:00
modules =
let
core = self.nixosModules.profiles.core;
modOverrides = { config, unstableModulesPath, ... }: {
disabledModules = unstableModules ++ addToDisabledModules;
imports = map
(path: "${unstableModulesPath}/${path}")
unstableModules;
};
2020-07-31 04:17:28 +00:00
global = {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
hardware.enableRedistributableFirmware = lib.mkDefault true;
2020-07-31 04:17:28 +00:00
networking.hostName = hostName;
nix.nixPath = let path = toString ../.; in
[
2020-12-16 21:47:51 +00:00
"nixos-unstable=${master}"
2021-01-19 08:00:41 +00:00
"nixos=${nixos}"
];
2020-07-31 04:17:28 +00:00
nixpkgs = { inherit pkgs; };
2020-07-31 04:17:28 +00:00
nix.registry = {
2020-12-16 21:47:51 +00:00
master.flake = master;
2020-07-31 04:17:28 +00:00
nixflk.flake = self;
2020-12-16 21:47:51 +00:00
nixpkgs.flake = nixos;
2020-07-31 04:17:28 +00:00
};
2020-08-04 06:11:08 +00:00
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
};
2020-07-31 04:17:28 +00:00
local = import "${toString ./.}/${hostName}.nix";
2020-07-31 04:17:28 +00:00
# Everything in `./modules/list.nix`.
flakeModules =
attrValues (removeAttrs self.nixosModules [ "profiles" ]);
2020-07-31 04:17:28 +00:00
in
2020-12-31 21:11:32 +00:00
flakeModules ++ [
core
global
local
modOverrides
] ++ externModules;
};
2020-01-04 05:06:31 +00:00
hosts = recImport {
dir = ./.;
_import = config;
};
2020-07-31 04:17:28 +00:00
in
hosts