Skip to content

Template: CI Tests

The CI template is Den’s comprehensive test suite. It tests every feature using nix-unit. This is the best learning resource for understanding exactly how Den behaves.

flake.nix
modules/
empty.nix # example test skeleton
test-support/
eval-den.nix # denTest + evalDen helpers
nix-unit.nix # nix-unit integration
features/
angle-brackets.nix # <den/...> syntax
conditional-config.nix # conditional imports/configs
default-includes.nix # den.default behavior
forward.nix # den._.forward
homes.nix # standalone HM
host-options.nix # host/user schema options
namespaces.nix # namespace define/merge/export
os-user-class.nix # user class forwarding
parametric.nix # parametric functors
schema-base-modules.nix # den.base modules
special-args-custom-instantiate.nix # custom instantiation
top-level-parametric.nix # top-level context aspects
user-host-bidirectional-config.nix # bidirectional providers
batteries/
define-user.nix # define-user battery
flake-parts.nix # inputs' and self'
import-tree.nix # import-tree battery
primary-user.nix # primary-user battery
tty-autologin.nix # tty-autologin battery
unfree.nix # unfree packages
user-shell.nix # user-shell battery
context/
apply.nix # ctx application
apply-non-exact.nix # non-exact matching
cross-provider.nix # cross-provider mechanism
custom-ctx.nix # custom context types
den-default.nix # den.default as context
host-propagation.nix # full host pipeline
named-provider.nix # self-named providers
deadbugs/
_external-namespace-deep-aspect.nix
static-include-dup-package.nix
home-manager/
home-managed-home.nix
use-global-pkgs.nix
non-dendritic/ # non-den files for import-tree tests
provider/ # external namespace provider flake
Test FileWhat It Tests
conditional-config.nixConditional imports using host/user attributes
default-includes.nixden.default applying to all hosts/users
host-options.nixCustom host attributes, hostName, aspect names
top-level-parametric.nixContext-aware top-level aspects
parametric.nixAll parametric functors (atLeast, fixedTo, expands)
Test FileWhat It Tests
user-host-bidirectional-config.nixHost→user and user→host config flow
context/cross-provider.nixSource providing config to target context
context/named-provider.nixSelf-named provider mechanism
Test FileWhat It Tests
context/apply.nixContext application mechanics
context/apply-non-exact.nixNon-exact context matching
context/custom-ctx.nixUser-defined context types with into
context/den-default.nixden.default as a context type
context/host-propagation.nixFull host pipeline with all contributions
Test FileWhat It Tests
batteries/define-user.nixUser definition across contexts
batteries/primary-user.nixPrimary user groups
batteries/user-shell.nixShell configuration
batteries/unfree.nixUnfree package predicates
batteries/tty-autologin.nixTTY autologin service
batteries/import-tree.nixAuto-importing class dirs
batteries/flake-parts.nixinputs' and self' providers
Test FileWhat It Tests
angle-brackets.nixAll bracket resolution paths
namespaces.nixLocal, remote, merged namespaces
forward.nixCustom class forwarding
homes.nixStandalone Home-Manager configs
schema-base-modules.nixden.base.{host,user,home,conf}
Test FileWhat It Tests
deadbugs/static-include-dup-package.nixDuplicate deduplication for packages/lists
deadbugs/_external-namespace-deep-aspect.nixDeep aspect access from external flakes

The provider/ subdirectory is a separate flake that defines a namespace provider with aspects. It’s used by the deadbugs test to verify cross-flake namespace consumption:

provider/modules/den.nix
{ inputs, ... }:
{
imports = [ inputs.den.flakeModule (inputs.den.namespace "provider" true) ];
provider.tools._.dev._.editors = {
nixos.programs.vim.enable = true;
};
}

From the Den root against your local checkout:

Terminal window
nix flake check --override-input den . ./templates/ci

You can also run a single or a subset of tests using:

Terminal window
# You can use any attr-path bellow flake.tests after system-agnositc to run those specific tests:
nix-unit --override-input den . --flake ./templates/ci#.tests.systems.x86_64-linux.system-agnostic

Copy modules/empty.nix as a starting point:

{ denTest, ... }:
{
flake.tests.my-feature = {
test-name = denTest (
{ den, igloo, ... }:
{
den.hosts.x86_64-linux.igloo.users.tux = { };
expr = /* what you get */;
expected = /* what you expect */;
}
);
};
}
Contribute Community Sponsor