Skip to content

Expose the evaluated palette as a Nix attrset #61

Description

@cappyzawa

Background

akari already emits evaluated colors as Nix for some tools (dist/nix/akari-{variant}-delta.nix, -fzf, -gh-dash), but there is no way to read the palette itself (its color keys) from Nix. Non-tmux Nix consumers — e.g. JankyBorders, SketchyBar, or a user's own Home Manager modules — that want to match akari must hardcode hex values, which don't follow the active variant and drift when the palette changes.

The tmux-specific side of this is tracked in #60 (via tmux user options); this issue covers the Nix side.

Proposal

Expose the evaluated palette as a per-variant Nix attrset.

  • Add templates/nix/akari-{name}-palette.nix.tera. The generator already renders any {name} template per variant (process_templaterender_per_variant), so this produces dist/nix/akari-night-palette.nix and dist/nix/akari-dawn-palette.nix with no Rust change.
  • Expose it through the Home Manager module, mirroring nix/targets/delta.nix: a read-only config.akari.palette option defaulting to import "${sources}/nix/akari-${config.akari.variant}-palette.nix".

Template sketch:

# Akari {{ variant | title }} — palette for Nix
{
  base = { background = "{{ base.background }}"; foreground = "{{ base.foreground }}"; };
  layers = { surface = "{{ layers.surface }}"; border = "{{ layers.border }}"; sunken = "{{ layers.sunken }}"; raised = "{{ layers.raised }}"; };
  state = { active_bg = "{{ state.active_bg }}"; selection_bg = "{{ state.selection_bg }}"; selection_fg = "{{ state.selection_fg }}"; cursor = "{{ state.cursor }}"; warning = "{{ state.warning }}"; error = "{{ state.error }}"; info = "{{ state.info }}"; hint = "{{ state.hint }}"; };
  semantic = { text = "{{ semantic.text }}"; comment = "{{ semantic.comment }}"; keyword = "{{ semantic.keyword }}"; /* ... */ };
}

Consumer example (Home Manager):

"#[fg=${config.akari.palette.semantic.comment}] #I:#W "

Scope (which keys)

Use the same subset as #60 for a consistent mental model across surfaces:

  • semantic.*
  • base (background, foreground)
  • layers (surface, border, sunken, raised)
  • state (active_bg, selection_bg, selection_fg, cursor, warning, error, info, hint)

Exclude colors.* (world pigments — internal material; the palette TOML says to use semantic in tool themes) and ansi.* / ansi.bright.*. Subset-first: adding keys is non-breaking, removing is breaking.

API shape

Read-only config.akari.palette for the active variant (matches the existing HM module style). An explicit akariLib.palette.${variant} (both variants) is an alternative if a consumer ever needs a non-active variant.

Related

Companion issue: #60 (tmux user options). Shared color-coverage policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions