From 9f97e1ea56e5e196d6b672772937d2d39e2dd127 Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Fri, 23 Oct 2026 22:00:06 -0700 Subject: [PATCH 1/2] feat(integrations): record where each part of the stack came from Every configuration records ecosystems: an account for each part of the stack its evaluation used, keyed as the parts are resolved. Each account names the declaration that supplied the source (the ecosystemSrc of the configuration, the defaultEcosystemSrc of the tree, or the source pinned under exactly that name) and the name of that source among the pinned sources. nixpkgs-lib is recorded for every evaluation, each integration adds the ecosystems it resolves, and a package config also lists the names its sets take from the source of the package set. flake-parts resolves a selected source once. A flake-parts configuration that passed ecosystemSrc threw, because the selected source went back into resolveEcosystemSrc, which takes a function. Co-Authored-By: Claude Opus 5.5 --- flake.lock | 6 +- lib-overlays/caisson-colmena/default.nix | 13 +- lib-overlays/caisson-disko/default.nix | 16 +- lib-overlays/colmena/default.nix | 5 + lib-overlays/darwin/default.nix | 18 +- lib-overlays/disko/default.nix | 5 + lib-overlays/flake-parts/default.nix | 63 +++-- lib-overlays/hjem/default.nix | 9 +- lib-overlays/home-manager/default.nix | 9 +- lib-overlays/integrations/default.nix | 62 ++++- lib-overlays/kubenix/default.nix | 9 +- lib-overlays/nixidy/default.nix | 9 +- lib-overlays/nixos-minimal/default.nix | 2 + lib-overlays/nixos/default.nix | 12 +- lib-overlays/nixpkgs/default.nix | 44 +++- lib-overlays/nixvim/default.nix | 9 +- lib-overlays/nvf/default.nix | 9 +- lib-overlays/system-manager/default.nix | 21 +- lib-overlays/terranix/default.nix | 9 +- lib-overlays/topology/default.nix | 9 +- lib-overlays/treefmt/default.nix | 9 +- tests/dependencies/flake.lock | 6 +- .../flake/nixpkgs-lib-only/default.nix | 18 ++ tests/pinned-world/default.nix | 221 +++++++++++++++++- 24 files changed, 527 insertions(+), 66 deletions(-) diff --git a/flake.lock b/flake.lock index 7166251..ef3f5a1 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "caisson-core": { "locked": { - "lastModified": 1792651257, - "narHash": "sha256-5SMkHLn3uyGkzCl6/VAxLoZ08fRlq9lrhD0JbuO8eUI=", + "lastModified": 1792816405, + "narHash": "sha256-GvBxj7PBDsCeZ9tjSNrCu5MMU4MtEb2iCi22iNgHuMk=", "owner": "nix-caisson", "repo": "caisson-core", - "rev": "9e1bdf63c237d6559bd4291688ae992a9933f67e", + "rev": "2e3394466e09d92b11d2c8af02a889b3a9a9f5e4", "type": "github" }, "original": { diff --git a/lib-overlays/caisson-colmena/default.nix b/lib-overlays/caisson-colmena/default.nix index c16c903..a266125 100644 --- a/lib-overlays/caisson-colmena/default.nix +++ b/lib-overlays/caisson-colmena/default.nix @@ -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"; }; @@ -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 @@ -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 diff --git a/lib-overlays/caisson-disko/default.nix b/lib-overlays/caisson-disko/default.nix index c6fcadb..6db0ce8 100644 --- a/lib-overlays/caisson-disko/default.nix +++ b/lib-overlays/caisson-disko/default.nix @@ -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"; }; @@ -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. @@ -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. @@ -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. diff --git a/lib-overlays/colmena/default.nix b/lib-overlays/colmena/default.nix index dbb463b..be1510f 100644 --- a/lib-overlays/colmena/default.nix +++ b/lib-overlays/colmena/default.nix @@ -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 diff --git a/lib-overlays/darwin/default.nix b/lib-overlays/darwin/default.nix index ec5096b..72bec0a 100644 --- a/lib-overlays/darwin/default.nix +++ b/lib-overlays/darwin/default.nix @@ -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"; }; @@ -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 ++ [ diff --git a/lib-overlays/disko/default.nix b/lib-overlays/disko/default.nix index bd7c66e..9ea6650 100644 --- a/lib-overlays/disko/default.nix +++ b/lib-overlays/disko/default.nix @@ -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 diff --git a/lib-overlays/flake-parts/default.nix b/lib-overlays/flake-parts/default.nix index f598742..3105083 100644 --- a/lib-overlays/flake-parts/default.nix +++ b/lib-overlays/flake-parts/default.nix @@ -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. @@ -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 @@ -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 = [ diff --git a/lib-overlays/hjem/default.nix b/lib-overlays/hjem/default.nix index a835673..500b257 100644 --- a/lib-overlays/hjem/default.nix +++ b/lib-overlays/hjem/default.nix @@ -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"; }; @@ -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 diff --git a/lib-overlays/home-manager/default.nix b/lib-overlays/home-manager/default.nix index 7cc34b3..6b90f60 100644 --- a/lib-overlays/home-manager/default.nix +++ b/lib-overlays/home-manager/default.nix @@ -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"; }; @@ -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 = [ diff --git a/lib-overlays/integrations/default.nix b/lib-overlays/integrations/default.nix index f5274b8..eba4b66 100644 --- a/lib-overlays/integrations/default.nix +++ b/lib-overlays/integrations/default.nix @@ -153,6 +153,50 @@ to mkLib. ''; + # How an evaluation came by the source of the ecosystem `name`, as + # its manifest records it under `ecosystems.`. 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 @@ -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; }) // ( @@ -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; }); }; }; @@ -1653,6 +1710,7 @@ topValue resolveEcosystemSrc selectedEcosystemSrc + ecosystemAccountOf mkIntegration mkAltIntegration frameworkModules diff --git a/lib-overlays/kubenix/default.nix b/lib-overlays/kubenix/default.nix index 8d4c1d5..a5c3ccc 100644 --- a/lib-overlays/kubenix/default.nix +++ b/lib-overlays/kubenix/default.nix @@ -39,7 +39,9 @@ let context = "lib.caisson.kubenix.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "kubenix"; context = "caisson.kubenix"; }; @@ -152,6 +154,11 @@ in { inherit value; + # Where kubenix came from, as `src` was resolved. + ecosystems.kubenix = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What evalModules received: the framework module of the # class, the modules selected from the registry, the # configuration's module and the module that hands the diff --git a/lib-overlays/nixidy/default.nix b/lib-overlays/nixidy/default.nix index ecb49be..f74e687 100644 --- a/lib-overlays/nixidy/default.nix +++ b/lib-overlays/nixidy/default.nix @@ -40,7 +40,9 @@ let context = "lib.caisson.nixidy.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "nixidy"; context = "caisson.nixidy"; }; @@ -112,6 +114,11 @@ in { inherit value; + # Where nixidy came from, as `src` was resolved. + ecosystems.nixidy = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What `mkEnv` received: the modules of the composition, # then nixidy's module list. `mkEnv` appends nixidy's module # list after the modules it is given. diff --git a/lib-overlays/nixos-minimal/default.nix b/lib-overlays/nixos-minimal/default.nix index 1c46522..41b4e8f 100644 --- a/lib-overlays/nixos-minimal/default.nix +++ b/lib-overlays/nixos-minimal/default.nix @@ -61,6 +61,8 @@ inherit (callArgs) lib; }).evalModules (builtins.removeAttrs callArgs [ "lib" ]); + # Where the module collection came from, as `src` was resolved. + ecosystems.nixos = common.srcAccount; # What evalModules received: the modules of the composition, # with no NixOS base modules. modules = common.modules; diff --git a/lib-overlays/nixos/default.nix b/lib-overlays/nixos/default.nix index c9bbf3d..b267e72 100644 --- a/lib-overlays/nixos/default.nix +++ b/lib-overlays/nixos/default.nix @@ -29,7 +29,9 @@ # The library the modules run on is the composed lib, from the # `nixpkgs-lib` key, and the package set is a package config, # from the `nixpkgs` key: three parts, each from a separate key. - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "nixos"; context = "caisson.nixos"; }; @@ -57,6 +59,12 @@ explicit = args.ecosystemSrc or null; manifest = view.lib.caisson-core.libManifest or { }; }; + # Where the module collection came from, as `src` was + # resolved, which an evaluation records as `ecosystems.nixos`. + srcAccount = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = view.lib.caisson-core.libManifest or { }; + }; }; # The evaluator's call, on the view being evaluated: eval-config @@ -92,6 +100,8 @@ in { inherit value; + # Where the module collection came from, as `src` was resolved. + ecosystems.nixos = common.srcAccount; # What eval-config received: NixOS' module list, then the # modules of the composition. modules = [ diff --git a/lib-overlays/nixpkgs/default.nix b/lib-overlays/nixpkgs/default.nix index 30bc2d8..69395a1 100644 --- a/lib-overlays/nixpkgs/default.nix +++ b/lib-overlays/nixpkgs/default.nix @@ -39,7 +39,9 @@ prevNs = (prev.caisson or { }).nixpkgs or { }; selection = final.caisson.integrations; - resolveEcosystemSrc = selection.resolveEcosystemSrc { + resolveEcosystemSrc = selection.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = selection.ecosystemAccountOf ecosystem; + ecosystem = { name = "nixpkgs"; context = "lib.caisson.nixpkgs.mkConfiguration"; }; @@ -124,6 +126,23 @@ # it to the packages as `pkgs.lib` and builds no fixpoint over it. packageSetLib = src: base: + let + sourceLib = builtins.import "${src}/lib"; + in + base + // builtins.listToAttrs ( + builtins.map (name: { + inherit name; + value = sourceLib.${name}; + }) (packageSetNames src) + ); + + # The top-level names of the library at `src` that the lib of a + # package set takes from there, in the order `packageSetLib` takes + # them: the package-set libraries, the tables, then the top-level + # names of the functions of the package-set libraries. + packageSetNames = + src: let sourceLib = builtins.import "${src}/lib"; present = builtins.filter (name: sourceLib ? ${name}); @@ -133,15 +152,8 @@ reExports = builtins.filter ( name: !(builtins.elem name libraries) && memberOf libraries name && !(memberOf general name) ) (builtins.attrNames sourceLib); - names = libraries ++ present packageSetData ++ reExports; in - base - // builtins.listToAttrs ( - builtins.map (name: { - inherit name; - value = sourceLib.${name}; - }) names - ); + libraries ++ present packageSetData ++ reExports; # The package set of nixpkgs at `src`, instantiated as # `pkgs/top-level/default.nix` instantiates it, from arguments @@ -399,6 +411,20 @@ childless = false; inherit (caissonConfig) systems; ecosystemSrc = src; + # Where each part of the stack the sets use came from. The + # general utilities and the module system come from the + # library of the composition. The package set comes from + # `nixpkgs`, and so do the package-set libraries of its lib, + # which `libraries` lists by their top-level names. + ecosystems = { + nixpkgs-lib = selection.ecosystemAccountOf { + name = "nixpkgs-lib"; + context = "the nixpkgs-lib entry"; + } { }; + nixpkgs = ecosystemAccountOf { explicit = args.ecosystemSrc or null; } // { + libraries = packageSetNames src; + }; + }; pkgOverlays = builtins.map (entry: entry.key) ( caissonConfig.overlays ++ caissonConfig.extraOverlays ); diff --git a/lib-overlays/nixvim/default.nix b/lib-overlays/nixvim/default.nix index a5b9981..43e7395 100644 --- a/lib-overlays/nixvim/default.nix +++ b/lib-overlays/nixvim/default.nix @@ -45,7 +45,9 @@ let context = "lib.caisson.nixvim.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "nixvim"; context = "caisson.nixvim"; }; @@ -157,6 +159,11 @@ in { inherit value; + # Where nixvim came from, as `src` was resolved. + ecosystems.nixvim = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What evalModules received: the framework module of the # class, the modules selected from the registry, the # configuration's module, the top-level module tree of nixvim, diff --git a/lib-overlays/nvf/default.nix b/lib-overlays/nvf/default.nix index d9f8440..f8ff8df 100644 --- a/lib-overlays/nvf/default.nix +++ b/lib-overlays/nvf/default.nix @@ -47,7 +47,9 @@ let context = "lib.caisson.nvf.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "nvf"; context = "caisson.nvf"; }; @@ -177,6 +179,11 @@ in { inherit value; + # Where nvf came from, as `src` was resolved. + ecosystems.nvf = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What evalModules received: nvf's module list, then the # modules of the composition. modules = [ diff --git a/lib-overlays/system-manager/default.nix b/lib-overlays/system-manager/default.nix index 98354c9..22b0a27 100644 --- a/lib-overlays/system-manager/default.nix +++ b/lib-overlays/system-manager/default.nix @@ -53,7 +53,9 @@ let context = "lib.caisson.system-manager.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "system-manager"; context = "caisson.system-manager"; }; @@ -61,7 +63,9 @@ # The source of the NixOS module collection the evaluation reads # modules from: the composition's `nixos` key, as for a NixOS # configuration. - resolveNixpkgsSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveNixpkgsSrc = final.caisson.integrations.resolveEcosystemSrc nixosEcosystem; + nixosAccountOf = final.caisson.integrations.ecosystemAccountOf nixosEcosystem; + nixosEcosystem = { name = "nixos"; context = "caisson.system-manager"; }; @@ -280,6 +284,19 @@ in { inherit value; + # Where system-manager came from, as `src` was resolved, and + # where the NixOS module collection came from, as `nixpkgsSrc` + # was resolved. + ecosystems = { + system-manager = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; + nixos = nixosAccountOf { + explicit = null; + manifest = lib.caisson-core.libManifest or { }; + }; + }; # What `makeSystemConfig` received: system-manager's module # list, then the modules of the composition. modules = [ diff --git a/lib-overlays/terranix/default.nix b/lib-overlays/terranix/default.nix index 5300da2..1b20a5e 100644 --- a/lib-overlays/terranix/default.nix +++ b/lib-overlays/terranix/default.nix @@ -39,7 +39,9 @@ let context = "lib.caisson.terranix.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "terranix"; context = "caisson.terranix"; }; @@ -127,6 +129,11 @@ in { inherit value; + # Where terranix came from, as `src` was resolved. + ecosystems.terranix = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What `terranixConfiguration` received: terranix's module # list, then the modules of the composition. modules = [ diff --git a/lib-overlays/topology/default.nix b/lib-overlays/topology/default.nix index eb87105..8b81809 100644 --- a/lib-overlays/topology/default.nix +++ b/lib-overlays/topology/default.nix @@ -42,7 +42,9 @@ let context = "lib.caisson.topology.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "nix-topology"; context = "caisson.topology"; }; @@ -148,6 +150,11 @@ in { inherit value; + # Where nix-topology came from, as `src` was resolved. + ecosystems.nix-topology = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What evalModules received: the topology module tree of # nix-topology, recorded as a module of the nix-topology # source, the module that hands it the NixOS configurations diff --git a/lib-overlays/treefmt/default.nix b/lib-overlays/treefmt/default.nix index 1332210..fa1ac5b 100644 --- a/lib-overlays/treefmt/default.nix +++ b/lib-overlays/treefmt/default.nix @@ -43,7 +43,9 @@ let context = "lib.caisson.treefmt.mkConfiguration"; - resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc { + resolveEcosystemSrc = final.caisson.integrations.resolveEcosystemSrc ecosystem; + ecosystemAccountOf = final.caisson.integrations.ecosystemAccountOf ecosystem; + ecosystem = { name = "treefmt-nix"; context = "caisson.treefmt"; }; @@ -129,6 +131,11 @@ in { inherit value; + # Where treefmt-nix came from, as `treefmt` was resolved. + ecosystems.treefmt-nix = ecosystemAccountOf { + explicit = args.ecosystemSrc or null; + manifest = lib.caisson-core.libManifest or { }; + }; # What evalModules received: treefmt-nix's module list, then # the modules of the composition. modules = [ diff --git a/tests/dependencies/flake.lock b/tests/dependencies/flake.lock index 961af29..f70d13e 100644 --- a/tests/dependencies/flake.lock +++ b/tests/dependencies/flake.lock @@ -2,11 +2,11 @@ "nodes": { "caisson-core": { "locked": { - "lastModified": 1792651257, - "narHash": "sha256-5SMkHLn3uyGkzCl6/VAxLoZ08fRlq9lrhD0JbuO8eUI=", + "lastModified": 1792816405, + "narHash": "sha256-GvBxj7PBDsCeZ9tjSNrCu5MMU4MtEb2iCi22iNgHuMk=", "owner": "nix-caisson", "repo": "caisson-core", - "rev": "9e1bdf63c237d6559bd4291688ae992a9933f67e", + "rev": "2e3394466e09d92b11d2c8af02a889b3a9a9f5e4", "type": "github" }, "original": { diff --git a/tests/integration/nixpkgs-lib-only/configs/flake/nixpkgs-lib-only/default.nix b/tests/integration/nixpkgs-lib-only/configs/flake/nixpkgs-lib-only/default.nix index a52ad32..5f62772 100644 --- a/tests/integration/nixpkgs-lib-only/configs/flake/nixpkgs-lib-only/default.nix +++ b/tests/integration/nixpkgs-lib-only/configs/flake/nixpkgs-lib-only/default.nix @@ -27,6 +27,7 @@ # of the package set's source. fromSet = name: set: lib.hasPrefix "${inputs.nixpkgs}/lib/" (fileOf name set); marked = "marked by the composition"; + inherit (lib.caisson.nixpkgs.pkgSets.default) ecosystems; in { checks.nixpkgs-lib-only = @@ -46,6 +47,23 @@ assert lib.getExe pkgs.hello == marked; assert pkgs.lib.getExe pkgs.hello == upstream.lib.getExe upstream.hello; assert pkgs.lib.splitString "," "a,b" == [ marked ]; + # The package config records where the parts came from. The + # library is a copy the selection builds, so it names no pinned + # source. The package set and its package-set libraries come + # from the source pinned as `nixpkgs`. + assert + ecosystems.nixpkgs-lib == { + from = "defaultEcosystemSrc"; + source = null; + }; + assert ecosystems.nixpkgs.from == "sources" && ecosystems.nixpkgs.source == "nixpkgs"; + assert builtins.all (name: builtins.elem name ecosystems.nixpkgs.libraries) [ + "systems" + "licenses" + "getExe" + "callPackageWith" + ]; + assert !(builtins.elem "compareVersions" ecosystems.nixpkgs.libraries); pkgs.runCommand "nixpkgs-lib-only" { } "touch $out"; }; } diff --git a/tests/pinned-world/default.nix b/tests/pinned-world/default.nix index 55c75f8..5361950 100644 --- a/tests/pinned-world/default.nix +++ b/tests/pinned-world/default.nix @@ -886,6 +886,102 @@ let file = "modules/nixos/default/caisson"; }; + # Each configuration records where each part of the stack it used + # came from. The library of every evaluation is the nixpkgs pin, + # through the `defaultEcosystemSrc` of the tree. The machine selects + # its module collection with its own `ecosystemSrc`, and the + # home-manager configuration inside it selects home-manager the + # same way. The top resolves no ecosystem beside the library. + ecosystemsRecordWhereEachPartCameFrom = + let + top = machineWithHomes.caisson.manifest; + machine = top.children.system.x86_64-linux.children.nixos.probe; + declared = machine.children.system.x86_64-linux.children.home-manager.declared; + library = { + from = "defaultEcosystemSrc"; + source = "nixpkgs"; + }; + in + top.ecosystems == { + nixpkgs-lib = library; + } + && + machine.ecosystems == { + nixpkgs-lib = library; + nixos = { + from = "ecosystemSrc"; + source = "nixpkgs"; + }; + } + && + declared.ecosystems == { + nixpkgs-lib = library; + home-manager = { + from = "ecosystemSrc"; + source = "home-manager"; + }; + }; + + # The configurations of the shared probe trees record where each + # ecosystem they resolved came from. `hiveLib` pins colmena and + # disko under those names and selects nothing for them, so a colmena + # configuration and a disko configuration of either integration + # take the pinned source of that name. A machine inside them takes + # its module collection from the `nixos` of the `defaultEcosystemSrc` + # of the tree. The darwin tree pins nix-darwin, nixpkgs, + # home-manager and hjem under those names. The hjem tree pins hjem + # and selects its module collection as `hiveLib` does. + ecosystemsRecordWhereEachIntegrationsPartsCameFrom = + let + pinned = source: { + from = "sources"; + inherit source; + }; + library = { + from = "defaultEcosystemSrc"; + source = "nixpkgs"; + }; + colmena = + (colmenaTop { probe-node = minimalNixosBase; }).caisson.manifest.children.caisson-colmena.default; + node = colmena.children.system.x86_64-linux.children.nixos.probe-node; + upstreamColmena = upstreamHiveTop.caisson.manifest.children.colmena.default; + caissonDisko = layoutManifest "caisson-disko" (layoutTop { + integration = "caisson-disko"; + layout = luksLvmLayout; + }); + disko = layoutManifest "disko" (layoutTop { + integration = "disko"; + layout = luksLvmLayout; + }); + darwin = import ../darwin-system { inherit inputs; }; + family = darwin.familyManifest; + familyChildren = family.children.system.${darwin.system}.children; + hjem = import ../hjem-system { inherit inputs; }; + in + colmena.ecosystems == { + nixpkgs-lib = library; + colmena = pinned "colmena"; + } + && node.ecosystems.nixos == library + && upstreamColmena.ecosystems.colmena == pinned "colmena" + && + caissonDisko.ecosystems == { + nixpkgs-lib = library; + disko = pinned "disko"; + } + && disko.ecosystems.disko == pinned "disko" + && + family.ecosystems == { + nixpkgs-lib = library; + nix-darwin = pinned "nix-darwin"; + nixpkgs = pinned "nixpkgs"; + } + && familyChildren.home-manager.probe.ecosystems.home-manager == pinned "home-manager" + && familyChildren.hjem.probe.ecosystems.hjem == pinned "hjem" + && hjem.standalone.caisson.manifest.ecosystems.hjem == pinned "hjem" + && hjem.inner.ecosystems.hjem == pinned "hjem" + && hjem.machineManifest.ecosystems.nixos == library; + # A selector that renames and drops configurations, with a note # saying so: the export record holds the published names alone, # each with the name path by the names the configurations are @@ -2575,7 +2671,13 @@ let && rooted.checks.x86_64-linux.treefmt.drvPath == (rootedEvaluation.outputs.check root).drvPath && rooted.formatter.x86_64-linux.drvPath == upstream.drvPath # The configuration `docs` is evaluated. - && builtins.isString children.docs.outputs.wrapper.drvPath; + && builtins.isString children.docs.outputs.wrapper.drvPath + # Each configuration records the treefmt-nix it selects. + && + evaluation.ecosystems.treefmt-nix == { + from = "ecosystemSrc"; + source = "treefmt-nix"; + }; # An nvf configuration is published as # `nvfConfigurations..`, and its Neovim is the one @@ -2666,7 +2768,13 @@ let # the Neovim nvf builds. && topProfile.scope == "user" && topProfile.path == "$HOME/.local/state/caisson/profiles/nvf/editor" - && topProfile.package.drvPath == upstream.drvPath; + && topProfile.package.drvPath == upstream.drvPath + # The configuration records the nvf it selects. + && + top.caisson.manifest.children.system.x86_64-linux.children.nvf.editor.ecosystems.nvf == { + from = "ecosystemSrc"; + source = "nvf"; + }; # A nixvim configuration is published as # `nixvimConfigurations..`, and its package is the one @@ -2699,7 +2807,13 @@ let builtins.attrNames top.nixvimConfigurations == [ "x86_64-linux" ] && top.nixvimConfigurations.x86_64-linux.editor.config.build.package.drvPath - == upstream.config.build.package.drvPath; + == upstream.config.build.package.drvPath + # The configuration records the nixvim it selects. + && + top.caisson.manifest.children.system.x86_64-linux.children.nixvim.editor.ecosystems.nixvim == { + from = "ecosystemSrc"; + source = "nixvim"; + }; # A nixvim configuration declared inside a NixOS machine is a profile # of the system, as an nvf configuration there is. The machine writes @@ -2811,6 +2925,7 @@ let ]; }; topology = top.topology.x86_64-linux; + evaluation = top.caisson.manifest.children.system.x86_64-linux.children.topology.default; in builtins.attrNames top.nixosConfigurations == [ "alpha" @@ -2818,7 +2933,19 @@ let ] && builtins.attrNames topology.config.nodes == builtins.attrNames upstream.config.nodes && builtins.elem "alpha" (builtins.attrNames topology.config.nodes) - && topology.config.output.drvPath == upstream.config.output.drvPath; + && topology.config.output.drvPath == upstream.config.output.drvPath + # The configuration records the nix-topology it selects, and each + # machine inside it the module collection of the tree. + && + evaluation.ecosystems.nix-topology == { + from = "ecosystemSrc"; + source = "nix-topology"; + } + && + evaluation.children.system.x86_64-linux.children.nixos.alpha.ecosystems.nixos == { + from = "defaultEcosystemSrc"; + source = "nixpkgs"; + }; # A kubenix configuration is published as # `kubenixConfigurations..`, its evaluation, whose @@ -2846,7 +2973,13 @@ let upstream = import "${inputs.kubenix}/lib/eval-modules.nix" { inherit pkgs; } { inherit module; }; in top.kubenixConfigurations.x86_64-linux.cluster.config.kubernetes.result.drvPath - == upstream.config.kubernetes.result.drvPath; + == upstream.config.kubernetes.result.drvPath + # The configuration records the kubenix it selects. + && + top.caisson.manifest.children.system.x86_64-linux.children.kubenix.cluster.ecosystems.kubenix == { + from = "ecosystemSrc"; + source = "kubenix"; + }; # A nixidy configuration is published as # `nixidyEnvs..`, and its rendered environment is the @@ -2878,7 +3011,13 @@ let modules = [ module ]; }; in - top.nixidyEnvs.x86_64-linux.prod.environmentPackage.drvPath == upstream.environmentPackage.drvPath; + top.nixidyEnvs.x86_64-linux.prod.environmentPackage.drvPath == upstream.environmentPackage.drvPath + # The configuration records the nixidy it selects. + && + top.caisson.manifest.children.system.x86_64-linux.children.nixidy.prod.ecosystems.nixidy == { + from = "ecosystemSrc"; + source = "nixidy"; + }; # A machine activates the profile inside a hjem configuration as the # user of that hjem configuration and of no other. The machine here @@ -3072,7 +3211,14 @@ let && terraform.name == "config.tf.json" && terraform.passthru.config.terraform.required_version == ">= 1.0" && terraform.passthru.config.output.composed.value - && published.terranixConfigurations.infra.drvPath == terraform.drvPath; + && published.terranixConfigurations.infra.drvPath == terraform.drvPath + # The configuration records the terranix it selects. + && + published.caisson.manifest.children.system.x86_64-linux.children.terranix.infra.ecosystems.terranix + == { + from = "ecosystemSrc"; + source = "terranix"; + }; # A system-manager configuration that is a top is its system, built # for the system of the evaluation, and its modules get the composed @@ -3131,7 +3277,25 @@ let && (runsOn.pinnedWorldProbe or null) == "the set the composition declares" && system.config.services.userborn.package.drvPath == userborn.drvPath && !(builtins.tryEval withOverlay.drvPath).success - && published.systemConfigs.default.drvPath == system.drvPath; + && published.systemConfigs.default.drvPath == system.drvPath + # The configuration records the system-manager it selects, and the + # module collection of the tree it reads NixOS modules from. + && + published.caisson.manifest.children.system.x86_64-linux.children.system-manager.default.ecosystems + == { + nixpkgs-lib = { + from = "defaultEcosystemSrc"; + source = "nixpkgs"; + }; + system-manager = { + from = "ecosystemSrc"; + source = "system-manager"; + }; + nixos = { + from = "defaultEcosystemSrc"; + source = "nixpkgs"; + }; + }; # The ecosystem-args twins take the evaluator's arguments in # `ecosystemArgs`, applied last. @@ -3343,8 +3507,24 @@ let config.probePkgs = pkgs; }; }; + # The manifest of such an evaluation, for its system. + evaluation = + (composedWithDeclaration.caisson-core.finalizeTop ( + composedWithDeclaration.caisson.nixos-minimal.mkConfiguration { configModule = { }; } + )).x86_64-linux; + declared = { + from = "defaultEcosystemSrc"; + source = "pinned-nixpkgs"; + }; in - system.config.probePkgs ? hello; + system.config.probePkgs ? hello + # The evaluation records the library and the module collection it + # took from the declaration. + && + evaluation.ecosystems == { + nixpkgs-lib = declared; + nixos = declared; + }; nixpkgsHelpersWorkOnRealPkgs = let @@ -3385,6 +3565,11 @@ let flake = composedWithBoth.caisson.flake-parts.mkTopConfiguration { configModule = selectors; }; + # The same flake, with flake-parts selected by the configuration. + selecting = composedWithBoth.caisson.flake-parts.mkTopConfiguration { + ecosystemSrc = sources: sources.flake-parts; + configModule = selectors; + }; in builtins.attrNames top.libOverlays == [ "caisson/structural" ] && top.caisson.manifest ? modules @@ -3393,7 +3578,23 @@ let && flake.lib ? caisson && builtins.attrNames flake.lib.caisson-core.evalManifest.outputs.exports.libOverlays - == [ "caisson/structural" ]; + == [ "caisson/structural" ] + # The flake records the flake-parts the tree pins under that name. + && + flake.caisson.manifest.ecosystems.flake-parts == { + from = "sources"; + source = "flake-parts"; + } + # A flake that selects flake-parts runs on it and records the + # selection. + && + builtins.attrNames selecting.lib.caisson-core.evalManifest.outputs.exports.libOverlays + == [ "caisson/structural" ] + && + selecting.caisson.manifest.ecosystems.flake-parts == { + from = "ecosystemSrc"; + source = "flake-parts"; + }; # The modules that caisson exports work only inside an evaluation # that caisson makes. caisson publishes none of them in its From 04be3409e35c3e72e259ed928f64aafcef269684 Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Fri, 23 Oct 2026 22:16:40 -0700 Subject: [PATCH 2/2] maint: lock caisson-core to main Co-Authored-By: Claude Opus 5.5 --- flake.lock | 4 ++-- tests/dependencies/flake.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index ef3f5a1..0b76336 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "caisson-core": { "locked": { - "lastModified": 1792816405, + "lastModified": 1792818841, "narHash": "sha256-GvBxj7PBDsCeZ9tjSNrCu5MMU4MtEb2iCi22iNgHuMk=", "owner": "nix-caisson", "repo": "caisson-core", - "rev": "2e3394466e09d92b11d2c8af02a889b3a9a9f5e4", + "rev": "68fe58454e7f4b49f5254b1270ffa0c6f3b62ca2", "type": "github" }, "original": { diff --git a/tests/dependencies/flake.lock b/tests/dependencies/flake.lock index f70d13e..3adb0a6 100644 --- a/tests/dependencies/flake.lock +++ b/tests/dependencies/flake.lock @@ -2,11 +2,11 @@ "nodes": { "caisson-core": { "locked": { - "lastModified": 1792816405, + "lastModified": 1792818841, "narHash": "sha256-GvBxj7PBDsCeZ9tjSNrCu5MMU4MtEb2iCi22iNgHuMk=", "owner": "nix-caisson", "repo": "caisson-core", - "rev": "2e3394466e09d92b11d2c8af02a889b3a9a9f5e4", + "rev": "68fe58454e7f4b49f5254b1270ffa0c6f3b62ca2", "type": "github" }, "original": {