# modules/home/noctalia-plugins.nix — Noctalia plugins from the official
# registry (flake input noctalia-plugins, so `nix flake update noctalia-plugins`
# is the update button), linked into ~/.config/noctalia/plugins.
#
# Why not the wrapper's preInstalledPlugins: any file besides settings moves
# NOCTALIA_CONFIG_DIR into the Nix store, and Noctalia then cannot write
# colors.json, so the Rosé Pine scheme never applies. Here the config dir stays
# ~/.config/noctalia: each plugin is a directory of store symlinks (its own
# settings.json stays writable), and plugins.json is merged rather than linked,
# so the GUI can still install and toggle other plugins.
#
# Bar slots for the plugins are in modules/features/desktop/noctalia.nix
# (packages.noctalia-daemon), as "plugin:<id>".
{ self, ... }:
let
palette = (import ../_palette.nix).gruvpine;
# Gruvpine as a Noctalia colour scheme: dark is the palette in _palette.nix,
# light borrows Gruvbox light. Noctalia lists every
# colorschemes/<Name>/<Name>.json beside its bundled schemes.
gruvpineScheme = {
dark = {
mPrimary = palette.rose; mOnPrimary = palette.base;
mSecondary = palette.foam; mOnSecondary = palette.base;
mTertiary = palette.iris; mOnTertiary = palette.base;
mError = palette.love; mOnError = palette.base;
mSurface = palette.base; mOnSurface = palette.text;
mSurfaceVariant = palette.overlay; mOnSurfaceVariant = palette.subtle;
mOutline = palette.hlMed; mShadow = palette.base;
mHover = palette.hlHigh; mOnHover = palette.text;
terminal = {
normal = {
black = palette.overlay; red = palette.love; green = palette.pine;
yellow = palette.gold; blue = palette.foam; magenta = palette.iris;
cyan = palette.rose; white = palette.text;
};
bright = {
black = palette.muted; red = palette.love; green = palette.pine;
yellow = palette.gold; blue = palette.foam; magenta = palette.iris;
cyan = palette.rose; white = "#fbf1c7";
};
foreground = palette.text; background = palette.base;
selectionFg = palette.text; selectionBg = palette.hlMed;
cursorText = palette.base; cursor = palette.text;
};
};
light = {
mPrimary = "#af3a03"; mOnPrimary = "#fbf1c7";
mSecondary = "#427b58"; mOnSecondary = "#fbf1c7";
mTertiary = "#8f3f71"; mOnTertiary = "#fbf1c7";
mError = "#9d0006"; mOnError = "#fbf1c7";
mSurface = "#fbf1c7"; mOnSurface = "#3c3836";
mSurfaceVariant = "#ebdbb2"; mOnSurfaceVariant = "#665c54";
mOutline = "#d5c4a1"; mShadow = "#f2e5bc";
mHover = "#d5c4a1"; mOnHover = "#3c3836";
terminal = {
normal = {
black = "#ebdbb2"; red = "#9d0006"; green = "#79740e";
yellow = "#b57614"; blue = "#427b58"; magenta = "#8f3f71";
cyan = "#af3a03"; white = "#3c3836";
};
bright = {
black = "#928374"; red = "#9d0006"; green = "#79740e";
yellow = "#b57614"; blue = "#427b58"; magenta = "#8f3f71";
cyan = "#af3a03"; white = "#282828";
};
foreground = "#3c3836"; background = "#fbf1c7";
selectionFg = "#3c3836"; selectionBg = "#d5c4a1";
cursorText = "#fbf1c7"; cursor = "#3c3836";
};
};
};
in
{
flake.homeModules.noctalia-plugins =
{ lib, pkgs, inputs, osConfig, ... }:
let
sourceUrl = "https://github.com/noctalia-dev/noctalia-plugins";
plugins = [
"catwalk" # a cat in the bar that runs faster with CPU load
"clipper" # clipboard manager with pinned items, notecards, ToDo
"dns-switcher" # change DNS through NetworkManager (pkexec)
"git-companion" # repo status in the bar (GitHub/GitLab)
"keybind-cheatsheet" # Niri shortcuts in the Noctalia bar
"mangowc-layout-switcher" # layout switcher for MangoWC; idle under niri
"model-usage" # AI usage meters in the bar
"niri-auto-tile" # auto-tiling rules for niri (python3)
"niri-screensaver" # packaged launcher, Alacritty and TerminalTextEffects
"privacy-indicator" # camera/mic/screen-share dots
"screen-shot-and-record" # Niri screenshots routed to Grim + Satty below
"fancy-audiovisualizer" # desktop widget: place it from Settings → Desktop widgets
"kde-connect" # needs kdeconnectd (not enabled here yet)
"obs-control" # needs OBS with its websocket server (not installed here)
"pomodoro"
];
states = lib.genAttrs plugins (_: { enabled = true; inherit sourceUrl; });
statesJson = pkgs.writeText "noctalia-plugin-states.json" (builtins.toJSON states);
recorder = lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.screen-record;
screenOcr = lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.screen-ocr;
screensaver = self.packages.${pkgs.stdenv.hostPlatform.system}.niri-screensaver;
screensaverDefaults = pkgs.writeText "niri-screensaver-config" ''
FRAME_RATE="30"
LOGO_FILE="${screensaver}/share/niri-screensaver/logos/nixdaemon.txt"
LOGO_DIR="${screensaver}/share/niri-screensaver/logos"
SHOW_CLOCK="true"
CLOCK_FORMAT="%H:%M"
CURSOR_HIDE="true"
CURSOR_WARP="false"
DISMISS_ON_KEY="true"
EXCLUDE_EFFECTS="dev_worm"
'';
screensaverPluginDefaults = pkgs.writeText "niri-screensaver-settings.json" (builtins.toJSON {
enabled = true;
idleSeconds = 300;
frameRate = 30;
showClock = true;
logoPath = "${screensaver}/share/niri-screensaver/logos/nixdaemon.txt";
logoDir = "${screensaver}/share/niri-screensaver/logos";
launcherCommand = "${screensaver}/bin/niri-screensaver-launch launch";
killCommand = "${screensaver}/bin/niri-screensaver-launch kill";
});
screenshotPlugin = pkgs.runCommand "noctalia-screenshot-niri" { } ''
cp -r ${inputs.noctalia-plugins}/screen-shot-and-record "$out"
chmod u+w "$out" "$out/Main.qml" "$out/Panel.qml"
substituteInPlace "$out/Main.qml" --replace-fail \
'property string target: ""' \
'property string target: ""
readonly property var recordingStatusCommand: CompositorService.isNiri ? ["${recorder}", "status"] : ["pidof", "wf-recorder"]
Process {
id: niriRecorder
running: false
onExited: root.recordingActive = false
}
Process {
id: niriRecorderStatus
command: ["${recorder}", "status"]
onExited: (exitCode) => { root.recordingActive = (exitCode === 0) }
}
Timer {
interval: 1000
repeat: true
triggeredOnStart: true
running: CompositorService.isNiri
onTriggered: { if (!niriRecorderStatus.running) niriRecorderStatus.running = true }
}' \
--replace-fail 'command: ["pidof", "wf-recorder"]' 'command: root.recordingStatusCommand' \
--replace-fail 'function stopRecording() {' \
'function stopRecording() {
if (CompositorService.isNiri) {
Quickshell.execDetached(["${recorder}", "stop"]);
return;
}'
substituteInPlace "$out/Main.qml" --replace-fail \
'if (CompositorService.isNiri) {' \
'if (CompositorService.isNiri && target === "screenshot") {
Quickshell.execDetached(["${lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.screenshot}", "region"]);
return;
}
if (CompositorService.isNiri && target === "ocr") {
Quickshell.execDetached(["${screenOcr}"]);
return;
}
if (CompositorService.isNiri && (target === "record" || target === "recordsound")) {
if (!niriRecorder.running) {
niriRecorder.command = ["${recorder}", target === "recordsound" ? "audio" : "video"];
niriRecorder.running = true;
}
return;
}
if (CompositorService.isNiri) {'
substituteInPlace "$out/Panel.qml" --replace-fail \
'command: ["pidof", "wf-recorder"]' \
'command: root.mainInstance?.recordingStatusCommand ?? ["pidof", "wf-recorder"]'
'';
keybindPlugin = pkgs.runCommand "noctalia-keybind-cheatsheet-niri" { } ''
cp -r ${inputs.noctalia-plugins}/keybind-cheatsheet "$out"
chmod u+w "$out" "$out/Main.qml"
${pkgs.python3}/bin/python3 ${./_keybind-cheatsheet/patch.py} "$out/Main.qml"
'';
in
lib.mkIf osConfig.daemon.desktop.niri.enable {
# The weather location (home town) is kept out of the public repo; the
# noctalia-daemon launcher (modules/features/desktop/noctalia.nix) reads
# it from here at login. Edit: TMPDIR=/dev/shm sops secrets/noctalia-location
sops.secrets.noctalia-location = {
sopsFile = ../../secrets/noctalia-location;
format = "binary";
};
xdg.configFile = lib.listToAttrs (map (id: {
name = "noctalia/plugins/${id}";
value = {
source =
if id == "screen-shot-and-record" then screenshotPlugin
else if id == "keybind-cheatsheet" then keybindPlugin
else "${inputs.noctalia-plugins}/${id}";
recursive = true;
};
}) plugins) // {
"noctalia/colorschemes/Gruvpine/Gruvpine.json".source =
pkgs.writeText "Gruvpine.json" (builtins.toJSON gruvpineScheme);
};
# The plugin edits these files, so seed them rather than making store links.
home.activation.niriScreensaverDefaults = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
run mkdir -p "$HOME/.config/niri-screensaver"
if [ ! -f "$HOME/.config/niri-screensaver/config" ]; then
run cp ${screensaverDefaults} "$HOME/.config/niri-screensaver/config"
run chmod u+w "$HOME/.config/niri-screensaver/config"
fi
f="$HOME/.config/noctalia/plugins/niri-screensaver/settings.json"
if [ -f "$f" ]; then old=$(cat "$f"); else old='{}'; fi
new=$(printf '%s' "$old" | ${lib.getExe pkgs.jq} --slurpfile defaults ${screensaverPluginDefaults} \
'$defaults[0] * . | .launcherCommand = $defaults[0].launcherCommand | .killCommand = $defaults[0].killCommand')
[ -n "''${DRY_RUN:-}" ] || printf '%s\n' "$new" > "$f"
'';
# Keep the plugin settings writable, preserving the selected folders and
# every other option while replacing the old editor choice once applied.
home.activation.noctaliaScreenshotEditor = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
f="$HOME/.config/noctalia/plugins/screen-shot-and-record/settings.json"
if [ -f "$f" ]; then old=$(cat "$f"); else old='{}'; fi
new=$(printf '%s' "$old" | ${lib.getExe pkgs.jq} '.screenshotEditor = "satty"')
[ -n "''${DRY_RUN:-}" ] || printf '%s\n' "$new" > "$f"
'';
# The wrapper's generated config contains the live binds. Keep a stable
# path for the plugin across Nix store generations and preserve its UI options.
home.activation.noctaliaKeybindCheatsheet = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
f="$HOME/.config/niri/keybind-cheatsheet.kdl"
run mkdir -p "$HOME/.config/niri"
[ -n "''${DRY_RUN:-}" ] || ln -sfn ${osConfig.daemon.desktop.niri.package}/niri-config.kdl "$f"
f="$HOME/.config/noctalia/plugins/keybind-cheatsheet/settings.json"
if [ -f "$f" ]; then old=$(cat "$f"); else old='{}'; fi
new=$(printf '%s' "$old" | ${lib.getExe pkgs.jq} \
'.niriConfigPath = "~/.config/niri/keybind-cheatsheet.kdl" | .cheatsheetData = []')
[ -n "''${DRY_RUN:-}" ] || printf '%s\n' "$new" > "$f"
'';
# Add the states to whatever plugins.json the GUI has written; keys already
# there (other plugins, sources) are kept.
home.activation.noctaliaPluginStates = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
f="$HOME/.config/noctalia/plugins.json"
if [ -f "$f" ]; then
old=$(cat "$f")
else
old='{"version":2,"sources":[{"enabled":true,"name":"Noctalia Plugins","url":"${sourceUrl}"}],"states":{}}'
fi
new=$(printf '%s' "$old" | ${lib.getExe pkgs.jq} --slurpfile s ${statesJson} '.states = ((.states // {}) + $s[0])')
run mkdir -p "$(dirname "$f")"
[ -n "''${DRY_RUN:-}" ] || printf '%s\n' "$new" > "$f"
'';
home.packages = [ screensaver ] ++ (with pkgs; [
wtype # Clipper's paste-on-select
sshfs # KDE Connect's "Browse files"
]);
};
}