1 parent
80ec3dfdd3
commit
079cceb554
57 files changed
+4092
-538
No files matched your search
Executable
BIN
Binary file not shown.
@@ -1,12 +1,65 @@
|
||||
# Everyday desktop applications (home-manager). Firefox, mpv, imv and zathura
|
||||
# are configured programs; mpv and zathura are also themed by Stylix
|
||||
# (theme/stylix.nix). Firefox is not: Stylix would need a declared profile.
|
||||
# (theme/stylix.nix). Firefox is not: Stylix would need a declared profile, and
|
||||
# a declared profile would replace the existing one. Its settings are enterprise
|
||||
# policies instead, which need no profile.
|
||||
{
|
||||
flake.modules.homeManager.apps =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
vintagestory = pkgs.vintagestoryPackages.v1-22-7.overrideAttrs (old: {
|
||||
# Put the actual executable in the game directory.
|
||||
postInstall = (old.postInstall or "") + ''
|
||||
install -Dm755 ${./PlayVintageStory} \
|
||||
"$out/share/vintagestory/PlayVintageStory"
|
||||
'';
|
||||
|
||||
postFixup = (old.postFixup or "") + ''
|
||||
# Create another launcher with the same environment as
|
||||
# the original vintagestory launcher.
|
||||
makeWrapper \
|
||||
"$out/share/vintagestory/PlayVintageStory" \
|
||||
"$out/bin/PlayVintageStory" \
|
||||
--prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.dotnet-runtime_10 ]}" \
|
||||
--prefix LD_LIBRARY_PATH : \
|
||||
"${pkgs.lib.makeLibraryPath old.runtimeLibs}" \
|
||||
--set DOTNET_ROOT \
|
||||
"${pkgs.dotnet-runtime_10.unwrapped}/share/dotnet" \
|
||||
--set DOTNET_ROOT_X64 \
|
||||
"${pkgs.dotnet-runtime_10.unwrapped}/share/dotnet" \
|
||||
--set-default mesa_glthread true \
|
||||
--run "cd $out/share/vintagestory"
|
||||
|
||||
# Change only the main game's desktop entry.
|
||||
# The original bin/vintagestory remains intact.
|
||||
substituteInPlace \
|
||||
"$out/share/applications/vintagestory.desktop" \
|
||||
--replace-fail \
|
||||
'Exec=vintagestory' \
|
||||
"Exec=$out/bin/PlayVintageStory"
|
||||
'';
|
||||
}); in
|
||||
{
|
||||
programs = {
|
||||
firefox.enable = true;
|
||||
firefox = {
|
||||
enable = true;
|
||||
policies = {
|
||||
# Reopen the windows and tabs of the last session. Not locked, so
|
||||
# the startup setting in about:preferences still works.
|
||||
Homepage.StartPage = "previous-session";
|
||||
Preferences = {
|
||||
# Website appearance: dark (0; 1 is light, 2 follows the system).
|
||||
# A default, not a lock: it can still be changed in
|
||||
# about:preferences. Type is explicit: Firefox may read a
|
||||
# plain 0 or 1 as a boolean.
|
||||
"layout.css.prefers-color-scheme.content-override" = {
|
||||
Value = 0;
|
||||
Type = "number";
|
||||
Status = "default";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
mpv.enable = true;
|
||||
imv.enable = true;
|
||||
zathura.enable = true;
|
||||
@@ -17,10 +70,13 @@
|
||||
telegram-desktop
|
||||
file-roller
|
||||
teamspeak6-client
|
||||
spotify
|
||||
loupe # image viewer
|
||||
zenity
|
||||
procps
|
||||
vscode
|
||||
networkmanager-openvpn
|
||||
vintagestory
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
# Coverage fonts: scripts and symbols that the theme fonts do not have. The
|
||||
# theme fonts themselves (Monaspace, Inter, Noto Serif, Noto Color Emoji) and
|
||||
# the fontconfig default families come from Stylix (theme/stylix.nix, targets
|
||||
# `font-packages` and `fontconfig`).
|
||||
# theme fonts themselves (Monaspace Radon for monospace and sans-serif, Noto
|
||||
# Serif, Noto Color Emoji) and the fontconfig default families come from Stylix
|
||||
# (theme/stylix.nix, targets `font-packages` and `fontconfig`).
|
||||
{
|
||||
flake.modules.nixos.fonts =
|
||||
{ pkgs, ... }:
|
||||
|
||||
@@ -12,8 +12,11 @@ local ipc = "noctalia msg "
|
||||
---- APPLICATIONS ----
|
||||
----------------------
|
||||
|
||||
hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(nix.terminal))
|
||||
hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(nix.fileManager))
|
||||
-- Started through uwsm-app (nix.appLauncher), so each app is a scope of the
|
||||
-- session and is stopped before the compositor at logout. The short-lived
|
||||
-- commands further down (noctalia msg, screenshots) are started directly.
|
||||
hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(nix.appLauncher .. " " .. nix.terminal))
|
||||
hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(nix.appLauncher .. " " .. nix.fileManager))
|
||||
|
||||
---------------
|
||||
---- WINDOWS ----
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# Hyprland desktop, both halves of one feature:
|
||||
# NixOS UWSM-managed compositor, SDDM with autologin of the owner,
|
||||
# portals, keyring and the small services a desktop needs.
|
||||
# NixOS UWSM-managed compositor, portals, keyring and the small
|
||||
# services a desktop needs.
|
||||
# home-manager the user configuration. Hyprland reads Lua: the real config
|
||||
# is in the .lua files next to this file; Nix only passes in the
|
||||
# values that come from elsewhere (`require("nixvars")`).
|
||||
# The NixOS half adds the home-manager half to the owner, so a host imports
|
||||
# `nixos.hyprland` once. Noctalia, audio and fonts are separate aspects.
|
||||
# `nixos.hyprland` once. The display manager (sddm), Noctalia, audio and fonts
|
||||
# are separate aspects.
|
||||
{ config, ... }:
|
||||
let
|
||||
inherit (config.meta) owner;
|
||||
@@ -24,15 +25,6 @@ in
|
||||
xwayland.enable = true;
|
||||
};
|
||||
|
||||
services.displayManager.sddm = {
|
||||
enable = true;
|
||||
wayland.enable = true;
|
||||
settings.Autologin = {
|
||||
Session = "hyprland.desktop";
|
||||
User = owner.name;
|
||||
};
|
||||
};
|
||||
|
||||
xdg.portal.extraPortals = [
|
||||
pkgs.xdg-desktop-portal-gtk
|
||||
pkgs.xdg-desktop-portal-hyprland
|
||||
@@ -44,9 +36,6 @@ in
|
||||
|
||||
programs.dconf.enable = true;
|
||||
|
||||
# Electron/Chromium apps use native Wayland.
|
||||
environment.sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
|
||||
# Removable drives and trash/mounts in the file manager.
|
||||
services.udisks2.enable = true;
|
||||
services.gvfs.enable = true;
|
||||
@@ -89,9 +78,29 @@ in
|
||||
kbOptions = osConfig.services.xserver.xkb.options;
|
||||
terminal = "wezterm";
|
||||
fileManager = "dolphin";
|
||||
# Binds start apps through this, so each runs as its own scope of the
|
||||
# session (app-graphical.slice) and is stopped before the compositor at
|
||||
# logout, instead of living inside Hyprland's unit.
|
||||
appLauncher = "${lib.getExe' osConfig.programs.uwsm.package "uwsm-app"} --";
|
||||
cursorSize = if cursor.enable then cursor.size else 24;
|
||||
cursorTheme = if cursor.enable then cursor.name else "";
|
||||
};
|
||||
|
||||
# The only place these are defined. UWSM sources uwsm/env-<desktop>
|
||||
# (lowercased XDG_CURRENT_DESKTOP) before the compositor starts and puts
|
||||
# the result into the systemd and D-Bus activation environments, so every
|
||||
# app of the Hyprland session sees them, and nothing outside it does.
|
||||
waylandEnv = {
|
||||
# Electron/Chromium apps use native Wayland.
|
||||
NIXOS_OZONE_WL = "1";
|
||||
ELECTRON_OZONE_PLATFORM_HINT = "auto";
|
||||
GDK_BACKEND = "wayland,x11,*";
|
||||
QT_QPA_PLATFORM = "wayland;xcb";
|
||||
# Falls back to X11 when an SDL app has no Wayland support, but some
|
||||
# older SDL games still break with it (set SDL_VIDEODRIVER=x11 for those).
|
||||
SDL_VIDEODRIVER = "wayland,x11";
|
||||
CLUTTER_BACKEND = "wayland";
|
||||
};
|
||||
in
|
||||
{
|
||||
wayland.windowManager.hyprland = {
|
||||
@@ -123,6 +132,26 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
xdg.configFile."uwsm/env-hyprland".text = lib.concatLines (
|
||||
lib.mapAttrsToList (name: value: "export ${name}=${lib.escapeShellArg value}") waylandEnv
|
||||
);
|
||||
|
||||
# Home-manager's session variables (hm-session-vars.sh) reach shells only.
|
||||
# The compositor, and so the binds, and the user services (Noctalia, and
|
||||
# so the launcher) inherit the systemd user manager's environment instead,
|
||||
# which systemd.user.sessionVariables (environment.d) feeds. Of the
|
||||
# variables home-manager sets, the editor is the one programs outside a
|
||||
# shell look for. Taken from home.sessionVariables, so the neovim aspect
|
||||
# stays the only place that defines them (and nothing breaks when it is
|
||||
# not imported). They apply from the next login.
|
||||
systemd.user.sessionVariables = lib.filterAttrs (
|
||||
name: _:
|
||||
builtins.elem name [
|
||||
"EDITOR"
|
||||
"VISUAL"
|
||||
]
|
||||
) config.home.sessionVariables;
|
||||
|
||||
# Tools the binds call (screenshots, file manager).
|
||||
home.packages = with pkgs; [
|
||||
grim
|
||||
|
||||
@@ -87,3 +87,41 @@ hl.window_rule({
|
||||
|
||||
float = true,
|
||||
})
|
||||
|
||||
-- Proton games map as XWayland windows of class steam_app_<id>, but so do the
|
||||
-- launchers, installers and tools that run in the same prefix (Paradox,
|
||||
-- Rockstar, EA app, Ubisoft Connect, redistributable setups, crash reporters),
|
||||
-- so the class alone cannot tell them apart; the title does. Static rules run
|
||||
-- once, when the window maps: a launcher that sets its title later counts as a
|
||||
-- game. Native Linux Steam games do not use this class and are not covered.
|
||||
local protonClass = "^steam_app_\\d+$"
|
||||
local launcherTitle = "(?i).*("
|
||||
.. "launch(er|ing)|setup|install|updat|redistributable|config|settings"
|
||||
.. "|\\berrors?\\b|crash(ed| ?report| ?handler|pad)|eula|licen[cs]e agreement"
|
||||
.. "|\\bea app\\b|ubisoft connect|\\buplay\\b|social club|battle\\.net|gog galaxy"
|
||||
.. ").*"
|
||||
|
||||
-- Games start fullscreen. float = false skips windows Hyprland floats on its own
|
||||
-- (dialogs, transient and fixed-size windows, menus, tooltips); the negated
|
||||
-- title skips launchers. A game can still leave fullscreen through its own
|
||||
-- settings: suppress_event is deliberately not set.
|
||||
hl.window_rule({
|
||||
name = "steam-games-fullscreen",
|
||||
match = {
|
||||
class = protonClass,
|
||||
title = "negative:" .. launcherTitle,
|
||||
float = false,
|
||||
},
|
||||
|
||||
fullscreen = true,
|
||||
})
|
||||
|
||||
-- Launchers and popups of those games float in the middle of the screen. Same
|
||||
-- title regex as above, not negated, so the two rules never match one window.
|
||||
hl.window_rule({
|
||||
name = "steam-games-launchers",
|
||||
match = { class = protonClass, title = launcherTitle },
|
||||
|
||||
float = true,
|
||||
center = true,
|
||||
})
|
||||
@@ -8,7 +8,7 @@ local nix = require("nixvars")
|
||||
|
||||
-- Any output, native mode, placed automatically. Use mode = "highrr" to prefer
|
||||
-- the highest refresh rate instead.
|
||||
hl.env("AQ_DRM_DEVICES", "/dev/dri/card1:/dev/dri/card0")
|
||||
-- hl.env("AQ_DRM_DEVICES", "/dev/dri/card1:/dev/dri/card0")
|
||||
hl.monitor({
|
||||
output = "DP-1",
|
||||
mode = "preferred",
|
||||
@@ -51,10 +51,18 @@ hl.monitor({
|
||||
---- ENVIRONMENT VARIABLES ----
|
||||
-------------------------------
|
||||
|
||||
hl.env("XCURSOR_SIZE", tostring(nix.cursorSize))
|
||||
hl.env("HYPRCURSOR_SIZE", tostring(nix.cursorSize))
|
||||
-- The Wayland toolkit variables (GDK_BACKEND, QT_QPA_PLATFORM, ...) are exported
|
||||
-- for the whole session by UWSM (uwsm/env-hyprland, see default.nix), not here.
|
||||
|
||||
-- hl.env sets a variable for Hyprland and what it starts. With true as the third
|
||||
-- argument it also exports it to the systemd user manager and the D-Bus
|
||||
-- activation environment (systemctl --user import-environment and
|
||||
-- dbus-update-activation-environment --systemd), so apps started by Noctalia,
|
||||
-- the portals or D-Bus activation use the same cursor.
|
||||
hl.env("XCURSOR_SIZE", tostring(nix.cursorSize), true)
|
||||
hl.env("HYPRCURSOR_SIZE", tostring(nix.cursorSize), true)
|
||||
if nix.cursorTheme ~= "" then
|
||||
hl.env("XCURSOR_THEME", nix.cursorTheme)
|
||||
hl.env("XCURSOR_THEME", nix.cursorTheme, true)
|
||||
end
|
||||
|
||||
-----------------------
|
||||
|
||||
+240
-17
@@ -4,10 +4,15 @@
|
||||
# (NetworkManager, Bluetooth, UPower, power profiles). The user
|
||||
# service is started by home-manager, so
|
||||
# `programs.noctalia.systemd` stays off here.
|
||||
# home-manager the user service and the shell settings.
|
||||
# home-manager the user service (started once Hyprland answers) and the shell
|
||||
# settings.
|
||||
# The NixOS half adds the home-manager half to the owner, so a host imports
|
||||
# `nixos.noctalia` once.
|
||||
#
|
||||
# Needs the hyprland aspect (desktop/hyprland, with UWSM): the service waits for
|
||||
# Hyprland's request socket (hyprctl), and apps and terminals start through
|
||||
# uwsm-app. The NixOS half asserts it.
|
||||
#
|
||||
# The modules come from the noctalia flake. home-manager ships its own
|
||||
# `programs.noctalia` too (modules/programs/noctalia), and nixpkgs has one for
|
||||
# NixOS; the flake's modules list those in `disabledModules`, so importing them
|
||||
@@ -27,10 +32,21 @@ let
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.noctalia =
|
||||
{ pkgs, ... }:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
imports = [ inputs.noctalia.nixosModules.default ];
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.programs.hyprland.enable && config.programs.hyprland.withUWSM;
|
||||
message = ''
|
||||
The Noctalia service (desktop/noctalia.nix) waits for Hyprland and
|
||||
starts apps through uwsm-app, so it needs the hyprland aspect
|
||||
(desktop/hyprland) with programs.hyprland.withUWSM.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
home-manager.users.${owner.name}.imports = [ hmNoctalia ];
|
||||
|
||||
programs.noctalia = {
|
||||
@@ -42,26 +58,233 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
flake.modules.homeManager.noctalia = {
|
||||
imports = [ inputs.noctalia.homeModules.default ];
|
||||
flake.modules.homeManager.noctalia =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
osConfig,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.programs.noctalia;
|
||||
inherit (osConfig.stylix) image;
|
||||
|
||||
programs.noctalia = {
|
||||
enable = true;
|
||||
# Starts apps as scopes of the graphical session (see launch_apps_*
|
||||
# below). The same launcher the Hyprland binds use.
|
||||
uwsmApp = lib.getExe' osConfig.programs.uwsm.package "uwsm-app";
|
||||
|
||||
# A user service instead of hl.exec_cmd, so it restarts on failure and
|
||||
# follows graphical-session.target (managed by UWSM).
|
||||
systemd.enable = true;
|
||||
# Noctalia asks Hyprland once, at startup, whether the config is Lua
|
||||
# (`j/status`, 500 ms timeout, no retry) and sends a workspace click as
|
||||
# hl.dsp.focus or as the legacy `dispatch workspace` accordingly; a Lua
|
||||
# config rejects the legacy form. graphical-session.target comes up before
|
||||
# the compositor answers on its request socket, so at login that request
|
||||
# can time out (the journal shows a 0.5 s pause right after the
|
||||
# RLIMIT_NOFILE line), Noctalia keeps "not Lua", and the workspace buttons
|
||||
# in the bar do nothing until the shell is restarted. So start it only once
|
||||
# Hyprland has answered the status request (a JSON object with
|
||||
# `configProvider`; what it says is Noctalia's business, it only needs the
|
||||
# request to succeed, so a non-Lua config does not stall the start) and has
|
||||
# workspaces (the workspace list also decides Noctalia's IPC schema). After
|
||||
# 15 s start anyway, a late bar beats none.
|
||||
#
|
||||
# XDG_SESSION_ID: a user service is not part of the login session, so
|
||||
# logind cannot find the session by PID (NoSessionForPID). Noctalia then
|
||||
# loses the lock-session handling and the brightness lookup. It tries
|
||||
# XDG_SESSION_ID first, so export the user's graphical session.
|
||||
#
|
||||
# exec, so Restart=on-failure sees Noctalia's own exit status. Nothing in
|
||||
# the wait or the lookup may fail the unit.
|
||||
session = pkgs.writeShellApplication {
|
||||
name = "noctalia-session";
|
||||
runtimeInputs = [ pkgs.coreutils ];
|
||||
text = ''
|
||||
hyprctl=${lib.getExe' osConfig.programs.hyprland.package "hyprctl"}
|
||||
jq=${lib.getExe pkgs.jq}
|
||||
|
||||
settings.shell = {
|
||||
telemetry_enabled = false;
|
||||
# Both probes get the 0.5 s Noctalia's own request has.
|
||||
ready() {
|
||||
[ -n "''${HYPRLAND_INSTANCE_SIGNATURE:-}" ] &&
|
||||
timeout 0.5 "$hyprctl" -j status | "$jq" -e 'has("configProvider")' >/dev/null &&
|
||||
timeout 0.5 "$hyprctl" -j workspaces | "$jq" -e 'length > 0' >/dev/null
|
||||
}
|
||||
|
||||
# No other polkit agent is started in the session.
|
||||
polkit_agent = true;
|
||||
deadline=$((SECONDS + 15))
|
||||
until ready 2>/dev/null; do
|
||||
if [ "$SECONDS" -ge "$deadline" ]; then
|
||||
echo "Hyprland not ready after 15 s, starting Noctalia anyway" >&2
|
||||
break
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
# Apps started from the launcher get their own systemd scope, so
|
||||
# restarting the shell service does not kill them.
|
||||
launch_apps_as_systemd_services = true;
|
||||
session=$(${lib.getExe' osConfig.systemd.package "loginctl"} show-user "$(id -u)" -p Display --value 2>/dev/null || true)
|
||||
if [ -n "$session" ]; then
|
||||
export XDG_SESSION_ID="$session"
|
||||
fi
|
||||
|
||||
exec ${lib.getExe cfg.package}
|
||||
'';
|
||||
};
|
||||
|
||||
# Stylix's wallpaper is a store path that changes with every new image,
|
||||
# and Noctalia keeps the path it was given in its runtime state. A fixed
|
||||
# link in $HOME survives that; the file behind it is replaced on switch.
|
||||
wallpaperExt = lib.optionalString (builtins.match ".*(\\.[A-Za-z0-9]+)" image != null) (
|
||||
lib.head (builtins.match ".*(\\.[A-Za-z0-9]+)" image)
|
||||
);
|
||||
wallpaperFile = "wallpapers/wallpaper${wallpaperExt}";
|
||||
wallpaperLink = "${config.xdg.dataHome}/${wallpaperFile}";
|
||||
|
||||
# Noctalia stores the wallpaper it was given (or picked in its own panel)
|
||||
# in its runtime state, ~/.local/state/noctalia/settings.toml, which is
|
||||
# applied after the declarative settings and wins over them. A path from
|
||||
# the Nix store (the bundled image of a first run, an older Stylix image)
|
||||
# stays in there after garbage collection deletes the file, and the
|
||||
# shell then shows no wallpaper whatever `wallpaper.default.path` says.
|
||||
# So once Noctalia answers on its IPC socket, look at what it reports
|
||||
# and, if that file is gone, point it at the stable link instead.
|
||||
#
|
||||
# `wallpaper-get` prints the default path; `wallpaper-get <connector>` the
|
||||
# effective one of a monitor (its own entry, else the default), and fails
|
||||
# for a monitor Noctalia does not know. `wallpaper-set <path>` sets the
|
||||
# default and every connected monitor (there is no call for the default
|
||||
# alone), `wallpaper-set <connector> <path>` one monitor, both persisted
|
||||
# to the runtime state. A missing default is repaired for all monitors,
|
||||
# otherwise only the monitors whose own path is gone.
|
||||
#
|
||||
# Run as ExecStartPost, so it may never fail the unit: it gives up quietly
|
||||
# when Noctalia does not answer within 10 s (plus one 2 s call), when the
|
||||
# link is not there yet, or when a call fails.
|
||||
healWallpaper = pkgs.writeShellApplication {
|
||||
name = "noctalia-heal-wallpaper";
|
||||
runtimeInputs = [
|
||||
pkgs.coreutils
|
||||
pkgs.jq
|
||||
];
|
||||
text = ''
|
||||
noctalia=${lib.getExe cfg.package}
|
||||
hyprctl=${lib.getExe' osConfig.programs.hyprland.package "hyprctl"}
|
||||
link=${lib.escapeShellArg wallpaperLink}
|
||||
|
||||
# Nothing to point Noctalia at before home-manager has linked the image.
|
||||
[ -f "$link" ] || exit 0
|
||||
|
||||
msg() { timeout 2 "$noctalia" msg "$@" 2>/dev/null; }
|
||||
|
||||
# A regular file (a symlink counts when its target is one), or the solid
|
||||
# colour Noctalia also takes as a wallpaper.
|
||||
usable() { [ -f "$1" ] || [[ "$1" == color:* ]]; }
|
||||
|
||||
# Rc 1 means the socket is not there yet or the wallpaper service is not
|
||||
# initialised yet; either way try again.
|
||||
deadline=$((SECONDS + 10))
|
||||
until default=$(msg wallpaper-get); do
|
||||
if [ "$SECONDS" -ge "$deadline" ]; then
|
||||
echo "Noctalia did not answer within 10 s, wallpaper not checked" >&2
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
if ! usable "$default"; then
|
||||
echo "Noctalia's wallpaper \"$default\" is gone, using $link" >&2
|
||||
reply=$(msg wallpaper-set "$link") || echo "wallpaper-set failed: $reply" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mapfile -t monitors < <(timeout 1 "$hyprctl" -j monitors 2>/dev/null | jq -r '.[].name' 2>/dev/null || true)
|
||||
for monitor in "''${monitors[@]}"; do
|
||||
path=$(msg wallpaper-get "$monitor") || continue
|
||||
if ! usable "$path"; then
|
||||
echo "Noctalia's wallpaper \"$path\" on $monitor is gone, using $link" >&2
|
||||
reply=$(msg wallpaper-set "$monitor" "$link") || echo "wallpaper-set $monitor failed: $reply" >&2
|
||||
fi
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
# Terminal=true launcher entries: Noctalia runs `$TERMINAL -e sh -lc
|
||||
# <command>` (the command already wrapped in uwsm-app, see
|
||||
# launch_apps_custom_command) and starts that with a plain fork, so the
|
||||
# terminal would live in noctalia.service's cgroup and die whenever the
|
||||
# shell restarts, on every switch that changes it. This is the $TERMINAL
|
||||
# Noctalia gets (Service.Environment below): it takes that call and
|
||||
# starts WezTerm through uwsm-app, as a scope of its own like the Hyprland
|
||||
# binds do. The terminal is the one of the binds (nixVars.terminal in
|
||||
# hyprland/default.nix), started by name and resolved by uwsm.
|
||||
#
|
||||
# Noctalia's `-e` is dropped and WezTerm's own `start --` put in its
|
||||
# place: WezTerm knows `-e` only as another name of the `start`
|
||||
# subcommand, and the `--` keeps `-lc` from being read as a WezTerm
|
||||
# option. uwsm-terminal* do not fit: they run `uwsm app -T`, which builds
|
||||
# the call from the terminal's desktop entry (`wezterm start --cwd .`)
|
||||
# plus `-e`, and `wezterm start ... -e` is not a WezTerm option.
|
||||
terminal = pkgs.writeShellApplication {
|
||||
name = "noctalia-terminal";
|
||||
text = ''
|
||||
if [ "''${1:-}" = "-e" ]; then
|
||||
shift
|
||||
fi
|
||||
if [ "$#" -gt 0 ]; then
|
||||
set -- -- "$@"
|
||||
fi
|
||||
exec ${uwsmApp} -- wezterm start "$@"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ inputs.noctalia.homeModules.default ];
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
programs.noctalia = {
|
||||
enable = true;
|
||||
|
||||
# A user service instead of hl.exec_cmd, so it restarts on failure and
|
||||
# follows graphical-session.target (managed by UWSM).
|
||||
systemd.enable = true;
|
||||
|
||||
settings.shell = {
|
||||
telemetry_enabled = false;
|
||||
|
||||
# No other polkit agent is started in the session.
|
||||
polkit_agent = true;
|
||||
|
||||
# Apps from the launcher, dock and taskbar start through uwsm-app, as
|
||||
# scopes in app-graphical.slice. UWSM stops that slice before the
|
||||
# compositor, so apps close cleanly at logout (Firefox saves its
|
||||
# session), and restarting the shell does not kill them. Noctalia's own
|
||||
# systemd launcher would put them in app.slice, which is not ordered
|
||||
# before the compositor, and it overrides the custom command, so it
|
||||
# stays off.
|
||||
launch_apps_as_systemd_services = false;
|
||||
launch_apps_custom_command = "${uwsmApp} -- $CMD";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.noctalia.Service = {
|
||||
ExecStart = lib.mkForce (lib.getExe session);
|
||||
|
||||
# The terminal for Terminal=true entries (see `terminal` above).
|
||||
Environment = [ "TERMINAL=${lib.getExe terminal}" ];
|
||||
};
|
||||
}
|
||||
|
||||
(lib.mkIf (image != null) {
|
||||
xdg.dataFile.${wallpaperFile}.source = image;
|
||||
|
||||
# Stylix's noctalia target writes the same key with the store path.
|
||||
programs.noctalia.settings.wallpaper.default.path = lib.mkForce wallpaperLink;
|
||||
|
||||
# Another image, or the same path with new contents: reload the shell.
|
||||
systemd.user.services.noctalia.Unit.X-Restart-Triggers = [ "${image}" ];
|
||||
|
||||
# Repairs a wallpaper path in Noctalia's runtime state that no longer
|
||||
# exists (see `healWallpaper` above). The `-` keeps a failure from
|
||||
# failing the unit; the script does not fail anyway.
|
||||
systemd.user.services.noctalia.Service.ExecStartPost = "-${lib.getExe healWallpaper}";
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
# Obsidian (home-manager only): the app, one vault and its community plugins,
|
||||
# configured declaratively through home-manager's programs.obsidian.
|
||||
#
|
||||
# The vault is ~/Documents/Notes, backed up with git to the owner's Gitea by the
|
||||
# obsidian-git plugin. Everything under .obsidian/ comes from Nix and is not
|
||||
# committed:
|
||||
# - app.json, appearance.json, core-plugins.json, community-plugins.json, the
|
||||
# core plugin files (daily-notes.json) and the Stylix CSS snippet are links
|
||||
# into the store. Obsidian cannot write to them, so a setting changed in its
|
||||
# settings window does not stick: change it here instead.
|
||||
# - Each plugin directory holds links to the pinned release files. The
|
||||
# data.json of the few plugins that get settings here is a plain file,
|
||||
# merged at activation (see pluginSettings), not a link: Calendar rewrites
|
||||
# its data.json every time it loads, which a link into the store would make
|
||||
# fail. The other plugins create their own data.json.
|
||||
# What is not in the vault and so cannot be declared: whether community plugins
|
||||
# are trusted (the first time the vault opens Obsidian asks, "Turn on community
|
||||
# plugins") and the spellcheck languages (Settings -> Editor), both kept in
|
||||
# Obsidian's own browser storage.
|
||||
#
|
||||
# Colours and fonts come from Stylix (the `obsidian` target, switched on for the
|
||||
# vault in theme/stylix.nix): a CSS snippet with the palette, the UI and
|
||||
# monospace fonts. Only the dark/light base scheme is chosen here. A host
|
||||
# importing this aspect imports `theme` too.
|
||||
#
|
||||
# Claude Code can read and search the vault: ai/claude-code.nix adds every
|
||||
# enabled vault to its additional directories. A short CLAUDE.md in the
|
||||
# vault tells it the conventions. There is no Obsidian MCP server: nixpkgs has
|
||||
# none, the popular ones go through the Local REST API plugin with an API key,
|
||||
# and plain file access already covers reading and searching Markdown.
|
||||
{
|
||||
flake.modules.homeManager.obsidian =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
osConfig,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# The attribute name must be listed in stylix.targets.obsidian.vaultNames
|
||||
# (theme/stylix.nix; checked by the assertion below). The target is
|
||||
# relative to $HOME: Documents is a btrfs subvolume on the data SSD.
|
||||
vaultName = "Notes";
|
||||
vaultTarget = "Documents/${vaultName}";
|
||||
vaultDir = "${config.home.homeDirectory}/${vaultTarget}";
|
||||
|
||||
# Created empty on Gitea by hand; the first push by obsidian-git fills it.
|
||||
remote = "gitea@git.faumaray.ru:faumaray/Notes.git";
|
||||
|
||||
# Community plugins: pinned GitHub release assets, none of them is in
|
||||
# nixpkgs. The attribute name is the plugin id (manifest.json "id", which
|
||||
# is also its directory name under .obsidian/plugins; the build checks
|
||||
# it). To update one: change `version`, set its hashes to lib.fakeHash and
|
||||
# copy the real ones from the build error (or
|
||||
# `nix store prefetch-file <asset url>`). Not every release has a
|
||||
# styles.css. Each release's minAppVersion must stay at or below the
|
||||
# Obsidian in nixpkgs. Dataview's 0.5.70 release still says 0.5.68 in its
|
||||
# manifest.json; that is upstream's, not a mistake here.
|
||||
plugins = {
|
||||
# Queries over notes: tables and lists from frontmatter and inline fields.
|
||||
dataview = {
|
||||
repo = "blacksmithgu/obsidian-dataview";
|
||||
version = "0.5.70";
|
||||
hashes = {
|
||||
"main.js" = "sha256-a7HPcBCvrYMOc1dfyg4r+9MnnFYuPZ0k8tL0UWHrfQA=";
|
||||
"manifest.json" = "sha256-kjXbRxEtqBuFWRx57LmuJXTl5yIHBW6XZHL5BhYoYYU=";
|
||||
"styles.css" = "sha256-MwbdkDLgD5ibpyM6N/0lW8TT9DQM7mYXYulS8/aqHek=";
|
||||
};
|
||||
};
|
||||
# Templates with logic (`<% tp.date.now() %>`), for notes made by hand.
|
||||
templater-obsidian = {
|
||||
repo = "SilentVoid13/Templater";
|
||||
version = "2.26.0";
|
||||
hashes = {
|
||||
"main.js" = "sha256-Cs1Fz9s6czfivvURaZvB+BncZGRa00gN8zV51C0ty6o=";
|
||||
"manifest.json" = "sha256-kcn6hRAIL/+gs9AiqsSYbjs5IpWxEm6Efq1+1yiRabg=";
|
||||
"styles.css" = "sha256-Z6bdLR1t7coSh8M0yohOxBlkM/ccpHOIoL0+rBTPi18=";
|
||||
};
|
||||
};
|
||||
# Month calendar next to the daily notes. Upstream's last release is
|
||||
# from 2021 and it still works; there is no maintained drop-in.
|
||||
calendar = {
|
||||
repo = "liamcain/obsidian-calendar-plugin";
|
||||
version = "1.5.10";
|
||||
hashes = {
|
||||
"main.js" = "sha256-f7M56c+f2+WoAforirhbNmtbN3f70ZPLyHKLwncR0SU=";
|
||||
"manifest.json" = "sha256-8+lYEzhkhRK6oS1bRYSQ9/02eRj3vba9hhcc5Xvn0Is=";
|
||||
};
|
||||
};
|
||||
# Tasks across the vault with due dates, recurrence and queries.
|
||||
obsidian-tasks-plugin = {
|
||||
repo = "obsidian-tasks-group/obsidian-tasks";
|
||||
version = "8.6.0";
|
||||
hashes = {
|
||||
"main.js" = "sha256-UA+BBtBd20g7v+wTXKx5SAIr9rpzhtGFGyj00IeGbo8=";
|
||||
"manifest.json" = "sha256-LvyI356XMkc2DUhrQgeRwmbIgkUWkZMDuUjQGS4VkSc=";
|
||||
"styles.css" = "sha256-1w2OvUH8I7/V1Zhzsak+2VVLFUVGo+Y3vU4ELmLRzyM=";
|
||||
};
|
||||
};
|
||||
# Drawings and diagrams stored as Markdown files (Excalidraw/ by default).
|
||||
obsidian-excalidraw-plugin = {
|
||||
repo = "zsviczian/obsidian-excalidraw-plugin";
|
||||
version = "2.29.0";
|
||||
hashes = {
|
||||
"main.js" = "sha256-TaIISk6v59MoSE+ldCAEufuZA0bEyE/ekkuIWl7MHBc=";
|
||||
"manifest.json" = "sha256-SIC4hcUGQ++EjTHOqCl3bKLpZ0c1Ou4zTXHodfedMcA=";
|
||||
"styles.css" = "sha256-Fz6cFhoBxTs8FzNE4CPeTTJ/0GWOR2lhtGsOapMRfe0=";
|
||||
};
|
||||
};
|
||||
|
||||
# Code-focused set. Tables: Tab/Enter move between cells and reformat
|
||||
# the table as it is edited (Markdown tables are tedious by hand).
|
||||
table-editor-obsidian = {
|
||||
repo = "tgrosinger/advanced-tables-obsidian";
|
||||
version = "0.23.2";
|
||||
hashes = {
|
||||
"main.js" = "sha256-z13U3b3evvaMyZzZOog+M4lcfxI9BLxdEQbqbjOLp5E=";
|
||||
"manifest.json" = "sha256-aYtPd0ReB9iH8zRQ6vUzoo4Jm3tIP2QvqIM2L/vY/+k=";
|
||||
"styles.css" = "sha256-I/ow128Rf9PRYkxMLm3e2r+AmSOZawU0iV+CVOpqOfc=";
|
||||
};
|
||||
};
|
||||
# Formatter for notes (YAML, headings, spacing), run by hand or on save.
|
||||
obsidian-linter = {
|
||||
repo = "platers/obsidian-linter";
|
||||
version = "1.34.2";
|
||||
hashes = {
|
||||
"main.js" = "sha256-ova0R27tYWq6ZOlT6t2ut58h16jbB1nrsHD70CgUIYs=";
|
||||
"manifest.json" = "sha256-4Cpa3FPccf7ewVhBNfvToCS1aYQ0y79socu5sSnuduA=";
|
||||
"styles.css" = "sha256-rto6ZoBw3h5IZQ0WE6lr0Bjgt7OqX6vchSY1ifEZhjQ=";
|
||||
};
|
||||
};
|
||||
# Syntax highlighting of fenced code blocks in reading and editing view
|
||||
# (Shiki, 200+ languages), line numbers, line highlights, copy button.
|
||||
# Chosen over Code Styler, whose last commit is from January 2025 and
|
||||
# last release from February 2024; this one released in April 2026. Its
|
||||
# default theme follows the Obsidian colours, so Stylix reaches it.
|
||||
shiki-highlighter = {
|
||||
repo = "mProjectsCode/obsidian-shiki-plugin";
|
||||
version = "0.7.7";
|
||||
hashes = {
|
||||
"main.js" = "sha256-uCv60MqhG5GruQFMNHtKn675V1vWPXWxKbsCeqteYMA=";
|
||||
"manifest.json" = "sha256-viPX7+Ea/NEvkpucdByYs+8zWTfPy6H3YrQ95sd/15E=";
|
||||
"styles.css" = "sha256-zKx7aLmW251TJky3iWiFebFCtHJRQiEK9U8xHptmVSU=";
|
||||
};
|
||||
};
|
||||
|
||||
# Backup and sync of the vault with git.
|
||||
obsidian-git = {
|
||||
repo = "Vinzent03/obsidian-git";
|
||||
version = "2.42.0";
|
||||
hashes = {
|
||||
"main.js" = "sha256-SW2xSLzqQWn0VeI0uwLwj4xQwxfArVr947J8CQTa8TM=";
|
||||
"manifest.json" = "sha256-etmOjM4VfphGtHlBxqfLmwIrydXG0ReCKQ56ehZLRw0=";
|
||||
"styles.css" = "sha256-8wrSykL+/jtwTFSPd0fShcIDj6TOkGAeaP5v1mBJQFI=";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# A plugin directory laid out as Obsidian wants it: the release files.
|
||||
# home-manager would read manifest.json at evaluation (import from
|
||||
# derivation) to learn the id unless the package says it, hence
|
||||
# `manifestId`.
|
||||
mkPlugin =
|
||||
id:
|
||||
{
|
||||
repo,
|
||||
version,
|
||||
hashes,
|
||||
}:
|
||||
pkgs.runCommand "obsidian-plugin-${id}-${version}"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs.jq ];
|
||||
passthru.manifestId = id;
|
||||
}
|
||||
''
|
||||
mkdir -p $out
|
||||
${lib.concatStrings (
|
||||
lib.mapAttrsToList (file: hash: ''
|
||||
cp ${
|
||||
pkgs.fetchurl {
|
||||
url = "https://github.com/${repo}/releases/download/${version}/${file}";
|
||||
inherit hash;
|
||||
}
|
||||
} $out/${file}
|
||||
'') hashes
|
||||
)}
|
||||
if ! jq -e --arg id ${lib.escapeShellArg id} '.id == $id' $out/manifest.json > /dev/null; then
|
||||
echo "manifest.json of ${id} ${version} has id $(jq -r .id $out/manifest.json)" >&2
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
# Commit message of the automatic backups, and of manual commits.
|
||||
commitMessage = "vault backup: {{hostname}} {{date}}, {{numFiles}} file(s)";
|
||||
|
||||
# data.json of the plugins whose settings are declared here (the others
|
||||
# run on their defaults). Declared keys win on every switch, anything else
|
||||
# the plugin keeps in the file survives. Keys are the plugin's own; check
|
||||
# them against its source when updating the plugin.
|
||||
pluginSettings = {
|
||||
obsidian-git = {
|
||||
# Pull when the vault opens. Until the first push gives the branch an
|
||||
# upstream the plugin skips this (git's push.autoSetupRemote is on).
|
||||
autoPullOnBoot = true;
|
||||
# Every 10 minutes: commit any changes, pull (so what another device
|
||||
# pushed arrives too), push what is unpushed. No empty commits.
|
||||
autoSaveInterval = 10;
|
||||
autoCommitMessage = commitMessage;
|
||||
inherit commitMessage;
|
||||
# No notice every 10 minutes saying there was nothing to commit.
|
||||
disablePopupsForNoChanges = true;
|
||||
};
|
||||
templater-obsidian = {
|
||||
# Schema version 2; without it Templater treats the file as the old
|
||||
# format and migrates (rewrites) it.
|
||||
data_version = 2;
|
||||
templates_folder = "Templates";
|
||||
};
|
||||
# Weeks start on Monday (the default follows the en_US locale: Sunday).
|
||||
calendar.weekStart = "monday";
|
||||
};
|
||||
|
||||
# Files written once when the vault is created (see obsidianVault below).
|
||||
# They are regular files in the repository, so a link into the store would
|
||||
# be committed as one.
|
||||
gitignore = pkgs.writeText "obsidian-vault-gitignore" ''
|
||||
# Generated by Nix (home-manager) and the same on every machine.
|
||||
.obsidian/
|
||||
.trash/
|
||||
|
||||
# OS junk.
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
.directory
|
||||
'';
|
||||
|
||||
# Core variables ({{title}}, {{date}}), which the Daily notes plugin fills
|
||||
# in itself; Templater's `<% %>` syntax is not used here, because
|
||||
# Templater triggers on new files only when that is enabled on the device
|
||||
# (a per-device setting it keeps outside the vault).
|
||||
dailyTemplate = pkgs.writeText "obsidian-vault-daily-template" ''
|
||||
---
|
||||
tags:
|
||||
- daily
|
||||
---
|
||||
|
||||
# {{title}}
|
||||
|
||||
## Tasks
|
||||
|
||||
## Notes
|
||||
'';
|
||||
|
||||
vaultClaudeMd = pkgs.writeText "obsidian-vault-claude-md" ''
|
||||
# Notes vault
|
||||
|
||||
Personal Obsidian vault: Markdown files, backed up to Gitea by the
|
||||
obsidian-git plugin (an automatic commit every 10 minutes). Read and
|
||||
search it freely; change notes only when asked.
|
||||
|
||||
## Layout
|
||||
|
||||
- `Inbox/`: new notes land here; the owner files them into topic folders.
|
||||
- `Daily/YYYY-MM-DD.md`: daily notes, made from `Templates/Daily.md`.
|
||||
- `Templates/`: the Templater folder and the daily note template.
|
||||
- `Attachments/`: images and other files pasted into notes.
|
||||
- `Excalidraw/`: drawings (`*.excalidraw.md`), not meant to be edited as text.
|
||||
- Other folders are topics chosen by the owner.
|
||||
|
||||
## Conventions
|
||||
|
||||
- Links are wikilinks, `[[Note name]]`; keep file names unique so the
|
||||
short form works.
|
||||
- Metadata is YAML frontmatter; tags are lower case and nested with a
|
||||
slash, for example `project/nixos`.
|
||||
- Tasks use the Tasks plugin format: `- [ ] text 📅 2026-12-31`.
|
||||
- Dataview queries live in ```` ```dataview ```` blocks; leave them as they are.
|
||||
- Notes are in English or Russian; keep the language of the note.
|
||||
- Make small edits. Do not reformat or rewrite whole notes.
|
||||
|
||||
## Never touch
|
||||
|
||||
- `.obsidian/`: generated by Nix and read-only; change it in the NixOS
|
||||
configuration, not here.
|
||||
- `.git/`: do not commit or push; obsidian-git does that.
|
||||
'';
|
||||
in
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = builtins.elem vaultName config.stylix.targets.obsidian.vaultNames;
|
||||
message = ''
|
||||
The Obsidian vault "${vaultName}" (desktop/obsidian.nix) gets its
|
||||
colours and fonts from Stylix only if it is listed in
|
||||
stylix.targets.obsidian.vaultNames (theme/stylix.nix).
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
programs.obsidian = {
|
||||
enable = true;
|
||||
|
||||
vaults.${vaultName} = {
|
||||
target = vaultTarget;
|
||||
|
||||
settings = {
|
||||
app = {
|
||||
# New notes go to Inbox/ (created below; Obsidian falls back to
|
||||
# the vault root while the folder is missing). Pasted files go to
|
||||
# one Attachments/ folder instead of cluttering the notes.
|
||||
newFileLocation = "folder";
|
||||
newFileFolderPath = "Inbox";
|
||||
attachmentFolderPath = "Attachments";
|
||||
# Renaming or moving a note rewrites the links to it, without asking.
|
||||
alwaysUpdateLinks = true;
|
||||
# Vim keybindings in the editor: the owner lives in Neovim. Set
|
||||
# to false for the plain editor.
|
||||
vimMode = true;
|
||||
readableLineLength = true;
|
||||
# The spellcheck languages (en, ru) are a per-device setting in
|
||||
# Settings -> Editor; they cannot be declared.
|
||||
spellcheck = true;
|
||||
};
|
||||
|
||||
# Stylix adds the fonts and the colour snippet; this picks the base
|
||||
# scheme the snippet is written for (it follows the Stylix polarity).
|
||||
appearance.theme = if osConfig.stylix.polarity == "dark" then "obsidian" else "moonstone";
|
||||
|
||||
# Core plugins: navigation (files, search, quick switcher, backlinks,
|
||||
# outgoing links, outline, graph, bookmarks, tags, page preview),
|
||||
# editing (properties, note composer, command palette, status bar,
|
||||
# word count), daily notes, canvas and file recovery. The core
|
||||
# Templates plugin is off: Templater replaces it.
|
||||
corePlugins = [
|
||||
"file-explorer"
|
||||
"global-search"
|
||||
"switcher"
|
||||
"backlink"
|
||||
"outgoing-link"
|
||||
"outline"
|
||||
"graph"
|
||||
"bookmarks"
|
||||
"tag-pane"
|
||||
"page-preview"
|
||||
"properties"
|
||||
"note-composer"
|
||||
"command-palette"
|
||||
"editor-status"
|
||||
"word-count"
|
||||
"canvas"
|
||||
"file-recovery"
|
||||
{
|
||||
name = "daily-notes";
|
||||
settings = {
|
||||
folder = "Daily";
|
||||
format = "YYYY-MM-DD";
|
||||
template = "Templates/Daily";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
communityPlugins = lib.mapAttrsToList mkPlugin plugins;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# data.json of the plugins: see pluginSettings. After linkGeneration, which
|
||||
# creates the plugin directories.
|
||||
home.activation.obsidianPluginSettings = lib.hm.dag.entryAfter [ "linkGeneration" ] (
|
||||
lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (
|
||||
id: settings:
|
||||
lib.hm.generators.mkImpureConfigMerger {
|
||||
inherit pkgs;
|
||||
format = "json";
|
||||
empty = "{}";
|
||||
jqOperation = "$dynamic * $static";
|
||||
path = "${vaultDir}/.obsidian/plugins/${id}/data.json";
|
||||
staticSettings = (pkgs.formats.json { }).generate "obsidian-${id}-data.json" settings;
|
||||
verboseMsg = "Merging the Obsidian ${id} settings into its data.json";
|
||||
}
|
||||
) pluginSettings
|
||||
)
|
||||
);
|
||||
|
||||
# The vault as a git repository, once. The existence of .git marks it as
|
||||
# done: an existing repository (or one cloned there beforehand) is never
|
||||
# touched, nor are its remotes. Files are written before `git init`, so a
|
||||
# switch that fails half way is finished by the next one. Never pushes.
|
||||
# On a second machine the vault already exists on Gitea: instead of
|
||||
# waiting for this, clone it into place first (git clone), or run
|
||||
# `git fetch && git checkout -f -B main origin/main` in the new vault to
|
||||
# replace the files written here.
|
||||
home.activation.obsidianVault = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
|
||||
vault="$HOME/${vaultTarget}"
|
||||
|
||||
if [ ! -e "$vault/.git" ]; then
|
||||
# A folder that is missing makes the Daily notes plugin refuse to
|
||||
# create today's note and new notes fall back to the vault root; git
|
||||
# keeps empty folders only with a file in them.
|
||||
run mkdir -p "$vault/Inbox" "$vault/Daily" "$vault/Templates"
|
||||
run touch "$vault/Inbox/.gitkeep" "$vault/Daily/.gitkeep"
|
||||
|
||||
obsidian_seed() {
|
||||
if [ ! -e "$2" ]; then
|
||||
run install -m 0644 "$1" "$2"
|
||||
fi
|
||||
}
|
||||
obsidian_seed ${gitignore} "$vault/.gitignore"
|
||||
obsidian_seed ${vaultClaudeMd} "$vault/CLAUDE.md"
|
||||
obsidian_seed ${dailyTemplate} "$vault/Templates/Daily.md"
|
||||
|
||||
run ${lib.getExe pkgs.git} -C "$vault" init --quiet -b main
|
||||
run ${lib.getExe pkgs.git} -C "$vault" remote add origin ${lib.escapeShellArg remote}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
# Login screen: SDDM as a Wayland greeter, NixOS half only.
|
||||
# NixOS the display manager with the Catppuccin SDDM theme. No autologin:
|
||||
# the owner types the password at every boot, and that password also
|
||||
# unlocks gnome-keyring (the `sddm` PAM service substacks `login`,
|
||||
# and services.gnome.gnome-keyring adds pam_gnome_keyring to `login`).
|
||||
# The session offered first is UWSM-managed Hyprland (`hyprland-uwsm`, from
|
||||
# programs.hyprland.withUWSM in desktop/hyprland), so a host importing this
|
||||
# aspect imports `hyprland` and `theme` too. The theme takes what it shows from
|
||||
# Stylix (theme/stylix.nix): the palette's flavour, the font, the cursor and
|
||||
# the wallpaper.
|
||||
# Greeter: Weston in kiosk mode (the nixpkgs default compositor), which takes
|
||||
# the keyboard layouts from services.xserver.xkb (Alt+Shift switches; the theme
|
||||
# has no layout indicator). Weston is not configured per monitor here, so with
|
||||
# two monitors expect the greeter on one of them.
|
||||
{
|
||||
flake.modules.nixos.sddm =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (config) stylix;
|
||||
|
||||
# The theme ships one directory per flavour and accent. The flavour is the
|
||||
# one the Stylix palette is named after (catppuccin-mocha -> mocha), so
|
||||
# the greeter follows a palette switch to another Catppuccin flavour.
|
||||
flavor = lib.removePrefix "catppuccin-" config.lib.stylix.colors.slug;
|
||||
# The same accent as the Noctalia theme ("Catppuccin Mocha Lavender").
|
||||
accent = "lavender";
|
||||
|
||||
catppuccin-sddm = pkgs.catppuccin-sddm.override {
|
||||
inherit flavor accent;
|
||||
# The Stylix UI font, which is also what GTK and Qt apps use. (The
|
||||
# shell overrides it for itself with Monaspace Krypton, see
|
||||
# theme/stylix.nix; the greeter follows the system font instead of
|
||||
# repeating that literal.)
|
||||
font = stylix.fonts.sansSerif.name;
|
||||
fontSize = toString stylix.fonts.sizes.desktop;
|
||||
# The wallpaper. With no stylix.image the theme keeps its own.
|
||||
background = stylix.image;
|
||||
# A solid panel (the palette's mantle) behind the login form, so the
|
||||
# form stays readable whatever the wallpaper is.
|
||||
loginBackground = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = builtins.elem flavor [
|
||||
"latte"
|
||||
"frappe"
|
||||
"macchiato"
|
||||
"mocha"
|
||||
];
|
||||
message = ''
|
||||
The SDDM theme (desktop/sddm.nix) is Catppuccin and follows the
|
||||
flavour of the Stylix palette, but the palette is
|
||||
"${config.lib.stylix.colors.slug}". Use a Catppuccin scheme in
|
||||
theme/stylix.nix or pick another SDDM theme.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
services.displayManager = {
|
||||
sddm = {
|
||||
enable = true;
|
||||
wayland.enable = true;
|
||||
theme = "catppuccin-${flavor}-${accent}";
|
||||
# The theme draws its icons as SVG; the greeter needs the Qt SVG
|
||||
# plugin to load them.
|
||||
extraPackages = [ pkgs.kdePackages.qtsvg ];
|
||||
settings.Theme = {
|
||||
CursorTheme = stylix.cursor.name;
|
||||
CursorSize = stylix.cursor.size;
|
||||
};
|
||||
};
|
||||
# Preselected in the greeter (SDDM then remembers the last session
|
||||
# used). No autoLogin and no `Autologin` key in the SDDM settings: the
|
||||
# login always asks for the password.
|
||||
defaultSession = "hyprland-uwsm";
|
||||
};
|
||||
|
||||
# The greeter finds the theme in /run/current-system/sw/share/sddm/themes
|
||||
# and the cursor in the system icon path.
|
||||
environment.systemPackages = [
|
||||
catppuccin-sddm
|
||||
stylix.cursor.package
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user