Anotther flake.nix bump.
This commit is contained in:
parent
8b2042e2bd
commit
f4023c47b0
1 changed files with 55 additions and 20 deletions
75
flake.nix
75
flake.nix
|
|
@ -10,61 +10,92 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs, deploy-rs, disko, nixos-anywhere, ... }:
|
outputs = { self, nixpkgs, deploy-rs, disko, nixos-anywhere, ... }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
# Default architecture if a system doesn’t override it
|
||||||
|
defaultSystem = "x86_64-linux";
|
||||||
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
# pkgs per-system so cross-arch doesn’t explode later
|
||||||
lib = pkgs.lib;
|
pkgsFor = system: import nixpkgs { inherit system; };
|
||||||
|
|
||||||
addressing = import ./lib/addressing {
|
lib = nixpkgs.lib;
|
||||||
inherit lib;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
# World spec & addressing
|
||||||
meta = import ./meta.nix;
|
meta = import ./meta.nix;
|
||||||
|
addressing = import ./lib/addressing { inherit lib; };
|
||||||
|
|
||||||
|
# Optional for now; meta.systems can be {} until the systems submodule lands
|
||||||
systemsFromMeta = meta.systems or { };
|
systemsFromMeta = meta.systems or { };
|
||||||
|
|
||||||
|
# Precomputed full network view
|
||||||
|
network = addressing.mkNetworkFromSpec meta;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
########################
|
||||||
|
# Library exports
|
||||||
|
########################
|
||||||
|
|
||||||
lib.metanix = {
|
lib.metanix = {
|
||||||
inherit meta addressing;
|
inherit meta addressing network;
|
||||||
network = addressing.mkNetworkFromSpec meta;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
########################
|
||||||
|
# NixOS configurations
|
||||||
|
########################
|
||||||
|
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
lib.mapAttrs
|
lib.mapAttrs
|
||||||
(name: sysCfg:
|
(name: sysCfg:
|
||||||
let
|
let
|
||||||
systemForHost = sysCfg.system or system;
|
# System for this host, fallback to default
|
||||||
|
system = sysCfg.system or defaultSystem;
|
||||||
|
pkgs = pkgsFor system;
|
||||||
in
|
in
|
||||||
lib.nixosSystem {
|
lib.nixosSystem {
|
||||||
system = systemForHost;
|
inherit system;
|
||||||
|
|
||||||
# Make meta + addressing available to all modules
|
# Make meta/addressing/world visible to modules
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit meta addressing;
|
inherit lib pkgs meta addressing system;
|
||||||
|
modulesPath = builtins.toString <nixpkgs/nixos/modules>;
|
||||||
};
|
};
|
||||||
|
|
||||||
modules =
|
modules =
|
||||||
(sysCfg.modules or [ ]) ++ [
|
(sysCfg.modules or [ ]) ++ [
|
||||||
|
# Core Metanix wiring
|
||||||
./modules/metanix/core.nix
|
./modules/metanix/core.nix
|
||||||
./modules/metanix/networkd.nix
|
./modules/metanix/networkd.nix
|
||||||
|
|
||||||
# Disko wiring if present
|
# Identity binding: “this box is <name> in Metanix”
|
||||||
|
{
|
||||||
|
networking.hostName = sysCfg.hostName or name;
|
||||||
|
metanix.thisHost = sysCfg.metanixName or name;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Optional Disko integration per host
|
||||||
(if sysCfg ? diskoConfig then
|
(if sysCfg ? diskoConfig then
|
||||||
{ imports = [ disko.nixosModules.disko sysCfg.diskoConfig ]; }
|
{
|
||||||
|
imports = [
|
||||||
|
disko.nixosModules.disko
|
||||||
|
sysCfg.diskoConfig
|
||||||
|
];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ })
|
{ })
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
systemsFromMeta;
|
systemsFromMeta;
|
||||||
|
|
||||||
|
########################
|
||||||
|
# deploy-rs
|
||||||
|
########################
|
||||||
|
|
||||||
deploy = {
|
deploy = {
|
||||||
nodes =
|
nodes =
|
||||||
lib.mapAttrs
|
lib.mapAttrs
|
||||||
(name: sysCfg:
|
(name: sysCfg:
|
||||||
let
|
let
|
||||||
network = addressing.mkNetworkFromSpec meta;
|
|
||||||
hasNetworkHost = builtins.hasAttr name network.hosts;
|
hasNetworkHost = builtins.hasAttr name network.hosts;
|
||||||
hostInfo = if hasNetworkHost then network.hosts.${name} else null;
|
hostInfo = if hasNetworkHost then network.hosts.${name} else null;
|
||||||
|
|
||||||
defaultHostname =
|
defaultHostname =
|
||||||
if hasNetworkHost then hostInfo.fqdn else "${name}.${meta.domain}";
|
if hasNetworkHost then hostInfo.fqdn else "${name}.${meta.domain}";
|
||||||
in
|
in
|
||||||
|
|
@ -74,20 +105,24 @@
|
||||||
profiles.system = {
|
profiles.system = {
|
||||||
user = sysCfg.deployUser or "root";
|
user = sysCfg.deployUser or "root";
|
||||||
path =
|
path =
|
||||||
deploy-rs.lib.${system}.activate.nixos
|
deploy-rs.lib.${defaultSystem}.activate.nixos
|
||||||
self.nixosConfigurations.${name};
|
self.nixosConfigurations.${name};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
systemsFromMeta;
|
systemsFromMeta;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks.${system}.deploy =
|
checks.${defaultSystem}.deploy =
|
||||||
deploy-rs.lib.${system}.deployChecks self.deploy;
|
deploy-rs.lib.${defaultSystem}.deployChecks self.deploy;
|
||||||
|
|
||||||
apps.${system}.nixos-anywhere = {
|
########################
|
||||||
|
# nixos-anywhere helper
|
||||||
|
########################
|
||||||
|
|
||||||
|
apps.${defaultSystem}.nixos-anywhere = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program =
|
program =
|
||||||
"${nixos-anywhere.packages.${system}.nixos-anywhere}/bin/nixos-anywhere";
|
"${nixos-anywhere.packages.${defaultSystem}.nixos-anywhere}/bin/nixos-anywhere";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue