dotfiles/nixos/bootstrap/flake.nix

77 lines
2.0 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 = {
url = github:IvanMalison/nix;
inputs.nixpkgs.follows = "nixpkgs";
};
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";
};
};
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;
});
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 = {
2023-06-28 21:30:23 -06:00
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;
};
}