Shareable Aspects (Namespaces)

Namespaces are a Den social feature. It allows many flakes to augment a given aspect tree (under the same namespace).

You enable namespaces by having a module like:

{ inputs, ... }: 
{
  imports = [

    # create local `eg` (example!) namespace. not-flake exposed.
    (inputs.den.namespace "eg" false)

    # you can have several namespaces, create yours
    (input.den.namespace "yours" true)

    # you can also mixin other's namespaces
    (input.den.namespace "ours" inputs.theirs) # from remote
    (input.den.namespace "ours" true) # from local
  ];
}

Internally, a namespace is just a provides branch:

# den.ful is the social-convention for namespaces.
den.ful.<namespace>.<aspect>

Having an aspect namespace is not required but helps a lot with organization and conventient access to your aspects.

The following examples use the vix namespace, inspired by github:vic/vix own namespace pattern.

By using an aspect namespace you can:

  • Directly write to aspects in your namespace.
{
    vix.gaming.nixos = ...;

    # instead of:
    # den.ful.vix.gaming.nixos = ...;
}
  • Directly read aspects from your namespace.
# Access the namespace from module args
{ vix, ... }:
{
    den.default.includes = [ vix.security ];

    # instead of:
    # den.default.includes = [ den.ful.vix.security ];
}
  • Share and re-use aspects between Dendritic flakes
imports = [
  # Aspects opt-in exposed as flake.denful.<name>
  ( inputs.den.namespace "vix" true)

  # Many flakes can expose to the same namespace and we
  # can merge them, accessing aspects in a uniform way.
  ( inputs.den.namespace "vix" inputs.dendrix )
];
  • Use Den angle-brackets to access deeply nested trees
{ __findFile, ... }:
  den.aspects.my-laptop.includes = [ 
    <vix/gaming/retro> 
    
    # instead of den.ful.vix.gaming.provides.retro
  ];
}