Skip to content
Closed
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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ source by.
| `nixos-minimal` | `nixpkgs` | the `nixos` class under the minimal evaluator (no NixOS base modules); a second integration over the class `nixos` owns |
| `home-manager` | `home-manager` | Home Manager configurations |
| `home-manager-minimal` | `home-manager` | the `homeManager` class with Home Manager's necessary modules alone, the configuration importing what it uses from `modulesPath`; a second integration over the class `home-manager` owns |
| `hjem` | `hjem` | the files and packages of a user, as hjem manifests; activated by the NixOS configuration they are declared inside, or applied with `hjem standalone` |
| `hjem` | `hjem` | the files and packages of a user, as hjem manifests; activated by the NixOS, darwin or system-manager configuration they are declared inside, or applied with `hjem standalone` |
| `terranix` | `terranix` | Terraform configurations written as terranix modules, published as `terranixConfigurations` of the `config.tf.json` files Terraform reads |
| `caisson-colmena` | `colmena` | colmena configurations whose machines are NixOS configurations declared inside them, published as the hive colmena's command reads; the colmena integration we recommend for new configurations |
| `colmena` | `colmena` | a hive written for colmena, taken as it is, with each node a NixOS configuration; for porting an existing hive and the modules written for it |
Expand All @@ -133,7 +133,12 @@ source by.
| `caisson-facter` | none | the hardware of a machine, a nixos-facter report checked against the report versions caisson knows and extended with a project's own options, with the NixOS configurations that run on it declared inside it; a machine gets the report through nixpkgs' `hardware.facter` |
| `facter` | none | a `facter.json` as nixos-facter writes it, with the NixOS configurations that run on it declared inside it; a machine gets it as `hardware.facter.reportPath` |
| `treefmt` | `treefmt-nix` | the formatters of a tree, as treefmt-nix modules; the configuration named `default` is published as the `formatter.<system>` that `nix fmt` runs |
| `system-manager` | `system-manager` | the systems of machines running another Linux distribution, published as the `systemConfigs` that `system-manager switch` reads |
| `nvf` | `nvf` | a Neovim written as nvf modules, published as `packages.<system>.<name>`, kept in a Nix profile of its own that the machine, home or hjem configuration it is declared inside activates |
| `nixvim` | `nixvim` | a Neovim written as nixvim modules, published as `nixvimConfigurations.<system>.<name>`, kept in a profile as an nvf configuration is |
| `topology` | `nix-topology` | the diagram of the NixOS configurations declared inside it, as nix-topology renders it; the configuration named `default` is published as `topology.<system>` |
| `kubenix` | `kubenix` | Kubernetes resources written as kubenix modules, published as `packages.<system>.<name>`, the JSON `kubectl apply -f` reads |
| `nixidy` | `nixidy` | an Argo CD environment written as nixidy modules, evaluated with nixidy's `mkEnv` and published as the `nixidyEnvs.<system>.<name>` the nixidy CLI reads |
| `system-manager` | `system-manager` | the systems of machines running another Linux distribution, published as the `systemConfigs` that `system-manager switch` reads; they activate the homes and hjem configurations declared inside them, and the profiles of the nvf and nixvim configurations declared inside them |
| `structural` | none | a configuration that only exports and holds configurations beneath it: the top of a repository whose point is what it exports, such as caisson itself, or a layer at any depth |

Each integration finds its ecosystem in this order: the `ecosystemSrc`
Expand Down
4 changes: 2 additions & 2 deletions configs/flake/caisson/partitions/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
};
in
builtins.seq suite.summary (pkgs.runCommand "pinned-world" { } "touch $out");
# The manifest file of an hjem configuration inside a NixOS
# The manifest file of a hjem configuration inside a NixOS
# machine and the units that activate it, built. Building
# the manifest file checks it against hjem's own schema
# with `cue vet`, so the file the machine activates is one
Expand Down Expand Up @@ -297,7 +297,7 @@
};
};
in
# The bare machine, and the machine with a home and an hjem
# The bare machine, and the machine with a home and a hjem
# configuration inside it, whose system holds the activation
# of the home and the launchd agents of hjem.
probe.pkgs.linkFarm "darwin-system" [
Expand Down
5 changes: 5 additions & 0 deletions configs/structural/impl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
terranix
system-manager
treefmt
nvf
nixvim
topology
kubenix
nixidy
;
};

Expand Down
3 changes: 2 additions & 1 deletion docs/development/repository-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ The layer users reach for: the integrations (`structural`,
`flake-parts`, `nixpkgs`, `nixos`, `nixos-minimal`, `home-manager`,
`home-manager-minimal`, `darwin`, `hjem`, `caisson-colmena`, `colmena`,
`caisson-disko`, `disko`, `caisson-facter`, `facter`, `terranix`,
`system-manager`, `treefmt`), each
`system-manager`, `treefmt`, `nvf`, `nixvim`, `topology`, `kubenix`,
`nixidy`), each
a library overlay
contributing its `lib.caisson` namespace, registering its module
class where it has a class (`nixos-minimal` and `home-manager-minimal`
Expand Down
4 changes: 2 additions & 2 deletions docs/development/testing-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ The checks partition merges outputs from all test and example flakes into the
| `literate-flake-greeting` | `examples/literate-flake/` | Example greeting package builds |
| `debug-disabled` | `checks.nix` (inline) | `self.debug` is not exposed in production |
| `pinned-world` | `checks.nix` + `tests/pinned-world/` | caisson composed with the pinned upstream world (nixpkgs, home-manager, colmena, disko, nix-darwin, hjem, terranix, system-manager) evaluates end to end; the `drift` workflow runs the same check against advanced pins |
| `hjem-system` | `checks.nix` + `tests/hjem-system/` | The manifest file of an hjem configuration inside a NixOS machine builds, which checks it against hjem's schema with `cue vet`, and so do the units that activate it, which runs shellcheck on their scripts |
| `darwin-system` (aarch64-darwin) | `checks.nix` + `tests/darwin-system/` | The two macOS machines of the pinned-world suite, declared through the darwin integration, build: the bare machine, and the machine with a home and an hjem configuration inside it; the `darwin-build` job of the check workflow builds them on a macOS runner |
| `hjem-system` | `checks.nix` + `tests/hjem-system/` | The manifest file of a hjem configuration inside a NixOS machine builds, which checks it against hjem's schema with `cue vet`, and so do the units that activate it, which runs shellcheck on their scripts |
| `darwin-system` (aarch64-darwin) | `checks.nix` + `tests/darwin-system/` | The two macOS machines of the pinned-world suite, declared through the darwin integration, build: the bare machine, and the machine with a home and a hjem configuration inside it; the `darwin-build` job of the check workflow builds them on a macOS runner |
| `argument-errors` | `checks.nix` + `tests/argument-errors/` | The argument error of every entry point comes from Nix itself, raised at the call site with no frame of caisson |
| `eval-weight` | `checks.nix` + `tests/eval-weight/` | Framework evaluation cost held to committed ceilings ([guide](https://nix-caisson.github.io/docs/eval-weight.html)) |
2 changes: 1 addition & 1 deletion docs/development/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ plumbing works.
configuration, a NixOS system with homes declared inside it, a
colmena hive, disk layouts with the machines installed onto them, a
darwin machine evaluated at aarch64-darwin with and without a home
and an hjem configuration inside it, hjem configurations on
and a hjem configuration inside it, hjem configurations on
their own and inside a NixOS machine, a terranix and a system-manager
configuration, and the composition guarantees of the real exported
overlays. The `hjem-system` check builds the manifest file of the hjem
Expand Down
10 changes: 7 additions & 3 deletions lib-overlays/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# The darwin integration: it owns the `darwin` class and evaluates it
# with nix-darwin's `eval-config.nix`, over the composed library. A
# darwin configuration is a macOS machine, evaluated at every system
# in force where it is declared, as a NixOS configuration is, and
# darwin configuration is a macOS machine, evaluated per system,
# once for each system in force where it is declared, as a NixOS configuration is, and
# published as `darwinConfigurations.<name>`, the value `darwin-rebuild`
# reads: the evaluated configuration with its `system` beside it.
#
Expand Down Expand Up @@ -159,11 +159,15 @@
args:
final.caisson.integrations.mkModuleConfiguration {
type = "darwin";
# A darwin configuration is evaluated at a system: it has an
# A darwin configuration is evaluated per system: it has an
# evaluation for every system in force where it is declared.
perSystem = true;
defaultPkgs = args.defaultPkgs or null;
inherit exportsTo;
# A darwin configuration is activated on a machine; the
# configurations with an activation declared inside it check
# its marker.
activation = final.caisson.integrations.machineActivation;
evaluate = evaluate args;
};

Expand Down
58 changes: 44 additions & 14 deletions lib-overlays/hjem/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: MIT
#
# The hjem integration: it owns the `hjem` class, hjem's class for the
# files and packages of a user. An hjem configuration is the home of a
# user, evaluated at every system in force where it is declared.
# files and packages of a user. A hjem configuration is the home of a
# user, evaluated per system, once for each system in force where it is declared.
#
# hjem itself evaluates a user only inside its NixOS and nix-darwin
# modules, as a submodule of `hjem.users`; its standalone CLI evaluates
Expand Down Expand Up @@ -52,7 +52,7 @@
context = "caisson.hjem";
};

# An hjem source: the hjem flake or source tree, which holds the
# A hjem source: the hjem flake or source tree, which holds the
# user module and hjem's library.
assertHjemSrc =
ecosystemSrc:
Expand All @@ -66,7 +66,7 @@
then
ecosystemSrc
else
throw "${context} requires `ecosystemSrc` to be an hjem flake or source tree (holding modules/common/user.nix and lib.nix).";
throw "${context} requires `ecosystemSrc` to be a hjem flake or source tree (holding modules/common/user.nix and lib.nix).";

# The manifest of an evaluated user, as hjem's OS modules write
# it: version 3, with an entry for every enabled file of the
Expand Down Expand Up @@ -130,23 +130,37 @@
null;

# The machine the configuration is declared inside, when there
# is one: the childless evaluation of the nearest NixOS or
# darwin configuration above it, which hjem's modules receive
# as `osConfig`, null when there is none.
# is one: the childless evaluation of the nearest NixOS,
# darwin or system-manager configuration above it, which hjem's
# modules receive as `osConfig`, null when there is none. A
# system-manager evaluation is its system, with the
# configuration and the options in its `passthru`.
machine = selection.nearestOf [
"nixos"
"darwin"
"system-manager"
] manifest;
osConfig = if machine != null then machine.value.config else null;

# A user hjem's NixOS module embeds also imports hjem's
# `modules/nixos/systemd.nix`, which declares the user's
# systemd units and links them into the user's files, with the
# `utils` and the options of the machine. A configuration inside
# a NixOS machine that has `utils` gets the same; the minimal
# NixOS evaluator gives none.
machineArgs = if machine != null then (machine.value._module or { }).args or { } else { };
nixosUser = machine != null && machine.type == "nixos" && machineArgs ? utils;
# a NixOS or system-manager machine that has `utils` gets the
# same; the minimal NixOS evaluator gives none.
machineArgs =
if machine == null then
{ }
else
(machine.value._module or { }).args
or (((machine.value.options or { })._module or { }).args.value or { });
nixosUser =
machine != null
&& builtins.elem machine.type [
"nixos"
"system-manager"
]
&& machineArgs ? utils;

# What hjem's OS modules set on a user that caisson sets too:
# the user's name from the name the configuration is declared
Expand Down Expand Up @@ -232,7 +246,7 @@
};
};

# An hjem configuration is published as
# A hjem configuration is published as
# `hjemConfigurations.<name>`, with `manifest` and `packages`,
# which is what `hjem standalone switch --flake` reads.
exportsTo = {
Expand All @@ -242,7 +256,7 @@
};
};

# What a reader of a file gets from an hjem configuration that is
# What a reader of a file gets from a hjem configuration that is
# a top: `manifest` and `packages`, which `hjem standalone switch
# --config` reads, and the manifest of the evaluation under
# `caisson.manifest`. hjem's CLI serializes the whole value with
Expand Down Expand Up @@ -273,14 +287,30 @@
args:
final.caisson.integrations.mkModuleConfiguration {
type = "hjem";
# An hjem configuration is evaluated at a system: it has an
# A hjem configuration is evaluated per system: it has an
# evaluation for every system in force where it is declared.
perSystem = true;
defaultPkgs = args.defaultPkgs or null;
inherit exportsTo;
# A hjem configuration is activated for its user. Its
# identity is its manifest file; its marker is a file in the
# directory of the user, which the hjem module
# `activation-marker` adds to the files of the configuration.
# The configurations with an activation declared inside it
# check the marker.
activation = {
identity = manifest: manifest.outputs.manifestFile.outPath;
marker =
manifest:
"${manifest.value.config.directory}/${markerDirectory}/${final.caisson.integrations.markerFileName manifest}";
};
evaluate = evaluate args;
};

# The directory, relative to the directory of the user, that holds
# the marker of a hjem configuration.
markerDirectory = ".local/state/caisson/markers";

integration = final.caisson.integrations.mkIntegration {
name = "hjem";
class = "hjem";
Expand Down
21 changes: 17 additions & 4 deletions lib-overlays/home-manager/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# contributes the declared home-manager's library to the composition
# as `lib.hm`, and evaluates the class over the composed library with
# home-manager's module list. A home is a configuration: it is
# evaluated at every system in force where it is declared, on the
# evaluated per system, once for each system in force where it is declared, on the
# package set in force there, and a top publishes it under
# `homeConfigurations`.
#
Expand Down Expand Up @@ -235,7 +235,8 @@
};

# The machine the home is declared inside, when there is one:
# the nearest NixOS or darwin configuration above the home, so
# the nearest NixOS, darwin or system-manager configuration
# above the home, so
# a structural configuration between the two changes nothing.
# The manifest holds the childless evaluation of that machine,
# which is the evaluation that leaves out the configurations
Expand Down Expand Up @@ -476,6 +477,7 @@
machineTypes = [
"nixos"
"darwin"
"system-manager"
];

# A home is published as `homeConfigurations.<name>`, the
Expand Down Expand Up @@ -509,11 +511,22 @@
variant: args:
selection.mkModuleConfiguration {
type = "home-manager";
# A home is evaluated at a system: it has an evaluation for
# A home is evaluated per system: it has an evaluation for
# every system in force where it is declared.
perSystem = true;
defaultPkgs = args.defaultPkgs or null;
inherit exportsTo;
# A home is activated for its user. Its identity is its
# activation package; its marker is a file under
# `$HOME/.local/state`, named by `$HOME` and not by
# `$XDG_STATE_HOME`, which a unit of the machine and a shell
# may see differently. The home-manager module
# `activation-marker` writes. The configurations with an
# activation declared inside the home check it.
activation = {
identity = manifest: manifest.outputs.activationPackage.outPath;
marker = manifest: "$HOME/.local/state/caisson/markers/${selection.markerFileName manifest}";
};
evaluate = evaluation variant args;
};

Expand All @@ -531,7 +544,7 @@
# `caisson.home-manager.configurations.<name>` finalizes it,
# and `mkTopConfiguration` finalizes it at a top.
# `lib.caisson.home-manager-minimal` takes the same arguments.
# The home is evaluated at every system in force where it is
# The home is evaluated per system, once for each system in force where it is
# declared, and its package sets come from the composition,
# through the manifest; `defaultPkgs` selects the set it runs
# on.
Expand Down
Loading
Loading