Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion lib-overlays/caisson-colmena/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
final: prev:
let

resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem;
ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem;
ecosystem = {
name = "colmena";
context = "caisson.caisson-colmena";
};
Expand Down Expand Up @@ -273,6 +275,11 @@
in
{
value = evaluated;
# Where colmena came from, as `src` was resolved.
ecosystems.colmena = ecosystemAccountOf {
explicit = args.ecosystemSrc or null;
inherit manifest;
};
# What evalModules received: the options of the class, the
# framework module of the class, the modules selected from
# the registry and the configuration's module. Each node is a
Expand Down Expand Up @@ -382,6 +389,10 @@
assertColmenaEcosystemSrc (resolveEcosystemSrc {
inherit explicit manifest;
});
# Where that colmena source came from, from the same
# arguments, as a manifest records it under
# `ecosystems.colmena`.
ecosystemAccountOf = { explicit, manifest }: ecosystemAccountOf { inherit explicit manifest; };
};
};
in
Expand Down
16 changes: 15 additions & 1 deletion lib-overlays/caisson-disko/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
final: prev:
let

resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem;
ecosystem = {
name = "disko";
context = "caisson.caisson-disko";
};
Expand All @@ -77,6 +78,12 @@
inherit explicit manifest;
});

# Where that disko source came from, from the same arguments, as
# a manifest records it under `ecosystems.disko`.
ecosystemAccountOf =
{ explicit, manifest }:
final.caisson.integrations.ecosystemAccountOf ecosystem { inherit explicit manifest; };

# disko's type library, from the disko source, over `lib`. The
# types are built from `rootMountPoint`, the directory the mount
# script mounts the layout under.
Expand Down Expand Up @@ -253,6 +260,11 @@
in
{
value = evaluated;
# Where disko came from, as `src` was resolved.
ecosystems.disko = ecosystemAccountOf {
explicit = args.ecosystemSrc or null;
inherit manifest;
};
# What evalModules received: the devices option and the
# assertions, the framework module of the class, the modules
# selected from the registry and the configuration's module.
Expand Down Expand Up @@ -359,6 +371,8 @@
# `disko`, as recorded on `manifest`; refused when it is no
# disko source.
inherit ecosystemSrcOf;
# Where that disko source came from, from the same arguments.
inherit ecosystemAccountOf;
# disko's type library from `{ lib, src, rootMountPoint }`.
inherit diskoLibOf;
# The module declaring `disko.devices`, for a type library.
Expand Down
5 changes: 5 additions & 0 deletions lib-overlays/colmena/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@
in
{
value = evaluated;
# Where colmena came from, as `src` was resolved.
ecosystems.colmena = native.ecosystemAccountOf {
explicit = args.ecosystemSrc or null;
inherit manifest;
};
# What evalModules received: the options of the class, the
# framework module of the class, the modules selected from
# the registry and the module made from the hive. Each node is
Expand Down
18 changes: 16 additions & 2 deletions lib-overlays/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@
let
context = "lib.caisson.darwin.mkConfiguration";

resolveDarwinSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveDarwinSrc = final.caisson.integrations.resolveEcosystemSrc darwinEcosystem;
darwinAccountOf = final.caisson.integrations.ecosystemAccountOf darwinEcosystem;
darwinEcosystem = {
name = "nix-darwin";
context = "caisson.darwin";
};

resolveNixpkgsSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveNixpkgsSrc = final.caisson.integrations.resolveEcosystemSrc nixpkgsEcosystem;
nixpkgsAccountOf = final.caisson.integrations.ecosystemAccountOf nixpkgsEcosystem;
nixpkgsEcosystem = {
name = "nixpkgs";
context = "caisson.darwin";
};
Expand Down Expand Up @@ -145,6 +149,16 @@
in
{
inherit value;
# Where nix-darwin came from, as `src` was resolved, and where
# the nixpkgs of `nixpkgs.source` came from, as `nixpkgsSrc`
# was resolved.
ecosystems = {
nix-darwin = darwinAccountOf {
explicit = args.ecosystemSrc or null;
manifest = libManifest;
};
nixpkgs = nixpkgsAccountOf { manifest = libManifest; };
};
# What eval-config received: the modules of the
# composition, then nix-darwin's module list.
modules = darwinModules ++ [
Expand Down
5 changes: 5 additions & 0 deletions lib-overlays/disko/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
in
{
value = evaluated;
# Where disko came from, as `src` was resolved.
ecosystems.disko = native.ecosystemAccountOf {
explicit = args.ecosystemSrc or null;
inherit manifest;
};
# What evalModules received: the devices option, the
# framework module of the class, the modules selected from
# the registry and the configuration's module. disko's type
Expand Down
63 changes: 40 additions & 23 deletions lib-overlays/flake-parts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,36 @@
final: prev:
let

resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem;
ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem;
ecosystem = {
name = "flake-parts";
context = "caisson.flake-parts";
};
resolveSrc =
explicit:
resolveEcosystemSrc {
inherit explicit;
manifest = final.caisson-core.libManifest or { };
};
resolveOutPath = value: if builtins.isAttrs value && value ? outPath then value.outPath else value;

# flake-parts instantiated over this composition: its flake.nix
# applied to the composed library as `nixpkgs-lib`. What comes
# out (`lib.evalFlakeModule`, `flakeModules`) is flake-parts'
# machinery on caisson's library, with no second nixpkgs lib
# inside it.
flakePartsFor =
explicit:
# flake-parts instantiated over this composition from the
# flake-parts source `src`: its flake.nix applied to the composed
# library as `nixpkgs-lib`. What comes out (`lib.evalFlakeModule`,
# `flakeModules`) is flake-parts' machinery on caisson's library,
# with no second nixpkgs lib inside it.
flakePartsOf =
src:
final.caisson.callFlake {
src = resolveOutPath (resolveSrc explicit);
src = resolveOutPath src;
inputs.nixpkgs-lib = {
lib = final;
};
};
# The manifest the declared flake-parts is resolved from: the
# lib manifest of this composed library.
defaultManifest = final.caisson-core.libManifest or { };
# The composition's declared flake-parts, instantiated per
# composed library and shared by every evaluation that passes
# no `ecosystemSrc`.
flakePartsDefault = flakePartsFor null;
flakePartsDefault = flakePartsOf (resolveEcosystemSrc {
manifest = defaultManifest;
});

# The option types of the core module, re-exported under this
# namespace for the readers of that name.
Expand All @@ -85,13 +86,20 @@
let
selection = lib.caisson.integrations;

# The flake-parts source the configuration selects from the
# tree's sources, null when it selects none.
selected =
selection.selectedEcosystemSrc "lib.caisson.flake-parts.mkConfiguration"
(lib.caisson-core.libManifest or { })
(args.ecosystemSrc or null);
flakeParts = if selected == null then flakePartsDefault else flakePartsFor selected;
# The flake-parts the configuration runs on. A configuration
# that selects a source with `ecosystemSrc` selects it from
# the sources of the lib manifest of the evaluation. A
# configuration that selects none runs on the declared
# flake-parts.
explicit = args.ecosystemSrc or null;
flakeParts =
if explicit == null then
flakePartsDefault
else
flakePartsOf (resolveEcosystemSrc {
inherit explicit;
manifest = lib.caisson-core.libManifest or { };
});

# The flake class of the registry, the same source every
# adapter selects from, so modules arriving by any channel
Expand Down Expand Up @@ -226,6 +234,15 @@
in
{
value = evaluated;
# Where flake-parts came from, as `flakeParts` was resolved.
ecosystems.flake-parts =
if explicit == null then
ecosystemAccountOf { manifest = defaultManifest; }
else
ecosystemAccountOf {
inherit explicit;
manifest = lib.caisson-core.libManifest or { };
};
# What `evalFlakeModule` received: flake-parts' core modules,
# then the module of the composition.
modules = [
Expand Down
9 changes: 8 additions & 1 deletion lib-overlays/hjem/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
let
context = "lib.caisson.hjem.mkConfiguration";

resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem;
ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem;
ecosystem = {
name = "hjem";
context = "caisson.hjem";
};
Expand Down Expand Up @@ -229,6 +231,11 @@
in
{
inherit value;
# Where hjem came from, as `src` was resolved.
ecosystems.hjem = ecosystemAccountOf {
explicit = args.ecosystemSrc or null;
manifest = lib.caisson-core.libManifest or { };
};
# What evalModules received: hjem's user module, the module
# that sets the user's name, hjem's systemd module where the
# machine has `utils`, the framework module of the class, the
Expand Down
9 changes: 8 additions & 1 deletion lib-overlays/home-manager/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
let
selection = final.caisson.integrations;

resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc {
resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem;
ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem;
ecosystem = {
name = "home-manager";
context = "caisson.home-manager";
};
Expand Down Expand Up @@ -478,6 +480,11 @@
in
{
inherit value;
# Where home-manager came from, as `resolveSrc` resolved it.
ecosystems.home-manager = ecosystemAccountOf {
explicit = args.ecosystemSrc or null;
manifest = final.caisson-core.libManifest or { };
};
# What evalModules received: the configuration module, then
# home-manager's module list.
modules = [
Expand Down
62 changes: 60 additions & 2 deletions lib-overlays/integrations/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,50 @@
to mkLib.
'';

# How an evaluation came by the source of the ecosystem `name`, as
# its manifest records it under `ecosystems.<name>`. It takes the
# arguments `resolveEcosystemSrc` takes and follows the same
# order. `from` names the declaration that supplied the source:
# `ecosystemSrc` for the selection of the configuration,
# `defaultEcosystemSrc` for the selection of the tree, and
# `sources` for the source the tree pins under exactly that name.
# `source` is the name of that source among the pinned sources,
# where `pin` records its revision, or null where a selection
# builds the value in another way. Reading the account forces no
# source a selection does not read.
ecosystemAccountOf =
{
name,
context,
}:
{
explicit ? null,
manifest ? final.caisson-core.libManifest or { },
}:
let
sources = manifest.sources or { };
in
if explicit != null then
{
from = "ecosystemSrc";
source = final.caisson-core.selectedSourceName {
inherit sources;
selection = sources: selectedEcosystemSrc context { inherit sources; } explicit;
};
}
else if (manifest.defaultEcosystemSrc or { }) ? ${name} then
{
from = "defaultEcosystemSrc";
source = (manifest.defaultEcosystemSrcNames or { }).${name} or null;
}
else if sources ? ${name} then
{
from = "sources";
source = name;
}
else
resolveEcosystemSrc { inherit name context; } { inherit explicit manifest; };

named =
leaf: name:
let
Expand Down Expand Up @@ -559,7 +603,7 @@
}:
final.caisson-core.mkConfiguration {
inherit type perSystem;
recordFromEvaluation = if selection == null then [ ] else [ "moduleImports" ];
recordFromEvaluation = [ "ecosystems" ] ++ (if selection == null then [ ] else [ "moduleImports" ]);
record =
(if defaultPkgs == null then { } else { inherit defaultPkgs; })
// (
Expand Down Expand Up @@ -616,8 +660,21 @@
inherit (view) lib;
modules = evaluated.modules or [ ];
};
record = {
# Where each part of the stack the evaluation used came
# from (`ecosystemAccountOf`): the library of the lib it
# runs on, and each ecosystem the integration resolved,
# which its `evaluate` returns as `ecosystems`.
ecosystems = {
nixpkgs-lib = ecosystemAccountOf {
name = "nixpkgs-lib";
context = "the nixpkgs-lib entry";
} { manifest = view.lib.caisson-core.libManifest or { }; };
}
// (evaluated.ecosystems or { });
}
# How the evaluation selected its modules.
record = if selection == null then { } else { moduleImports = selectionAccountOf selection view; };
// (if selection == null then { } else { moduleImports = selectionAccountOf selection view; });
};
};

Expand Down Expand Up @@ -1653,6 +1710,7 @@
topValue
resolveEcosystemSrc
selectedEcosystemSrc
ecosystemAccountOf
mkIntegration
mkAltIntegration
frameworkModules
Expand Down
Loading
Loading