dotfiles/nixos/bootstrap/flake.nix

78 lines
2.1 KiB
Nix
Raw Normal View History

2023-06-28 20:25:04 -06:00
{
inputs = {
nixos-hardware = { url = github:NixOS/nixos-hardware; };
2023-06-28 20:26:30 -06:00
nixpkgs = { url = github:NixOS/nixpkgs/nixos-unstable; };
2023-06-28 20:25:04 -06:00
home-manager = {
url = github:nix-community/home-manager;
inputs.nixpkgs.follows = "nixpkgs";
};
nix = {
2023-07-28 10:02:12 -06:00
url = github:IvanMalison/nix/my2.15.1;
2023-06-28 20:25:04 -06:00
};
flake-utils = {
url = github:numtide/flake-utils;
inputs.systems.follows = "systems";
};
systems = { url = github:nix-systems/default; };
git-ignore-nix = {
url = github:hercules-ci/gitignore.nix;
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-wsl = { url = github:nix-community/NixOS-WSL; };
2023-06-28 20:25:04 -06:00
};
outputs = inputs@{
self, nixpkgs, nixos-hardware, home-manager, nix, ...
2023-06-28 20:25:04 -06:00
}:
let
mkConfig =
args@
{ system ? "x86_64-linux"
, baseModules ? []
, modules ? []
, specialArgs ? {}
, ...
}:
nixpkgs.lib.nixosSystem (args // {
inherit system;
modules = baseModules ++ modules;
specialArgs = { inherit inputs; } // specialArgs;
makeEnable = (import ../make-enable.nix) nixpkgs.lib;
2023-06-28 20:25:04 -06:00
});
2023-06-28 21:30:23 -06:00
machinesPath = ../machines;
machineFilenames = builtins.attrNames (builtins.readDir machinesPath);
2023-06-28 20:25:04 -06:00
machineNameFromFilename = filename: builtins.head (builtins.split "\\." filename);
mkConfigurationParams = filename: {
name = machineNameFromFilename filename;
value = {
modules = [ (machinesPath + ("/" + filename)) ];
2023-06-28 20:25:04 -06:00
};
};
defaultConfigurationParams =
builtins.listToAttrs (map mkConfigurationParams machineFilenames);
customParams = {
biskcomp = {
system = "aarch64-linux";
};
air-gapped-pi = {
system = "aarch64-linux";
};
};
in
{
nixosConfigurations = builtins.mapAttrs (machineName: params:
let machineParams =
if builtins.hasAttr machineName customParams
then (builtins.getAttr machineName customParams)
else {};
in mkConfig (params // machineParams)
) defaultConfigurationParams;
};
}