nix-infra/hive.nix

77 lines
2.3 KiB
Nix
Raw Normal View History

2024-04-21 19:00:58 +00:00
{ inputs, self, lib, ... }:
let
inherit (inputs) nixpkgs nixpkgs-unstable;
inherit (self) outputs;
pkgs = import nixpkgs { system = "x86_64-linux"; };
2024-05-15 11:22:46 +00:00
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; config.allowUnfree = true; };
2024-04-21 19:00:58 +00:00
in
{
flake = rec {
colmena =
let
hosts = lib.genAttrs (builtins.attrNames (builtins.readDir ./hosts)) (name: { });
in
{
meta = {
description = "All my NixoS machines";
specialArgs = {
inherit inputs outputs pkgs-unstable;
2024-05-04 10:03:59 +00:00
flake = self;
2024-04-21 19:00:58 +00:00
nodes = colmenaHive.nodes;
};
nixpkgs = pkgs;
};
defaults = { lib, config, name, nodes, ... }: {
2024-05-04 10:03:59 +00:00
imports = [
./hosts/${name}
./profiles/base
(import ./overlays)
inputs.home-manager.nixosModules.home-manager
] ++ builtins.attrValues self.nixosModules;
2024-04-21 19:00:58 +00:00
options.cherrykitten = {
primaryIPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address
else null;
};
primaryIPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv6.addresses 0).address
else null;
};
};
config = {
networking.hostName = name;
networking.domain = "cherrykitten.xyz";
2024-05-04 10:03:59 +00:00
deployment = {
2024-05-04 13:03:05 +00:00
allowLocalDeployment = true;
2024-05-04 10:03:59 +00:00
targetUser = lib.mkDefault "sammy";
tags = [ pkgs.stdenv.hostPlatform.system ];
};
2024-04-21 19:00:58 +00:00
home-manager.extraSpecialArgs = {
inherit inputs outputs pkgs-unstable;
2024-05-04 10:03:59 +00:00
flake = self;
2024-04-21 19:00:58 +00:00
};
};
};
} // hosts;
colmenaHive = inputs.colmena.lib.makeHive colmena;
nixosConfigurations = {
iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ inputs.home-manager.nixosModules.home-manager ./profiles/iso ];
};
} // colmenaHive.nodes;
};
}