Skip to content

Template: Bug Reproduction

This template helps you create minimal Den reproductions.

Use it for:

  • Showcasing focused demos of how you are trying to use Den.
  • Reducing a problem to its minimum outside of your infra.
  • Sharing code that exposes an unknown bug.
  • Contributing bug fixes to Den core.

All PRs modifying this template are run by Den CI on the following Den versions: PR_HEAD, main, latest.

Feel free to send any PR even if you don’t know if it is an actual bug or if you don’t know the solution.

Just having an small, focused example can help Den maintainers a lot. We can together determine if there’s something we need to fix in Den.

If you wish to contribute a fix, you are more than welcome, just mention you’d like to work on this at the PR.

Terminal window
mkdir bogus && cd bogus
nix flake init -t github:vic/den#bogus
nix flake update den
flake.nix
modules/
bug.nix # your bug reproduction
test-base.nix # test infrastructure (DO NOT EDIT)

Edit modules/bug.nix with a minimal test case:

{ denTest, ... }:
{
flake.tests.bogus = {
test-something = denTest (
{ den, lib, igloo, tuxHm, ... }:
{
den.hosts.x86_64-linux.igloo.users.tux = { };
# set up the scenario
den.aspects.igloo.nixos.environment.sessionVariables.FOO = ["foo" "bar"];
# what you get
expr = igloo.environment.sessionVariables.FOO;
# what you expect
expected = "foo:bar";
}
);
};
}

denTest is a helper that:

  1. Creates a fresh Den evaluation with your module
  2. Provides helpers like igloo (host config), tuxHm (user’s HM config)
  3. Compares expr against expected using nix-unit

Available test helpers (from test-base.nix):

HelperDescription
igloonixosConfigurations.igloo.config
icebergnixosConfigurations.iceberg.config
tuxHmigloo.home-manager.users.tux
pinguHmigloo.home-manager.users.pingu
funnyNamesResolves an aspect for class "funny" and collects .names
tracetraces included aspect names

If you want to see some examples, take a look at other bogus reports that are now part of Den repository at:

Terminal window
ls den/templates/ci/modules/features/deadbugs/*.nix
Terminal window
# From the bogus root
nix flake check
Terminal window
# From the Den root
just bogus

Edit Den /nix or /modules code and run:

Terminal window
just bogus

When your changes to Den have fixed the bug, be sure to move bug.nix into the templates/ci/modules/feautres/deadbugs/ directory, following naming conventions for both the file and test-suite name.

FeatureProvided
nix-unit test infrastructure
Pre-configured denTest helper
Version matrix testing
Common test helpers
Contribute Community Sponsor