Skip to content

feat(class): Classes for flake exposed system outputs#346

Merged
vic merged 1 commit intomainfrom
push-muyyvkqmllmv
Mar 31, 2026
Merged

feat(class): Classes for flake exposed system outputs#346
vic merged 1 commit intomainfrom
push-muyyvkqmllmv

Conversation

@vic
Copy link
Copy Markdown
Member

@vic vic commented Mar 30, 2026

Changeset Summary

Moved forward into nix/lib

forward proved to be a core combinator, moving it to lib allows to be used outside of Den's NixOS framework.

Forward based Ouputs

Now all nixosConfigurations,homeConfigurations,etc are now generated via forward itself, accumulating into a flake-class module

Flake System Outputs

Den now supports exposing to flake outputs via aspects.

The following classes were added (each named after the corresponding flake output attribute): packages, apps, checks, legacyPackages, devShells. All these are per-system outputs.

Usage:

See templates/ci/modules/features/forward-flake-level.nix for all tests

den.aspects.foo = {
  packages = { pkgs, ... }: { inherit hello; };
  devShells = { pkgs, ... }: {
    default = pkgs.mkShell { buildInputs = [ pkgs.hello ]; };
  };
}

# Enable flake output attributes
imports = with inputs.den.flakeOutputs; [ packages devShells ];

# Include aspects that produce per system flake outputs:
den.ctx.flake-system.includes = [ den.aspects.foo ];

You can also make all your hosts produce flake-level outputs by simply
creating a context transition { system } -> { host }:

den.ctx.flake-system.into.host = { system }:
  map (host: { inherit host; }) (lib.attrValues den.hosts.${system});

flakeOutputs.* modules. See #317

Den now provides the following modules under inputs.den.flakeOutputs.*

  • flake: creates a generic options.flake top-level option. Used only when no inputs.flake-parts is available to avoid collision with flake-parts.
  • nixosConfigurations: creates options.flake.nixosConfigurations
  • darwinConfigurations
  • homeConfigurations
  • packages: creates per-system options.flake.packages
  • apps
  • checks
  • devShells
  • legacyPackages

You will only need to import these on your flake (like we did in the previous code example) if you want to enable those flake outputs being written by Den.

den.systems option

This option is used by den.ctx.system to know what systems to produce outputs for.
It default to config.systems (flake-parts top-level system if it exists), or systems of den.hosts + den.hosmes, or if those were empty: lib.systems.flakeExposed

nvf-standalone using packages output

Our nvf example was the first iteration on producing packages from Den aspects, it has been updated to use den.ctx.flake-packages now.

@vic vic added the allow-ci allow all CI integration tests label Mar 30, 2026
@vic vic force-pushed the push-muyyvkqmllmv branch 13 times, most recently from 814b812 to 4317b90 Compare March 31, 2026 16:17
@vic vic force-pushed the push-muyyvkqmllmv branch from 4317b90 to ecc4273 Compare March 31, 2026 16:32
@vic vic changed the title WIP: move forward to lib feat(class): Classes for flake exposed system outputs Mar 31, 2026
@vic vic merged commit d02f2d6 into main Mar 31, 2026
15 of 16 checks passed
@vic vic deleted the push-muyyvkqmllmv branch March 31, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-ci allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant