diff --git a/flake.nix b/flake.nix index 2290a79..c8e859b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,71 @@ { - description = "Metanix infrastructure logic library"; + description = "Metanix core flake (meta.nix-driven outputs)"; - outputs = { self, nixpkgs }: { - lib = { data, lib }: - import ./lib/metanix.nix { inherit data lib; }; + inputs = { + # Base system + 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 + ]; + }; + }); + } }