feat(flake): expose lib.mkSystem for external consumers
Surface mkSystem as a flake output and make its host resolution non-throwing: internal hosts (this repo's hosts/<name>/) are still imported automatically, but a consumer using OmniXY as a flake input can now pass their own host via `modules` instead. First brick of the dependency-model framework; the core module aggregate (nixosModules) follows so a consumer's host can import OmniXY core. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
1238703d9f
commit
8678f637db
2 changed files with 25 additions and 7 deletions
13
flake.nix
13
flake.nix
|
|
@ -218,6 +218,19 @@
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
# Reusable library for external consumers. Use this flake as an
|
||||||
|
# input and build a host with the Omnixient conventions from your own
|
||||||
|
# repo, without forking:
|
||||||
|
#
|
||||||
|
# omni.lib.mkSystem "myhost" {
|
||||||
|
# settings = { ... }; # your identity (see settings.nix)
|
||||||
|
# modules = [ ./hosts/myhost ];
|
||||||
|
# };
|
||||||
|
#
|
||||||
|
# mkSystem bakes in Omnixient's nixpkgs, overlays, and inputs
|
||||||
|
# (home-manager, sops-nix, …), so you don't redeclare them.
|
||||||
|
lib.mkSystem = mkSystem;
|
||||||
|
|
||||||
# NixOS configurations.
|
# NixOS configurations.
|
||||||
#
|
#
|
||||||
# This public template ships the `example` host (copy-me starter) and
|
# This public template ships the `example` host (copy-me starter) and
|
||||||
|
|
|
||||||
|
|
@ -70,13 +70,18 @@ let
|
||||||
# fall back to a flat `hosts/<name>.nix`.
|
# fall back to a flat `hosts/<name>.nix`.
|
||||||
hostDir = ../hosts/${name};
|
hostDir = ../hosts/${name};
|
||||||
hostFile = ../hosts + "/${name}.nix";
|
hostFile = ../hosts + "/${name}.nix";
|
||||||
hostConfig =
|
# Internal hosts (this repo's hosts/<name>/) are imported automatically.
|
||||||
|
# External consumers using this flake as an input have no host dir here,
|
||||||
|
# so they pass their host config through `modules` and we add nothing.
|
||||||
|
hostConfigModules =
|
||||||
if builtins.pathExists hostDir then
|
if builtins.pathExists hostDir then
|
||||||
hostDir
|
[ hostDir ]
|
||||||
else if builtins.pathExists hostFile then
|
else if builtins.pathExists hostFile then
|
||||||
hostFile
|
[ hostFile ]
|
||||||
|
else if modules != [ ] then
|
||||||
|
[ ]
|
||||||
else
|
else
|
||||||
throw "mksystem: no host config for '${name}' (looked at ${toString hostDir} and ${toString hostFile})";
|
throw "mksystem: no host config for '${name}' — add hosts/${name}/ or pass one via `modules` (looked at ${toString hostDir} and ${toString hostFile})";
|
||||||
|
|
||||||
userNixosConfig = ../users/${user}/nixos.nix;
|
userNixosConfig = ../users/${user}/nixos.nix;
|
||||||
userHMConfig = ../users/${user}/home-manager.nix;
|
userHMConfig = ../users/${user}/home-manager.nix;
|
||||||
|
|
@ -101,10 +106,10 @@ nixpkgs.lib.nixosSystem {
|
||||||
{ nixpkgs.hostPlatform = system; }
|
{ nixpkgs.hostPlatform = system; }
|
||||||
{ nixpkgs.overlays = overlays; }
|
{ nixpkgs.overlays = overlays; }
|
||||||
{ nixpkgs.config.allowUnfree = true; }
|
{ nixpkgs.config.allowUnfree = true; }
|
||||||
|
|
||||||
# Per-host configuration.
|
|
||||||
hostConfig
|
|
||||||
]
|
]
|
||||||
|
# Per-host configuration: this repo's hosts/<name>/ when present;
|
||||||
|
# external consumers supply their host through `modules`.
|
||||||
|
++ hostConfigModules
|
||||||
# Per-user system-level config (account, shell, sudo) — only if the
|
# Per-user system-level config (account, shell, sudo) — only if the
|
||||||
# user file exists. Skipping silently is fine; some hosts share users
|
# user file exists. Skipping silently is fine; some hosts share users
|
||||||
# defined elsewhere (e.g. omni's users.nix).
|
# defined elsewhere (e.g. omni's users.nix).
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue