9.4 KiB
- For den migration, move legacy non-flake-parts modules into
modules/_legacy/before enablinginputs.import-tree ./modules; import-tree ignores underscore-prefixed paths. flake-partsmust includeinputs.nixpkgs-lib.follows = "nixpkgs"in this repository to match den bootstrap expectations.- The den bootstrap works with
modules/dendritic.niximporting(inputs.flake-file.flakeModules.dendritic or { })and(inputs.den.flakeModules.dendritic or { }), plus initialflake-file.inputsdeclarations. - Den host wiring uses
den.hosts.<system>.<hostname>.users.<username> = {}declarations inmodules/hosts.nixfor each host-user pair. den.default.includesaccepts batteries directly viaden.provides.*; this bootstrap usesden.provides.define-userandden.provides.inputs'.- In this flake-parts setup, declaring
options.flake.darwinConfigurationsaslib.types.lazyAttrsOf lib.types.rawallows multiple Darwin hosts to merge correctly.
Task 3: Utility functions under _lib/ - COMPLETED
What was done:
- Created
modules/_lib/directory - Copied 5 pure function files (not NixOS modules):
lib/constants.nix→modules/_lib/constants.nix(14 lines)lib/build-rust-package.nix→modules/_lib/build-rust-package.nix(20 lines)profiles/wallpaper.nix→modules/_lib/wallpaper.nix(11 lines)profiles/open-project.nix→modules/_lib/open-project.nix(10 lines)profiles/packages.nix→modules/_lib/packages.nix(67 lines)
Key insight:
- import-tree ignores paths with
/_prefix, somodules/_lib/is safe for pure functions - These files are NOT NixOS/home-manager modules - they're utility functions that would crash import-tree if placed directly under
modules/ - Files were COPIED (not moved) because old locations are still referenced by existing host configs until Task 26
Verification:
- All 5 files copied with identical content (byte-for-byte match)
alejandra --check modules/_lib/passed (formatting compliant)nix flake showexits 0 (import-tree correctly ignores_lib/)
Dependencies:
- Unblocks Task 4 (overlays need
build-rust-package.nixfrom_lib/)
Task 2: Hosts and defaults bootstrap notes
- Den host wiring uses
den.hosts.<system>.<hostname>.users.<username> = {}declarations inmodules/hosts.nixfor each host-user pair. den.default.includesaccepts batteries directly viaden.provides.*; this bootstrap usesden.provides.define-userandden.provides.inputs'.- In this flake-parts setup, declaring
options.flake.darwinConfigurationsaslib.types.lazyAttrsOf lib.types.rawallows multiple Darwin hosts to merge correctly.
Task 5: Core aspect module - COMPLETED
What was done:
- Created
modules/core.nixas a flake-parts module definingden.aspects.core - Ported all nix settings from
profiles/core.nixinto theosclass (applies to both nixos and darwin) - Updated
modules/defaults.nixto includeden.aspects.coreinden.default.includes
Key decisions:
- Used
osclass for shared settings (fish, nushell, nixpkgs.config.allowUnfree, nix package, substituters, trusted-public-keys, gc.automatic, gc.options, experimental-features) - Deliberately EXCLUDED
trusted-usersfrom core.nix (platform-specific: darwin uses "@admin", NixOS uses specific user — handled by darwin.nix and nixos-system.nix) - Deliberately EXCLUDED gc interval/dates (platform-specific: darwin uses
interval, NixOS usesdates— handled by darwin.nix and nixos-system.nix)
Verification:
modules/core.nixcreated with 35 lines (exact port of profiles/core.nix settings)modules/defaults.nixupdated to includeden.aspects.corein includes listalejandra .formatted both files successfullynix flake showexits 0 (flake evaluates cleanly)
Dependencies:
- Unblocks Task 6 (darwin.nix and nixos-system.nix can now reference den.aspects.core)
Task 6a: NixOS system aspect - COMPLETED
What was done:
- Created
modules/nixos-system.nixas a flake-parts module definingden.aspects.nixos-system - Ported NixOS-specific config from
profiles/nixos.nixinto thenixosclass
Key decisions:
- Used
nixosclass (notos) since all settings are NixOS-specific (sudo, boot, systemd-boot, users) nixosclass uses NixOS module function form{pkgs, ...}: { ... }to accesspkgsforlinuxPackages_latestandnushellinputsaccessed from outer flake-parts module args forhome-manager.nixosModules.home-managerimport- Hardcoded "cschmatzler" instead of variable interpolation (user is always the same)
- Hardcoded SSH keys inline instead of referencing constants (simplifies dependency)
- Deliberately EXCLUDED: system.stateVersion (in defaults.nix), sops.age.sshKeyPaths (in secrets.nix), home-manager.sharedModules/_module.args (den handles via inputs' battery)
Pattern:
- Outer function:
{inputs, ...}:— flake-parts module args - Inner class:
nixos = {pkgs, ...}: { ... }— NixOS module function imports = [inputs.home-manager.nixosModules.home-manager]inside the nixos class
Verification:
alejandra --check .passes (already compliant on write)nix flake showexits 0 (both michael and tahani evaluate cleanly)
Task 6b: Darwin system aspect - COMPLETED
What was done:
- Created
modules/darwin.nixas a flake-parts module definingden.aspects.darwin-system - Created
modules/_darwin/dock.nix— the dock module (NixOS-style with options/config) - Ported profiles/darwin.nix, profiles/dock.nix, profiles/homebrew.nix, and nix-homebrew config
Files created:
modules/darwin.nix— flake-parts module withden.aspects.darwin-system.darwinclassmodules/_darwin/dock.nix— dock options+activation script module (underscore prefix avoids import-tree)
Key decisions:
darwinclass uses NixOS module function form{pkgs, ...}: { ... }to accesspkgs.nushellinputsaccessed from outer flake-parts module args via closure (for nix-homebrew, home-manager, homebrew taps)- Dock module placed in
modules/_darwin/dock.nixand imported viaimports = [./_darwin/dock.nix]inside the darwin class - All
uservariable references replaced with hardcoded "cschmatzler" - Excluded: home-manager.extraSpecialArgs (den handles via batteries), system.stateVersion (in defaults.nix)
- nix-homebrew config wired with taps from flake inputs (homebrew-core, homebrew-cask)
Pattern for complex sub-modules:
- Use
modules/_<platform>/prefix (underscore avoids import-tree auto-import) - Import from aspect class via
imports = [./_darwin/dock.nix] - The inner NixOS module function captures
inputsfrom outer flake-parts scope via Nix closure
Verification:
alejandra .— already compliant on write (no changes needed)nix flake showexits 0 (flake evaluates cleanly with new aspect)
Task 23: Michael aspect with absorbed gitea module - COMPLETED
- Created
modules/_hosts/michael/and copiedhosts/michael/disk-config.nixplushosts/michael/hardware-configuration.nixbyte-for-byte into underscore-prefixed paths so import-tree ignores them. - Added
modules/michael.nixdefiningden.aspects.michaelwith includesden.aspects.nixos-system,den.aspects.core, andden.aspects.cschmatzler. - Inlined the full gitea/redis/litestream/caddy/restic/systemd config directly in the michael aspect and removed dependency on
options.my.gitea. - Preserved intentional
lib.mkForceoverrides for litestream and restic service users/groups. - Replaced legacy
cfg.*references with concrete values and SOPS paths: litestream bucketmichael-gitea-litestream, restic bucketmichael-gitea-repositories, endpoints3.eu-central-003.backblazeb2.com, andconfig.sops.secrets.michael-gitea-*.path.
Task 25: Tahani aspect with host sub-files - COMPLETED
-
Created
modules/_hosts/tahani/and copiedhosts/tahani/{adguardhome,cache,networking,paperless}.nixbyte-for-byte into underscore-prefixed paths so import-tree ignores host-only sub-files. -
Added
modules/tahani.nixdefiningden.aspects.tahaniwith includesden.aspects.nixos-system,den.aspects.core, andden.aspects.cschmatzler(network aspects intentionally deferred). -
Ported tahani-specific NixOS settings into the aspect (
networking.hostName, docker enablement, docker group membership forcschmatzler, and 16 GiB swapfile declaration). -
Ported tahani-specific Home Manager settings into the aspect (
programs.git.settings.user.email, zellij Nushell integration override enabled for tahani). -
Inbox-triage systemd unit now uses
pkgs.himalayafrom overlay inPATH(${pkgs.himalaya}/bin) withinputs'.llm-agents.packages.opencodeforExecStart; noconfig.home-manager.users...lookup. -
Verification:
alejandra .,alejandra --check ., andnix flake showall pass;lsp_diagnosticsis clean on all newly created tahani files. -
Home Manager
programs.nushellmodule writesconfig.nuas a merge of:environmentVariables(viaload-env), flattenedsettings, optionalconfigFile.text, thenextraConfig, then generatedshellAliases(see HMmodules/programs/nushell.nix). So any duplication inconfig.nuthat is isolated toextraConfigalmost always means the option value was merged multiple times (module included multiple times), not that HM writes it twice. -
In Den, HM user contexts include both the host aspect chain and the user aspect (
den.ctx.user). If you also include the user aspect from the host aspectincludes, user HM config is applied twice.