From 1ce7334a733ccd1b87659e49722ea6058a3db754 Mon Sep 17 00:00:00 2001 From: UGA Innovation Factory Date: Wed, 7 Jan 2026 18:11:59 -0500 Subject: [PATCH] feat: add lib.mkFleet for external flake consumption - Create lib/mkFleet.nix to expose fleet generator as library function - Allow external flakes to use Athenix's fleet logic with custom inventory - Export lib output in flake.nix with proper input passing - Enable usage: nixosConfigurations = athenix.lib.mkFleet { fleet = ...; hwTypes = ...; } --- flake.nix | 7 +++++-- lib/default.nix | 4 ++++ lib/mkFleet.nix | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 lib/default.nix create mode 100644 lib/mkFleet.nix diff --git a/flake.nix b/flake.nix index 74acc6a..e1cd249 100644 --- a/flake.nix +++ b/flake.nix @@ -69,7 +69,7 @@ ... }: let - fleet = import ./glue/fleet.nix { inherit inputs; }; + fleet = self.lib.mkFleet { inherit inputs; }; linuxSystem = "x86_64-linux"; artifacts = import ./installer/artifacts.nix { inherit inputs fleet self; @@ -90,11 +90,14 @@ nixosConfigurations = fleet.nixosConfigurations; # Expose artifacts to all systems, but they are always built for x86_64-linux - packages = forAllSystems (_: artifacts); + packages.${linuxSystem} = artifacts; # Expose host type modules and installer modules for external use nixosModules = import ./installer/modules.nix { inherit inputs; }; + # Library functions + lib = import ./lib { inherit inputs; }; + # Templates for external configurations templates = import ./templates; }; diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..fe2fff2 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,4 @@ +{ inputs }: +{ + mkFleet = import ./mkFleet.nix; +} \ No newline at end of file diff --git a/lib/mkFleet.nix b/lib/mkFleet.nix new file mode 100644 index 0000000..4de4d49 --- /dev/null +++ b/lib/mkFleet.nix @@ -0,0 +1,11 @@ +# Generate fleet configurations with custom fleet and hardware types +# Usage: nixosConfigurations = athenix.lib.mkFleet { fleet = { ... }; hwTypes = { ... }; } +{ + inputs, + fleet ? null, + hwTypes ? null, +}: + import ../fleet/default.nix { + inherit inputs; + inherit fleet hwTypes; + } \ No newline at end of file