refactor: niri config
This commit is contained in:
@@ -11,14 +11,22 @@ in
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [ inputs.niri.nixosModules.niri ];
|
||||
|
||||
nixpkgs.overlays = [ inputs.niri.overlays.niri ];
|
||||
|
||||
programs.niri.enable = true;
|
||||
programs.niri.package = pkgs.niri-unstable;
|
||||
programs.dconf.enable = true;
|
||||
programs = {
|
||||
dconf.enable = true;
|
||||
niri = {
|
||||
enable = true;
|
||||
package = pkgs.niri-unstable;
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
gvfs.enable = true;
|
||||
udisks2.enable = true;
|
||||
};
|
||||
|
||||
services.gvfs.enable = true;
|
||||
services.udisks2.enable = true;
|
||||
xdg.portal.enable = true;
|
||||
};
|
||||
|
||||
@@ -31,241 +39,59 @@ in
|
||||
...
|
||||
}:
|
||||
let
|
||||
repoTheme = repo.theme.kanagawa;
|
||||
browserCommand = config.meta.desktop.browser.command;
|
||||
fileManagerPackage = config.meta.desktop.fileManager.package;
|
||||
terminalCommand = config.meta.desktop.terminal.command;
|
||||
terminalDesktopEntryName = config.meta.desktop.terminal.desktopEntryName;
|
||||
nixosConfigDir = repo.account.nixosConfigurationPath;
|
||||
secretsFile = "${nixosConfigDir}/modules/secrets/secrets.yaml";
|
||||
outputs = lib.mapAttrs (
|
||||
_: display:
|
||||
{
|
||||
position = {
|
||||
x = display.x;
|
||||
y = display.y;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (display.primary or false) {
|
||||
"focus-at-startup" = true;
|
||||
}
|
||||
// lib.optionalAttrs (display.scale != null) {
|
||||
inherit (display) scale;
|
||||
}
|
||||
// lib.optionalAttrs (display.width != null && display.height != null && display.refresh != null) {
|
||||
mode = {
|
||||
inherit (display)
|
||||
width
|
||||
height
|
||||
refresh
|
||||
;
|
||||
};
|
||||
}
|
||||
) osConfig.meta.machine.displays;
|
||||
terminalCommandArg = lib.escapeShellArg terminalCommand;
|
||||
mkTerminalScript =
|
||||
{
|
||||
name,
|
||||
title,
|
||||
appId ? "niri-ux-terminal",
|
||||
workdir ? nixosConfigDir,
|
||||
command ? null,
|
||||
runtimeInputs ? [ ],
|
||||
}:
|
||||
let
|
||||
terminalArgs =
|
||||
if terminalDesktopEntryName == "kitty" then
|
||||
[
|
||||
"--class"
|
||||
appId
|
||||
"--title"
|
||||
title
|
||||
"--directory"
|
||||
workdir
|
||||
]
|
||||
else if terminalDesktopEntryName == "foot" then
|
||||
[
|
||||
"--app-id"
|
||||
appId
|
||||
"--title"
|
||||
title
|
||||
"--working-directory"
|
||||
workdir
|
||||
]
|
||||
else
|
||||
[ ];
|
||||
commandArgs =
|
||||
if command == null then
|
||||
[ ]
|
||||
else
|
||||
[
|
||||
"--"
|
||||
"${pkgs.bash}/bin/bash"
|
||||
"-lc"
|
||||
command
|
||||
];
|
||||
execArgs = lib.concatMapStringsSep " " lib.escapeShellArg (terminalArgs ++ commandArgs);
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
inherit name runtimeInputs;
|
||||
checkPhase = "";
|
||||
text = ''
|
||||
# shellcheck disable=SC2016
|
||||
cd ${lib.escapeShellArg workdir}
|
||||
exec ${terminalCommandArg} ${execArgs}
|
||||
'';
|
||||
};
|
||||
uxScripts =
|
||||
let
|
||||
vicinaePackage = config.programs.vicinae.package or pkgs.vicinae;
|
||||
in
|
||||
{
|
||||
nixosTerminal = mkTerminalScript {
|
||||
name = "niri-ux-nixos-terminal";
|
||||
title = "NixOS Config";
|
||||
};
|
||||
|
||||
nixosSwitch = mkTerminalScript {
|
||||
name = "niri-ux-nixos-switch";
|
||||
title = "NixOS Switch";
|
||||
appId = "niri-ux-float";
|
||||
runtimeInputs = [
|
||||
pkgs.coreutils
|
||||
pkgs.nh
|
||||
];
|
||||
command = ''
|
||||
set -o pipefail
|
||||
|
||||
log_dir="''${XDG_STATE_HOME:-$HOME/.local/state}/nixos-switch"
|
||||
mkdir -p "$log_dir"
|
||||
log="$log_dir/$(date +%Y%m%d-%H%M%S).log"
|
||||
status_file="$(mktemp)"
|
||||
|
||||
printf 'Running nh os switch in %s\n\n' ${lib.escapeShellArg nixosConfigDir}
|
||||
(
|
||||
cd ${lib.escapeShellArg nixosConfigDir}
|
||||
nh os switch
|
||||
printf '%s' "$?" > "$status_file"
|
||||
) 2>&1 | tee "$log"
|
||||
|
||||
status="$(cat "$status_file")"
|
||||
rm -f "$status_file"
|
||||
|
||||
printf '\nLog: %s\n' "$log"
|
||||
if [ "$status" -eq 0 ]; then
|
||||
printf 'NixOS switch completed successfully.\n'
|
||||
else
|
||||
printf 'NixOS switch failed with exit code %s.\n' "$status"
|
||||
fi
|
||||
|
||||
printf 'Press Enter to close...'
|
||||
read -r _
|
||||
exit "$status"
|
||||
'';
|
||||
};
|
||||
|
||||
editSecrets = mkTerminalScript {
|
||||
name = "niri-ux-edit-secrets";
|
||||
title = "Edit Secrets";
|
||||
appId = "niri-ux-float";
|
||||
runtimeInputs = [ pkgs.sops ];
|
||||
command = ''
|
||||
sops edit ${lib.escapeShellArg secretsFile}
|
||||
'';
|
||||
};
|
||||
|
||||
neovimProjects = mkTerminalScript {
|
||||
name = "niri-ux-neovim-projects";
|
||||
title = "Neovim Projects";
|
||||
command = ''
|
||||
nvim -c 'Telescope projects'
|
||||
'';
|
||||
};
|
||||
|
||||
vicinaeCommand = pkgs.writeShellApplication {
|
||||
name = "niri-ux-vicinae-command";
|
||||
runtimeInputs = [ vicinaePackage ];
|
||||
text = ''
|
||||
case "''${1:-}" in
|
||||
files)
|
||||
link="vicinae://extensions/sameoldlab/fuzzy-files/find"
|
||||
;;
|
||||
nix-options)
|
||||
link="vicinae://extensions/knoopx/nix/options"
|
||||
;;
|
||||
home-manager-options)
|
||||
link="vicinae://extensions/knoopx/nix/home-manager-options"
|
||||
;;
|
||||
nix-packages)
|
||||
link="vicinae://extensions/knoopx/nix/packages"
|
||||
;;
|
||||
niri-windows)
|
||||
link="vicinae://extensions/knoopx/niri/windows"
|
||||
;;
|
||||
*)
|
||||
printf 'unknown Vicinae command target: %s\n' "''${1:-}" >&2
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
|
||||
exec vicinae deeplink "$link"
|
||||
'';
|
||||
};
|
||||
|
||||
clipboardHistory = pkgs.writeShellApplication {
|
||||
name = "niri-ux-clipboard-history";
|
||||
runtimeInputs = [
|
||||
pkgs.cliphist
|
||||
vicinaePackage
|
||||
pkgs.wl-clipboard
|
||||
];
|
||||
text = ''
|
||||
selection="$(cliphist list | vicinae dmenu --navigation-title Clipboard --placeholder 'Search clipboard' --no-metadata)"
|
||||
if [ -z "$selection" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s' "$selection" | cliphist decode | wl-copy
|
||||
'';
|
||||
};
|
||||
|
||||
pickColor = pkgs.writeShellApplication {
|
||||
name = "niri-ux-pick-color";
|
||||
runtimeInputs = [
|
||||
pkgs.libnotify
|
||||
pkgs.niri
|
||||
pkgs.wl-clipboard
|
||||
];
|
||||
text = ''
|
||||
color="$(niri msg pick-color)"
|
||||
printf '%s' "$color" | wl-copy
|
||||
notify-send 'Color picked' "$color"
|
||||
'';
|
||||
};
|
||||
};
|
||||
uxCommands = lib.mapAttrs (_: lib.getExe) uxScripts;
|
||||
borderPalette = repo.theme.kanagawa.palette.niri.border;
|
||||
shortcuts = import ./_shortcuts.nix {
|
||||
inherit
|
||||
config
|
||||
lib
|
||||
pkgs
|
||||
repo
|
||||
;
|
||||
};
|
||||
in
|
||||
{
|
||||
home.sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
|
||||
dconf.settings = {
|
||||
"org/gnome/desktop/interface" = {
|
||||
color-scheme = "prefer-dark";
|
||||
};
|
||||
home = {
|
||||
sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
packages =
|
||||
with pkgs;
|
||||
[
|
||||
playerctl
|
||||
brightnessctl
|
||||
xwayland-satellite
|
||||
]
|
||||
++ [
|
||||
config.meta.desktop.fileManager.package
|
||||
]
|
||||
++ lib.attrValues shortcuts.scripts;
|
||||
};
|
||||
|
||||
home.packages =
|
||||
with pkgs;
|
||||
[
|
||||
playerctl
|
||||
brightnessctl
|
||||
xwayland-satellite
|
||||
]
|
||||
++ [ fileManagerPackage ]
|
||||
++ lib.attrValues uxScripts;
|
||||
dconf.settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
|
||||
|
||||
programs.niri.settings = {
|
||||
inherit outputs;
|
||||
outputs = lib.mapAttrs (
|
||||
_: display:
|
||||
{
|
||||
position = {
|
||||
inherit (display) x y;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (display.primary or false) {
|
||||
"focus-at-startup" = true;
|
||||
}
|
||||
// lib.optionalAttrs (display.scale != null) {
|
||||
inherit (display) scale;
|
||||
}
|
||||
// lib.optionalAttrs (display.width != null && display.height != null && display.refresh != null) {
|
||||
mode = {
|
||||
inherit (display)
|
||||
width
|
||||
height
|
||||
refresh
|
||||
;
|
||||
};
|
||||
}
|
||||
) osConfig.meta.machine.displays;
|
||||
|
||||
environment.DISPLAY = ":0";
|
||||
spawn-at-startup = [
|
||||
{ command = [ "xwayland-satellite" ]; }
|
||||
@@ -277,9 +103,9 @@ in
|
||||
|
||||
animations.slowdown = 0.6;
|
||||
|
||||
cursor = with config.home.pointerCursor; {
|
||||
size = size;
|
||||
theme = name;
|
||||
cursor = {
|
||||
inherit (config.home.pointerCursor) size;
|
||||
theme = config.home.pointerCursor.name;
|
||||
hide-after-inactive-ms = 3000;
|
||||
hide-when-typing = true;
|
||||
};
|
||||
@@ -288,15 +114,14 @@ in
|
||||
always-center-single-column = true;
|
||||
gaps = 14;
|
||||
focus-ring.enable = false;
|
||||
|
||||
default-column-width.proportion = 1. / 2.;
|
||||
|
||||
border = {
|
||||
enable = true;
|
||||
width = 3;
|
||||
active.color = repoTheme.palette.niri.border.active;
|
||||
inactive.color = repoTheme.palette.niri.border.inactive;
|
||||
urgent.color = repoTheme.palette.niri.border.urgent;
|
||||
active.color = borderPalette.active;
|
||||
inactive.color = borderPalette.inactive;
|
||||
urgent.color = borderPalette.urgent;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -316,7 +141,7 @@ in
|
||||
}
|
||||
{
|
||||
matches = [
|
||||
{ app-id = "^niri-ux-float$"; }
|
||||
{ app-id = "^niri-shortcut-float$"; }
|
||||
];
|
||||
open-floating = true;
|
||||
open-focused = true;
|
||||
@@ -334,18 +159,13 @@ in
|
||||
repeat-rate = 50;
|
||||
xkb.options = "caps:escape";
|
||||
};
|
||||
|
||||
touchpad = {
|
||||
dwt = true;
|
||||
};
|
||||
touchpad.dwt = true;
|
||||
};
|
||||
|
||||
binds = import ./_bindings.nix {
|
||||
inherit
|
||||
browserCommand
|
||||
terminalCommand
|
||||
uxCommands
|
||||
;
|
||||
browserCommand = config.meta.desktop.browser.command;
|
||||
terminalCommand = config.meta.desktop.terminal.command;
|
||||
shortcutCommands = shortcuts.commands;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user