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.
Initialize
Section titled “Initialize”mkdir bogus && cd bogusnix flake init -t github:vic/den#bogusnix flake update denProject Structure
Section titled “Project Structure”flake.nixmodules/ bug.nix # your bug reproduction test-base.nix # test infrastructure (DO NOT EDIT)Writing a Bug Reproduction
Section titled “Writing a Bug Reproduction”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"; } ); };}How denTest Works
Section titled “How denTest Works”denTest is a helper that:
- Creates a fresh Den evaluation with your module
- Provides helpers like
igloo(host config),tuxHm(user’s HM config) - Compares
expragainstexpectedusing nix-unit
Available test helpers (from test-base.nix):
| Helper | Description |
|---|---|
igloo | nixosConfigurations.igloo.config |
iceberg | nixosConfigurations.iceberg.config |
tuxHm | igloo.home-manager.users.tux |
pinguHm | igloo.home-manager.users.pingu |
funnyNames | Resolves an aspect for class "funny" and collects .names |
trace | traces 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:
ls den/templates/ci/modules/features/deadbugs/*.nixRun Tests
Section titled “Run Tests”# From the bogus rootnix flake check# From the Den rootjust bogusContributing a Fix
Section titled “Contributing a Fix”Edit Den /nix or /modules code and run:
just bogusWhen 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.
What It Provides
Section titled “What It Provides”| Feature | Provided |
|---|---|
| nix-unit test infrastructure | ✓ |
| Pre-configured denTest helper | ✓ |
| Version matrix testing | ✓ |
| Common test helpers | ✓ |
Next Steps
Section titled “Next Steps”- Read Debug Configurations for debugging techniques
- See the CI Tests template for Den’s own comprehensive test suite