2022-12-25 23:15:15 +00:00
|
|
|
{pkgs
|
|
|
|
,nixpkgs
|
|
|
|
,proj_root
|
2022-12-27 04:22:07 +00:00
|
|
|
,agenix
|
2022-12-25 23:15:15 +00:00
|
|
|
,nixosDefaultVersion? "22.05"
|
2022-12-27 04:22:07 +00:00
|
|
|
,defaultSystem? "x86_64-linux"
|
2022-12-25 23:15:15 +00:00
|
|
|
,...}@inputs: let
|
2022-12-25 10:54:10 +00:00
|
|
|
lib = pkgs.lib;
|
2022-12-27 04:22:07 +00:00
|
|
|
serde = import ./serde.nix inputs // {inherit lib;};
|
2022-12-25 23:15:15 +00:00
|
|
|
# procedure =
|
2022-12-25 10:54:10 +00:00
|
|
|
in {
|
|
|
|
# short-hand to create a shell derivation
|
|
|
|
# NOTE: this is pure. This means, env vars from devShells might not
|
|
|
|
# be accessible unless MAYBE they are `export`ed
|
|
|
|
shellAsDrv = {script, pname}: (pkgs.callPackage (
|
|
|
|
# just a pattern that we must remember: args to this are children of pkgs.
|
|
|
|
{writeShellScriptBin}: writeShellScriptBin pname script
|
|
|
|
) {});
|
2022-12-25 23:15:15 +00:00
|
|
|
|
|
|
|
# Configures hosts as nixosConfiguration
|
|
|
|
mkHost = {hostName
|
|
|
|
, nixosBareConfiguration
|
2022-12-27 04:22:07 +00:00
|
|
|
, finalInputs
|
|
|
|
, users ? {}
|
2022-12-25 23:15:15 +00:00
|
|
|
, nixosVersion? nixosDefaultVersion
|
|
|
|
, system? defaultSystem
|
2022-12-27 04:22:07 +00:00
|
|
|
, preset? "base"}: # base | minimal
|
|
|
|
let
|
|
|
|
hardwareConfig = hostname: import "${proj_root.hosts.path}/${hostName}/hardware-configuration.nix";
|
|
|
|
in nixpkgs.lib.nixosSystem (nixosBareConfiguration // {
|
2022-12-25 23:15:15 +00:00
|
|
|
inherit system;
|
|
|
|
modules = [
|
|
|
|
{
|
|
|
|
system.stateVersion = nixosVersion;
|
|
|
|
networking.hostName = hostName;
|
2022-12-27 04:22:07 +00:00
|
|
|
users.users = users;
|
2022-12-25 23:15:15 +00:00
|
|
|
}
|
2022-12-27 04:22:07 +00:00
|
|
|
{
|
|
|
|
_module.args = finalInputs;
|
|
|
|
}
|
|
|
|
import "${proj_root.modules.path}/secrets.nix"
|
|
|
|
import "${proj_root.modules.path}/${preset}.sys.nix"
|
2022-12-25 23:15:15 +00:00
|
|
|
] ++ nixosBareConfiguration.modules;
|
2022-12-27 04:22:07 +00:00
|
|
|
lib = finalInputs.lib;
|
2022-12-25 23:15:15 +00:00
|
|
|
});
|
2022-12-27 04:22:07 +00:00
|
|
|
inherit serde;
|
|
|
|
inherit (serde) fromYaml fromYamlPath;
|
2022-12-25 10:54:10 +00:00
|
|
|
}
|