Keep your own niri config next to fjordxy's: a local.kdl that is read last #26

Open
opened 2026-11-06 16:31:19 +01:00 by arne · 0 comments
Owner

Someone who switched from DMS reported this:

  • They lost left-handed on the mouse.
  • They didn't want the hot corner.
  • They wanted to keep their own hand-written niri config, the way DMS lets you.

As a workaround they put their input settings in ~/.local/state/fjordxy/current/niri-settings.kdl. This issue proposes a proper place for those settings. Comments are welcome, especially from anyone with a hand-written niri config.

What happens today

fjordxy generates all of ~/.config/niri/config.kdl from Nix (programs.niri.settings, via niri-flake). The file is a read-only store symlink, checked with niri validate at build. The order is:

  1. Settings. Each value takes the strongest source that set it: your own Nix beats fjordxy.toml's [niri] table, which beats fjordxy's defaults (mkDefault).
  2. blur, then programs.fjordxy.niri.extraNodes.
  3. include optional=true ".../fjordxy/current/niri-theme.kdl": the live theme.
  4. include optional=true ".../fjordxy/current/niri-settings.kdl": kept for drawer controls that don't exist yet.

What follows from that:

  • Your old config. The template and ISO set home-manager.backupFileExtension = "hm-bak". So if you had a config.kdl, home-manager moved it to ~/.config/niri/config.kdl.hm-bak. Your left-handed is in there.
  • The hot corner. fjordxy never set one, so niri's own default (top-left opens the overview) was live. That gets turned off separately.
  • niri-settings.kdl. Your workaround file there is safe for now, because nothing writes that file yet. It will be overwritten once drawer controls ship, so don't keep it there long-term.
  • Changing anything today means Nix and a rebuild. There's no hot reload, and no file of your own.

How DMS does it, for comparison

On a regular distro, DMS writes fragments to ~/.config/niri/dms/*.kdl. You paste include lines at the end of your own config.kdl, and DMS never edits that file. Its binds-next/binds order means your binds win.

On Nix, DMS also generates config.kdl: the niri-flake output goes to hm.kdl, and the DMS fragments are included after it. So the part people like is not "the shell doesn't touch config.kdl". It's a hand-written file the shell never touches, which hot-reloads and wins.

Proposal

fjordxy keeps generating config.kdl and adds one last include:

include optional=true "~/.config/niri/local.kdl"

local.kdl is yours. fjordxy creates it once with a commented header if it's missing, and never writes it again. Order, weakest to strongest:

fjordxy defaults < fjordxy.toml < your Nix < extraNodes < theme < drawer controls < local.kdl

How niri merges (from niri's include docs):

  • Binds override per key. Mod+Y { move-workspace-to-monitor-next; } just works.
  • layout, gestures and similar sections merge field by field.
  • window-rule and output are added as written. A later rule wins.
  • Input devices are replaced as a whole. input { mouse { … } } replaces the whole mouse section, and the same goes for touchpad. Your example works exactly as you'd expect.
  • local.kdl is not checked at build, because it lives in $HOME. niri checks it on every save and keeps the last good config if it's broken. The session will also run niri validate at login and show an alert.

For those who want raw kdl in their flake instead: programs.fjordxy.niri.localConfig = ./niri.kdl; uses the same include point, but from the store, so it is checked by niri validate at build.

Known gaps:

  • Binds in local.kdl won't appear on the keybindings sheet or the command page until the shell reads that file too (step 5).
  • Drawer controls can lose to local.kdl without saying so, until they learn to show "set in local.kdl" (step 6).

Multiple monitors

  • Each screen has its own workspaces. That's niri's model: each monitor has its own vertical stack. Mod+Y above, plus the existing Mod+Shift+Ctrl+←/→ (move column to monitor), is how you move things between screens.
  • Reversed screen order. Without position, niri sorts outputs by connector name and lays them out left to right. So DP-1 ends up left of HDMI-A-1, whatever your desk looks like. Fix it in local.kdl, using names from niri msg outputs and positions in logical pixels, so scale counts:
    output "HDMI-A-1" { position x=0 y=0; }
    output "DP-1"     { position x=1920 y=0; }
    

Steps

  1. Hot corner off by default (gestures.hot-corners.enable = false)
  2. Include ~/.config/niri/local.kdl last; create it with a header if it's missing
  3. programs.fjordxy.niri.localConfig (path in the flake, checked at build)
  4. Session start: niri validate and an alert on errors. First check what niri does on a parse error at login.
  5. Docs: "coming from plain niri / DMS". Cover config.kdl.hm-bak, what to strip from a DMS config (dms/*.kdl includes, spawn-at-startup "dms", DMS IPC binds) and monitor positions.
  6. Keybindings sheet and command page also show binds from local.kdl
  7. Before drawer controls ship:
    • a marker in niri-settings.kdl, so no hand-written file gets overwritten
    • controls for input and animations write the whole section (niri doesn't merge those)
    • "set in local.kdl" shown in the control

Questions

  • For you who switched: Does local.kdl cover what you wanted from the DMS model? Or do you really want to own config.kdl yourself and include fjordxy's file? That's possible, but then a missing include means no Mod+G.
  • Should local.kdl beat the theme and drawer controls, as proposed? The alternative is that the drawer always wins. Then a colour you set in local.kdl disappears at the next theme switch.
  • Name and location: is ~/.config/niri/local.kdl right?
  • Should Mod+Y (move-workspace-to-monitor-next) be a fjordxy default? The key is free.
  • herdr: the same question applies to herdr's config, but it's out of scope here. Say if you want a separate issue for it.

🤖 Generated with Claude Code

Someone who switched from DMS reported this: - They lost `left-handed` on the mouse. - They didn't want the hot corner. - They wanted to keep their own hand-written niri config, the way DMS lets you. As a workaround they put their `input` settings in `~/.local/state/fjordxy/current/niri-settings.kdl`. This issue proposes a proper place for those settings. Comments are welcome, especially from anyone with a hand-written niri config. ## What happens today fjordxy generates all of `~/.config/niri/config.kdl` from Nix (`programs.niri.settings`, via niri-flake). The file is a read-only store symlink, checked with `niri validate` at build. The order is: 1. Settings. Each value takes the strongest source that set it: your own Nix beats `fjordxy.toml`'s `[niri]` table, which beats fjordxy's defaults (`mkDefault`). 2. `blur`, then `programs.fjordxy.niri.extraNodes`. 3. `include optional=true ".../fjordxy/current/niri-theme.kdl"`: the live theme. 4. `include optional=true ".../fjordxy/current/niri-settings.kdl"`: kept for drawer controls that don't exist yet. What follows from that: - **Your old config.** The template and ISO set `home-manager.backupFileExtension = "hm-bak"`. So if you had a `config.kdl`, home-manager moved it to **`~/.config/niri/config.kdl.hm-bak`**. Your `left-handed` is in there. - **The hot corner.** fjordxy never set one, so niri's own default (top-left opens the overview) was live. That gets turned off separately. - **`niri-settings.kdl`.** Your workaround file there is safe for now, because nothing writes that file yet. It will be overwritten once drawer controls ship, so don't keep it there long-term. - **Changing anything** today means Nix and a rebuild. There's no hot reload, and no file of your own. ## How DMS does it, for comparison On a regular distro, DMS writes fragments to `~/.config/niri/dms/*.kdl`. You paste `include` lines at the end of your own `config.kdl`, and DMS never edits that file. Its binds-next/binds order means your binds win. On Nix, DMS also generates `config.kdl`: the niri-flake output goes to `hm.kdl`, and the DMS fragments are included after it. So the part people like is not "the shell doesn't touch config.kdl". It's **a hand-written file the shell never touches, which hot-reloads and wins.** ## Proposal fjordxy keeps generating `config.kdl` and adds one last include: ```kdl include optional=true "~/.config/niri/local.kdl" ``` `local.kdl` is yours. fjordxy creates it once with a commented header if it's missing, and never writes it again. Order, weakest to strongest: fjordxy defaults < `fjordxy.toml` < your Nix < `extraNodes` < theme < drawer controls < **`local.kdl`** How niri merges (from niri's include docs): - **Binds** override per key. `Mod+Y { move-workspace-to-monitor-next; }` just works. - **`layout`, `gestures` and similar sections** merge field by field. - **`window-rule` and `output`** are added as written. A later rule wins. - **Input devices are replaced as a whole.** `input { mouse { … } }` replaces the whole `mouse` section, and the same goes for `touchpad`. Your example works exactly as you'd expect. - **`local.kdl` is not checked at build**, because it lives in `$HOME`. niri checks it on every save and keeps the last good config if it's broken. The session will also run `niri validate` at login and show an alert. For those who want raw kdl in their flake instead: `programs.fjordxy.niri.localConfig = ./niri.kdl;` uses the same include point, but from the store, so it is checked by `niri validate` at build. Known gaps: - Binds in `local.kdl` won't appear on the keybindings sheet or the command page until the shell reads that file too (step 5). - Drawer controls can lose to `local.kdl` without saying so, until they learn to show "set in local.kdl" (step 6). ## Multiple monitors - **Each screen has its own workspaces.** That's niri's model: each monitor has its own vertical stack. `Mod+Y` above, plus the existing `Mod+Shift+Ctrl+←/→` (move column to monitor), is how you move things between screens. - **Reversed screen order.** Without `position`, niri sorts outputs by connector name and lays them out left to right. So `DP-1` ends up left of `HDMI-A-1`, whatever your desk looks like. Fix it in `local.kdl`, using names from `niri msg outputs` and positions in logical pixels, so scale counts: ```kdl output "HDMI-A-1" { position x=0 y=0; } output "DP-1" { position x=1920 y=0; } ``` ## Steps 0. [ ] Hot corner off by default (`gestures.hot-corners.enable = false`) 1. [ ] Include `~/.config/niri/local.kdl` last; create it with a header if it's missing 2. [ ] `programs.fjordxy.niri.localConfig` (path in the flake, checked at build) 3. [ ] Session start: `niri validate` and an alert on errors. First check what niri does on a parse error at login. 4. [ ] Docs: "coming from plain niri / DMS". Cover `config.kdl.hm-bak`, what to strip from a DMS config (`dms/*.kdl` includes, `spawn-at-startup "dms"`, DMS IPC binds) and monitor positions. 5. [ ] Keybindings sheet and command page also show binds from `local.kdl` 6. [ ] Before drawer controls ship: - a marker in `niri-settings.kdl`, so no hand-written file gets overwritten - controls for input and animations write the whole section (niri doesn't merge those) - "set in local.kdl" shown in the control ## Questions - **For you who switched:** Does `local.kdl` cover what you wanted from the DMS model? Or do you really want to own `config.kdl` yourself and include fjordxy's file? That's possible, but then a missing include means no `Mod+G`. - **Should `local.kdl` beat the theme and drawer controls,** as proposed? The alternative is that the drawer always wins. Then a colour you set in `local.kdl` disappears at the next theme switch. - **Name and location:** is `~/.config/niri/local.kdl` right? - **Should `Mod+Y` (`move-workspace-to-monitor-next`) be a fjordxy default?** The key is free. - **herdr:** the same question applies to herdr's config, but it's out of scope here. Say if you want a separate issue for it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bases/fjord#26
No description provided.