Set up core flake.nix file.

This commit is contained in:
yaro 2025-11-28 15:51:01 -06:00
parent 2ea6dfde56
commit ee31bfb7f6

View file

@ -1,8 +1,71 @@
{ {
description = "Metanix infrastructure logic library"; description = "Metanix core flake (meta.nix-driven outputs)";
outputs = { self, nixpkgs }: { inputs = {
lib = { data, lib }: # Base system
import ./lib/metanix.nix { inherit data lib; }; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Tooling we integrate with
deploy-rs.url = "github:serokell/deploy-rs";
disko.url = "github:nix-community/disko";
}; };
outputs = { self, nixpkgs, deploy-rs, disko, ... }:
let
lib = nixpkgs.lib;
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f:
lib.genAttrs systems (system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
metanixLib = import ./lib {
inherit nixpkgs deploy-rs disko;
};
# Build the "world" view from meta.nix
world = metanixLib.fromMeta {
metaFile = ./meta.nix;
inherit nixpkgs deploy-rs disko;
};
in
{
# So other flakes *can* depend on Metanix as a library if needed.
lib = metanixLib;
# For nixos-rebuild / nixos-anywhere / deploy-rs
nixosConfigurations = world.nixosConfigurations;
# For deploy-rs
deploy = {
nodes = world.deployNodes;
};
# For disko-based installs (either as bare configs or modules)
diskoConfigurations = world.diskoConfigurations;
checks = forAllSystems ({ pkgs, ... }: {
meta-validate = metanixLib.checkMeta {
inherit pkgs;
metaFile = ./meta.nix;
};
});
devShells = forAllSystems ({ system, pkgs }: {
default = pkgs.mkShell {
name = "metanix-dev";
buildInputs = [
pkgs.nix
pkgs.git
deploy-rs.packages.${system}.default
disko.packages.${system}.default
];
};
});
}
} }