Skip to content

Configure Aspects

Set NixOS/Darwin/HM options directly on an aspect:

den.aspects.igloo = {
nixos = { pkgs, ... }: {
environment.systemPackages = [ pkgs.hello ];
};
homeManager.programs.vim.enable = true;
};

Compose aspects with includes:

den.aspects.tux = {
includes = [
den.provides.primary-user
(den.provides.user-shell "fish")
den.aspects.base-tools
];
};

Functions in includes receive context and only activate when they match:

den.aspects.igloo.includes = [
den.aspects.video
];
den.aspects.video = den.lib.take.exactly ({ host, user }: {
nixos.users.users.${user.userName}.extraGroups = [ "video" ];
});

This runs once per user on the host. A function taking { host } only runs at the host level.

A host aspect can contribute to user-level settings:

den.aspects.igloo = {
nixos.networking.hostName = "igloo";
homeManager.programs.direnv.enable = true;
};

The homeManager config from a host aspect becomes the default for all users on that host.

A user aspect can contribute to the host’s NixOS/Darwin config:

den.aspects.tux = {
nixos.users.users.tux.description = "cute penguin";
homeManager = { pkgs, ... }: {
home.packages = [ pkgs.htop ];
};
};

The nixos config from a user aspect is applied to every host the user appears on.

Use aspect arguments to specialize:

den.aspects.igloo.includes = [ den.aspects.tuxGit ];
den.aspects.tuxGit = den.lib.take.exactly ({ host, user }:
if user.userName == "tux"
then { homeManager.programs.git.enable = true; }
else { }
);

Use den.default for settings that apply everywhere:

den.default = {
nixos.system.stateVersion = "25.11";
homeManager.home.stateVersion = "25.11";
includes = [
den.provides.define-user
(den.lib.take.exactly ({ host }: {
nixos.networking.hostName = host.hostName;
}))
];
};

Use den.lib.take.exactly to restrict a function to a specific context shape (e.g., only at host level, not user level).

Organize aspects hierarchically using provides:

den.aspects.gaming = {
nixos.programs.steam.enable = true;
provides.emulation.nixos.programs.retroarch.enable = true;
provides.streaming = {
nixos.services.sunshine.enable = true;
homeManager.programs.moonlight.enable = true;
};
};
den.aspects.my-pc.includes = [
den.aspects.gaming
den.aspects.gaming._.emulation
];
Contribute Community Sponsor