2021-03-16 21:42:58 +00:00
|
|
|
{ lib, nixos, self, inputs, ... }:
|
2021-03-14 07:10:51 +00:00
|
|
|
|
|
|
|
{ modules, ... } @ args:
|
|
|
|
lib.nixosSystem (args // {
|
|
|
|
modules =
|
|
|
|
let
|
2021-03-17 22:41:54 +00:00
|
|
|
moduleList = builtins.attrValues modules;
|
2021-03-14 07:10:51 +00:00
|
|
|
modpath = "nixos/modules";
|
|
|
|
|
2021-03-18 20:58:01 +00:00
|
|
|
fullHostConfig = (lib.nixosSystem (args // { modules = moduleList; })).config;
|
|
|
|
|
2021-03-14 07:10:51 +00:00
|
|
|
isoConfig = (lib.nixosSystem
|
|
|
|
(args // {
|
2021-03-17 22:41:54 +00:00
|
|
|
modules = moduleList ++ [
|
2021-03-18 22:42:17 +00:00
|
|
|
|
|
|
|
"${nixos}/${modpath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix"
|
|
|
|
|
2021-03-18 22:41:22 +00:00
|
|
|
({ config, suites, ... }: {
|
|
|
|
|
|
|
|
# avoid unwanted systemd service startups
|
2021-03-29 16:54:02 +00:00
|
|
|
# all strings in disabledModules get appended to modulesPath
|
|
|
|
# so convert each to list which can be coerced to string
|
2021-04-24 06:51:51 +00:00
|
|
|
disabledModules = map lib.singleton suites.allProfiles;
|
2021-03-18 22:41:22 +00:00
|
|
|
|
2021-03-18 22:42:17 +00:00
|
|
|
nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs;
|
|
|
|
|
2021-03-14 07:10:51 +00:00
|
|
|
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
|
2021-03-16 19:50:38 +00:00
|
|
|
isoImage.contents = [{
|
|
|
|
source = self;
|
|
|
|
target = "/devos/";
|
|
|
|
}];
|
2021-03-16 22:33:53 +00:00
|
|
|
isoImage.storeContents = [
|
|
|
|
self.devShell.${config.nixpkgs.system}
|
2021-03-18 20:58:01 +00:00
|
|
|
# include also closures that are "switched off" by the
|
|
|
|
# above profile filter on the local config attribute
|
|
|
|
fullHostConfig.system.build.toplevel
|
2021-03-16 22:33:53 +00:00
|
|
|
];
|
2021-03-19 04:17:58 +00:00
|
|
|
# still pull in tools of deactivated profiles
|
|
|
|
environment.systemPackages = fullHostConfig.environment.systemPackages;
|
2021-03-18 22:42:17 +00:00
|
|
|
|
2021-03-14 07:10:51 +00:00
|
|
|
# confilcts with networking.wireless which might be slightly
|
|
|
|
# more useful on a stick
|
|
|
|
networking.networkmanager.enable = lib.mkForce false;
|
|
|
|
# confilcts with networking.wireless
|
|
|
|
networking.wireless.iwd.enable = lib.mkForce false;
|
2021-03-18 22:42:17 +00:00
|
|
|
|
2021-03-16 19:50:38 +00:00
|
|
|
# Set up a link-local boostrap network
|
|
|
|
# See also: https://github.com/NixOS/nixpkgs/issues/75515#issuecomment-571661659
|
|
|
|
networking.usePredictableInterfaceNames = lib.mkForce true; # so prefix matching works
|
|
|
|
networking.useNetworkd = lib.mkForce true;
|
|
|
|
networking.useDHCP = lib.mkForce false;
|
|
|
|
networking.dhcpcd.enable = lib.mkForce false;
|
|
|
|
systemd.network = {
|
|
|
|
# https://www.freedesktop.org/software/systemd/man/systemd.network.html
|
|
|
|
networks."boostrap-link-local" = {
|
|
|
|
matchConfig = {
|
|
|
|
Name = "en* wl* ww*";
|
|
|
|
};
|
|
|
|
networkConfig = {
|
|
|
|
Description = "Link-local host bootstrap network";
|
|
|
|
MulticastDNS = true;
|
|
|
|
LinkLocalAddressing = "ipv6";
|
|
|
|
DHCP = "yes";
|
|
|
|
};
|
|
|
|
address = [
|
|
|
|
# fall back well-known link-local for situations where MulticastDNS is not available
|
|
|
|
"fe80::47" # 47: n=14 i=9 x=24; n+i+x
|
|
|
|
];
|
|
|
|
extraConfig = ''
|
|
|
|
# Unique, yet stable. Based off the MAC address.
|
|
|
|
IPv6LinkLocalAddressGenerationMode = "eui64"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2021-03-14 07:10:51 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
})).config;
|
2021-03-23 14:37:11 +00:00
|
|
|
hmConfig = (lib.nixosSystem
|
|
|
|
(args // {
|
|
|
|
modules = moduleList ++ [
|
|
|
|
({ config, ... }: {
|
|
|
|
home-manager.useUserPackages = lib.mkForce false;
|
|
|
|
home-manager.sharedModules = [
|
|
|
|
{
|
|
|
|
home.sessionVariables = {
|
|
|
|
inherit (config.environment.sessionVariables) NIX_PATH;
|
|
|
|
};
|
|
|
|
xdg.configFile."nix/registry.json".text =
|
|
|
|
config.environment.etc."nix/registry.json".text;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
})).config;
|
2021-03-14 07:10:51 +00:00
|
|
|
in
|
2021-03-17 22:41:54 +00:00
|
|
|
moduleList ++ [{
|
2021-03-14 07:10:51 +00:00
|
|
|
system.build = {
|
|
|
|
iso = isoConfig.system.build.isoImage;
|
2021-03-23 14:37:11 +00:00
|
|
|
homes = hmConfig.home-manager.users;
|
2021-03-14 07:10:51 +00:00
|
|
|
};
|
|
|
|
}];
|
|
|
|
})
|