Template: No-Flake
The noflake template shows that Den works perfectly without Nix flakes (and without flake-parts). It uses npins to lock dependencies and with-inputs to provide flake-like input resolution, all on stable Nix. It configures a single NixOS host with two users, using nix-maid and hjem as lightweight Home-Manager alternatives.
Initialize
Section titled “Initialize”If you have flakes enabled, use nix flake init to scaffold the template:
nix flake init -t github:denful/den#noflakeOtherwise copy the template contents into a fresh directory, then refresh the pinned Den source:
mkdir my-nix && cd my-nixcp -r $(nix eval --raw 'github:denful/den#templates.noflake.path')/* .npins update denProject Structure
Section titled “Project Structure”default.nix # entry point (replaces flake.nix)npins/ default.nix # npins fetcher sources.json # pinned dependencies (den, nixpkgs, import-tree, with-inputs, nix-maid, hjem, …)modules/ den.nix # host/user declarations + aspects nh.nix # den.sh shell apps for building each host/home with nhFile by File
Section titled “File by File”default.nix — Entry Point
Section titled “default.nix — Entry Point”let sources = import ./npins; with-inputs = import sources.with-inputs sources { # uncomment for local checkout on CI den.outPath = ./../..; };
outputs = inputs: (inputs.nixpkgs.lib.evalModules { modules = [ (inputs.import-tree ./modules) ]; specialArgs = { inherit inputs; inherit (inputs) self; }; }).config;
inwith-inputs outputsThis is the noflake equivalent of flake.nix. It uses lib.evalModules directly — the same mechanism Den uses internally.
sources comes from npins. with-inputs (itself a pinned source) reads the flake.nix of each dependency to discover transitive inputs and wires them into a flake-like inputs attrset, then hands them to outputs. The den.outPath line points den at the local checkout; in your own project you can drop it so den resolves from npins.
modules/den.nix — Configuration
Section titled “modules/den.nix — Configuration”{ den, inputs, ... }:{ # we can import this flakeModule even if we dont have flake-parts as input! imports = [ inputs.den.flakeModule ];
den.default.nixos = { # remove for real host fileSystems."/".device = "/dev/fake"; fileSystems."/".fsType = "auto"; boot.loader.grub.enable = false; };
# tux user on igloo host, using nix-maid den.hosts.x86_64-linux.igloo.users = { tux.classes = [ "maid" ]; pingu.classes = [ "hjem" ]; };
# host aspect den.aspects.igloo = { nixos = { pkgs, ... }: { environment.systemPackages = [ pkgs.vim ]; }; };
# include den batteries or your own re-usable aspects # this affects all users, could also be done per user den.schema.user.includes = [ den.batteries.define-user ];
# user aspect den.aspects.tux = { # user configures host <nixos/darwin>.users.users.tux.description user.description = "Cute Penguin";
# user contributes nixos and darwin common config os = { pkgs, ... }: { environment.systemPackages = [ pkgs.hello ]; };
# maid class maid.file.home.".gitconfig".text = '' [user] name=Tux ''; };
den.aspects.pingu = { hjem.files.".foo".text = "bar"; };}Notable differences from the flake templates:
- Uses nix-maid (
maidclass) and hjem (hjemclass) instead of Home-Manager — lighter alternatives. The class is selected per user viausers.<name>.classes. - The
osclass forwards content into bothnixosanddarwin; theuserclass forwards intousers.users.<name>. Both are built-in. den.batteries.define-userdeclares each user at the OS (and Home) level so the chosen class has a user to attach to.
modules/nh.nix — Build Shell
Section titled “modules/nh.nix — Build Shell”{ lib, den, inputs, ... }:{ options.den.sh = lib.mkOption { description = "Non-flake Den shell environment"; default = den.lib.nh.denShell { fromFlake = false; outPrefix = [ "flake" ]; } (import inputs.nixpkgs { }); };}den.lib.nh.denShell builds a mkShell containing one nh wrapper app per declared host and home. fromFlake = false makes the apps use --file . (stable Nix) instead of flake refs, and outPrefix = [ "flake" ] matches where Den places its outputs (see the note under Build).
First make sure Den is current:
npins update denThe template exposes runnable apps under den.sh (one per host/home). The default action is build:
# build the igloo hostnix-run . -A den.sh --run igloo
# or pass any nh action: switch, repl, build, --helpnix-run . -A den.sh --run 'igloo build'You can also build with plain nixos-rebuild or nix-build:
nixos-rebuild build --file . -A flake.nixosConfigurations.igloonix-build -A flake.nixosConfigurations.igloo.config.system.build.toplevelWhat It Provides
Section titled “What It Provides”| Feature | Provided |
|---|---|
| NixOS host configuration | ✓ |
| No flakes required | ✓ |
| No flake-parts required | ✓ |
| npins dependency pinning | ✓ |
nix-maid (maid class) | ✓ |
hjem (hjem class) | ✓ |
nh build apps via den.sh | ✓ |
| Home-Manager | ✗ (uses nix-maid / hjem instead) |
Next Steps
Section titled “Next Steps”- Read Core Principles to understand how Den works without flakes
- Consider the Minimal template if you want flakes but not flake-parts