Testing lib.mkForce

This commit is contained in:
2026-03-01 18:24:47 +01:00
parent db2b9e4a06
commit eb18a3628a
18 changed files with 944 additions and 1012 deletions
+534 -557
View File
File diff suppressed because it is too large Load Diff
+205 -228
View File
@@ -709,7 +709,7 @@ We also add a devshell that makes editing this repository easier in emacs.
hostname = machine; hostname = machine;
inherit user; inherit user;
inherit inputs; inherit inputs;
flakeRoot = inputs.self; flakeRoot.outPath= inputs.self;
}; };
}; };
}) machines }) machines
@@ -755,7 +755,7 @@ Lets look at the individual modules
home-manager.extraSpecialArgs = { home-manager.extraSpecialArgs = {
inherit user inputs; inherit user inputs;
flakeRoot = inputs.self; flakeRoot.outPath= inputs.self;
}; };
<<flake-home-backup>> <<flake-home-backup>>
@@ -897,7 +897,7 @@ This section describes a way of installing packages, either through nixpkgs orr
#+begin_src nix :tangle configuration/apps/install_packages.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle configuration/apps/install_packages.nix :noweb tangle :mkdirp yes
{ config, lib, pkgs, flakeRoot, inputs, ... }: { config, lib, pkgs, flakeRoot, inputs, ... }:
let let
packagesConfPath = flakeRoot + "/assets/conf/apps/packages.conf"; packagesConfPath = flakeRoot.outPath + "/assets/conf/apps/packages.conf";
raw = builtins.readFile packagesConfPath; raw = builtins.readFile packagesConfPath;
# IMPORTANT: explicit "\n" so we never accidentally split into characters # IMPORTANT: explicit "\n" so we never accidentally split into characters
rawLines = lib.splitString "\n" raw; rawLines = lib.splitString "\n" raw;
@@ -945,7 +945,7 @@ in
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
moduleName = "install-flatpaks"; moduleName = "install-flatpaks";
flatpakConfPath = flakeRoot + "/assets/conf/apps/flatpaks.conf"; flatpakConfPath = flakeRoot.outPath + "/assets/conf/apps/flatpaks.conf";
raw = builtins.readFile flatpakConfPath; raw = builtins.readFile flatpakConfPath;
# Explicit "\n" so we never accidentally split into characters # Explicit "\n" so we never accidentally split into characters
rawLines = lib.splitString "\n" raw; rawLines = lib.splitString "\n" raw;
@@ -1643,7 +1643,7 @@ This Home Manager Nix module (ai.nix) installs the Ollama package and configures
#+begin_src nix :tangle home/apps/ollama.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/apps/ollama.nix :noweb tangle :mkdirp yes
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
ollamaConfPath = flakeRoot + "/assets/conf/apps/ai/ollama/ollama.conf"; ollamaConfPath = flakeRoot.outPath + "/assets/conf/apps/ai/ollama/ollama.conf";
envVars = builtins.fromJSON (builtins.readFile ollamaConfPath); envVars = builtins.fromJSON (builtins.readFile ollamaConfPath);
in in
{ {
@@ -1725,251 +1725,228 @@ Finally, it creates a systemd user service (wpaperd.service) that automatically
#+begin_src nix :tangle home/desktop/wallpaper.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/desktop/wallpaper.nix :noweb tangle :mkdirp yes
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoWallpaperDir = flakeRoot + "/assets/conf/desktop/wallpaper"; repoWallpaperDir = flakeRoot.outPath + "/assets/conf/desktop/wallpaper";
repoWallpaperConf = flakeRoot + "/assets/conf/desktop/wallpaper/wallpaper.conf"; repoWallpaperConf = flakeRoot.outPath + "/assets/conf/desktop/wallpaper/wallpaper.conf";
userRelRoot = "nixos_conf/wallpaperstuff"; userRelRoot = "nixos_conf/wallpaperstuff";
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}"; userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
userConfPath = "${userAbsRoot}/wallpaper.conf"; userConfPath = "${userAbsRoot}/wallpaper.conf";
# Exclude wallpaper.conf so HM does NOT manage it (avoids backup collisions) # Exclude wallpaper.conf so HM does NOT manage it (avoids backup collisions)
repoWallpapersOnly = lib.cleanSourceWith { repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir; src = repoWallpaperDir;
filter = path: type: filter = path: type: (builtins.baseNameOf path) != "wallpaper.conf";
(builtins.baseNameOf path) != "wallpaper.conf";
}; };
in in
{ {
home.packages = [ pkgs.wpaperd ]; home.packages = [ pkgs.wpaperd ];
# Sync everything *except* wallpaper.conf into ~/nixos_conf/wallpaperstuff # Sync everything *except* wallpaper.conf into ~/nixos_conf/wallpaperstuff
home.file."${userRelRoot}" = { home.file."${userRelRoot}" = {
source = repoWallpapersOnly; source = repoWallpapersOnly;
recursive = true; recursive = true;
}; };
# Now safely overwrite the config every activation (no HM collision) # Now safely overwrite the config every activation (no HM collision)
home.activation.wallpaperConfForce = home.activation.wallpaperConfForce = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail
set -euo pipefail mkdir -p "${userAbsRoot}"
mkdir -p "${userAbsRoot}" install -m 0644 "${repoWallpaperConf}" "${userConfPath}"
install -m 0644 "${repoWallpaperConf}" "${userConfPath}"
''; '';
systemd.user.services.wpaperd = { systemd.user.services.wpaperd = {
Unit = { Unit = {
Description = "wpaperd wallpaper daemon"; Description = "wpaperd wallpaper daemon";
After = [ "default.target" ]; After = [ "default.target" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${userConfPath}";
Restart = "on-failure";
RestartSec = 1;
};
Install = {
WantedBy = [ "default.target" ];
};
}; };
Service = { }
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${userConfPath}";
Restart = "on-failure";
RestartSec = 1;
};
Install.WantedBy = [ "default.target" ];
;
#+end_src #+end_src
** Workspace Wallpaper ** Workspace Wallpaper
#+begin_src nix :tangle home/desktop/workspace_wallpaper.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/desktop/workspace_wallpaper.nix :noweb tangle :mkdirp yes
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
# Where your numbered wallpapers live (1.*, 2.*, ... 9.*)
userRelRoot = "nixos_conf/wallpaperstuff"; userRelRoot = "nixos_conf/wallpaperstuff";
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}"; userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
picturesDir = "${userAbsRoot}/pictures"; picturesDir = "${userAbsRoot}/pictures";
# (Optional) still sync your repo wallpapers/scripts into ~/nixos_conf/wallpaperstuff repoWallpaperDir = flakeRoot.outPath + "/assets/conf/desktop/wallpaper";
repoWallpaperDir = flakeRoot + "/assets/conf/desktop/wallpaper";
repoWallpapersOnly = lib.cleanSourceWith { repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir; src = repoWallpaperDir;
filter = path: type: true; filter = path: type: true;
}; };
daemonRel = "hypr/scripts/hyprpaper-ws-daemon.sh"; daemonRel = ".config/hypr/scripts/hyprpaper-ws-daemon.sh";
setRel = "hypr/scripts/set-wallpaper.sh"; setRel = ".config/hypr/scripts/set-wallpaper.sh";
in in
{ {
home.packages = [ home.packages = [
pkgs.hyprpaper pkgs.hyprpaper
pkgs.socat pkgs.socat
pkgs.jq pkgs.jq
pkgs.findutils pkgs.findutils
pkgs.coreutils pkgs.coreutils
pkgs.gnused pkgs.gnused
pkgs.gawk pkgs.gawk
]; ];
# Keep your existing "sync wallpapers into a writable dir" pattern # Sync wallpapers into a writable directory
home.file."${userRelRoot}" = { home.file."${userRelRoot}" = {
source = repoWallpapersOnly; source = repoWallpapersOnly;
recursive = true; recursive = true;
}; };
# Hyprpaper config (hyprpaper reads this; it does NOT need to write it) # Hyprpaper config
# `ipc = true` enables `hyprctl hyprpaper ...` commands. :contentReference[oaicite:0]{index=0} home.file.".config/hypr/hyprpaper.conf" = {
xdg.configFile."hypr/hyprpaper.conf".text = lib.mkForce '' text = ''
ipc = true ipc = true
splash = false splash = false
''; '';
# Workspace wallpaper daemon: listens to socket2, applies w-<id>=... mapping
# Uses workspacev2 to get numeric workspace id. :contentReference[oaicite:1]{index=1}
xdg.configFile."${daemonRel}" = {
executable = true;
text = lib.mkForce ''
#!/usr/bin/env bash
set -euo pipefail
: "''${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR not set}"
: "''${HYPRLAND_INSTANCE_SIGNATURE:?HYPRLAND_INSTANCE_SIGNATURE not set}"
SOCK="''${XDG_RUNTIME_DIR}/hypr/''${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
[[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
PICTURES_DIR="''${1:-${picturesDir}}"
FIT_MODE="fill" # hyprpaper fit_mode: contain|cover|tile|fill :contentReference[oaicite:2]{index=2}
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config"
focused_monitor() {
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
}
map_file_for_monitor() {
local mon="''${1}"
echo "''${MAP_ROOT}/''${mon}/defaults.conf"
}
ensure_map_file() {
local mon="''${1}"
local f
f="$(map_file_for_monitor "''${mon}")"
mkdir -p "$(dirname "''${f}")"
if [[ ! -f "''${f}" ]]; then
# Seed with 1..9 from picturesDir if present, else empty entries
{
for i in 1 2 3 4 5 6 7 8 9; do
seed="$(ls -1 "''${PICTURES_DIR}/''${i}."* 2>/dev/null | head -n 1 || true)"
echo "w-''${i}= ''${seed}"
done
} > "''${f}"
fi
echo "''${f}"
}
get_wall_for_ws() {
local mon="''${1}"
local wsid="''${2}"
local f key val
f="$(ensure_map_file "''${mon}")"
key="w-''${wsid}"
# accept "w-1=/path" or "w-1= /path"
val="$(awk -F= -v k="''${key}" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "''${f}" || true)"
echo "''${val}"
}
apply_wallpaper() {
local mon="''${1}"
local wsid="''${2}"
local file
file="$(get_wall_for_ws "''${mon}" "''${wsid}")"
[[ -n "''${file}" ]] || return 0
[[ -f "''${file}" ]] || return 0
# Apply via IPC
# hyprpaper wallpaper { monitor path fit_mode } model is per monitor. :contentReference[oaicite:3]{index=3}
hyprctl hyprpaper wallpaper "''${mon}, ''${file}, ''${FIT_MODE}" >/dev/null
}
# Initial apply on startup
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
handle() {
local line="''${1}"
case "''${line}" in
workspacev2* )
# workspacev2>>ID,NAME :contentReference[oaicite:4]{index=4}
local payload wsid
payload="''${line#*>>}"
wsid="''${payload%%,*}"
mon="$(focused_monitor || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
focusedmon* )
# focusedmon>>MON,WORKSPACENAME :contentReference[oaicite:5]{index=5}
# When monitor focus changes, re-apply for the active workspace id.
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
esac
}
socat -U - UNIX-CONNECT:"''${SOCK}" | while read -r line; do
handle "''${line}" || true
done
'';
}; };
# Workspace wallpaper daemon
# CLI setter in the style of your inspiration script. home.file."${daemonRel}" = {
# Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper] executable = true;
xdg.configFile."${setRel}" = { text = ''
executable = true; #!/usr/bin/env bash
text = lib.mkForce '' set -euo pipefail
#!/usr/bin/env bash : "${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR not set}"
set -euo pipefail : "${HYPRLAND_INSTANCE_SIGNATURE:?HYPRLAND_INSTANCE_SIGNATURE not set}"
SOCK="${XDG_RUNTIME_DIR}/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr" [[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config" PICTURES_DIR="${1:-${picturesDir}}"
FIT_MODE="fill" # hyprpaper fit_mode: contain|cover|tile|fill
usage() { HYPR_DIR="${config.xdg.configHome}/hypr"
echo "Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper_path]" MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
} focused_monitor() {
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
wsid="''${1:-}" }
mon="''${2:-}" map_file_for_monitor() {
wp="''${3:-}" local mon="$1"
echo "${MAP_ROOT}/${mon}/defaults.conf"
[[ -n "''${wsid}" ]] || { usage; exit 1; } }
[[ -n "''${mon}" ]] || { usage; exit 1; } ensure_map_file() {
local mon="$1"
cfg="''${MAP_ROOT}/''${mon}/defaults.conf" local f
mkdir -p "$(dirname "''${cfg}")" f="$(map_file_for_monitor "$mon")"
[[ -f "''${cfg}" ]] || touch "''${cfg}" mkdir -p "$(dirname "$f")"
if [[ ! -f "$f" ]]; then
if [[ -z "''${wp}" ]]; then # Seed with 1..9 from picturesDir if present, else empty entries
# Random pick from your defaults folder if you want; adjust path if needed: {
wp="$(find "$HOME/.config/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)" for i in 1 2 3 4 5 6 7 8 9; do
[[ -n "''${wp}" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; } seed="$(ls -1 "${PICTURES_DIR}/${i}."* 2>/dev/null | head -n 1 || true)"
fi echo "w-${i}=${seed}"
done
# Ensure key exists; if not, append it } > "$f"
key="w-''${wsid}" fi
if ! grep -q "^''${key}=" "''${cfg}"; then echo "$f"
echo "''${key}=" >> "''${cfg}" }
fi get_wall_for_ws() {
local mon="$1"
# Set mapping local wsid="$2"
${pkgs.gnused}/bin/sed -i "s|^''${key}=.*|''${key}= ''${wp}|g" "''${cfg}" local f key val
f="$(ensure_map_file "$mon")"
# If this monitor is currently showing that workspace id, apply immediately key="w-${wsid}"
curws="$(hyprctl -j monitors | jq -r --arg m "''${mon}" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)" val="$(awk -F= -v k="$key" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "$f" || true)"
if [[ "''${curws}" == "''${wsid}" ]]; then echo "$val"
hyprctl hyprpaper wallpaper "''${mon}, ''${wp}, fill" >/dev/null }
fi apply_wallpaper() {
''; local mon="$1"
local wsid="$2"
local file
file="$(get_wall_for_ws "$mon" "$wsid")"
[[ -n "$file" ]] || return 0
[[ -f "$file" ]] || return 0
hyprctl hyprpaper wallpaper "$mon, $file, $FIT_MODE" >/dev/null
}
# Initial apply on startup
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
handle() {
local line="$1"
case "$line" in
workspacev2* )
# workspacev2>>ID,NAME
local payload wsid
payload="${line#*>>}"
wsid="${payload%%,*}"
mon="$(focused_monitor || true)"
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
;;
focusedmon* )
# focusedmon>>MON,WORKSPACENAME
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
;;
esac
}
socat -U - UNIX-CONNECT:"$SOCK" | while read -r line; do
handle "$line" || true
done
'';
};
# CLI setter
home.file."${setRel}" = {
executable = true;
text = ''
#!/usr/bin/env bash
set -euo pipefail
HYPR_DIR="${config.xdg.configHome}/hypr"
MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
usage() {
echo "Usage: $0 <workspace_id> <monitor> [wallpaper_path]"
}
wsid="${1:-}"
mon="${2:-}"
wp="${3:-}"
[[ -n "$wsid" ]] || { usage; exit 1; }
[[ -n "$mon" ]] || { usage; exit 1; }
cfg="${MAP_ROOT}/${mon}/defaults.conf"
mkdir -p "$(dirname "$cfg")"
[[ -f "$cfg" ]] || touch "$cfg"
if [[ -z "$wp" ]]; then
wp="$(find "${config.home.homeDirectory}/.config/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)"
[[ -n "$wp" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; }
fi
key="w-${wsid}"
if ! grep -q "^${key}=" "$cfg"; then
echo "${key}=" >> "$cfg"
fi
${pkgs.gnused}/bin/sed -i "s|^${key}=.*|${key}= ${wp}|g" "$cfg"
curws="$(hyprctl -j monitors | jq -r --arg m "$mon" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)"
if [[ "$curws" == "$wsid" ]]; then
hyprctl hyprpaper wallpaper "$mon, $wp, fill" >/dev/null
fi
'';
}; };
# Services # Services
systemd.user.services.hyprpaper = { systemd.user.services.hyprpaper = {
Unit = { Unit = {
Description = "hyprpaper wallpaper daemon"; Description = "hyprpaper wallpaper daemon";
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ]; After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
Service = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
systemd.user.services.hyprpaper-ws-daemon = { systemd.user.services.hyprpaper-ws-daemon = {
Unit = { Unit = {
Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)"; Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)";
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" "hyprpaper.service" ]; After = [ "graphical-session.target" "hyprpaper.service" ];
}; };
Service = { Service = {
ExecStart = "${pkgs.bash}/bin/bash ${config.xdg.configHome}/${daemonRel} ${picturesDir}"; ExecStart = "${pkgs.bash}/bin/bash ${daemonRel} ${picturesDir}";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 1; RestartSec = 1;
}; };
Install = { WantedBy = [ "graphical-session.target" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
} }
#+end_src #+end_src
@@ -2003,8 +1980,8 @@ They are configured below.
#+begin_src nix :tangle home/desktop/hyprlock.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/desktop/hyprlock.nix :noweb tangle :mkdirp yes
{config, lib, pkgs, flakeRoot, ... }: {config, lib, pkgs, flakeRoot, ... }:
let let
lockPngSrc = flakeRoot + "/assets/lock.png"; lockPngSrc = flakeRoot.outPath + "/assets/lock.png";
hyprlockConf = flakeRoot + "/assets/conf/desktop/hypr/hyprlock.conf"; hyprlockConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprlock.conf";
in in
{ {
home.packages = [ pkgs.hyprlock ]; home.packages = [ pkgs.hyprlock ];
@@ -2018,7 +1995,7 @@ in
#+begin_src nix :tangle home/desktop/hypridle.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/desktop/hypridle.nix :noweb tangle :mkdirp yes
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
hypridleConf = flakeRoot + "/assets/conf/desktop/hypr/hypridle.conf"; hypridleConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hypridle.conf";
in in
{ {
home.packages = [ pkgs.hypridle ]; home.packages = [ pkgs.hypridle ];
@@ -2032,17 +2009,17 @@ This Nix module integrates the hyprscrolling plugin into a Home-Manager managed
{ config, lib, pkgs, flakeRoot,...}: { config, lib, pkgs, flakeRoot,...}:
let let
# Hyprscrolling drop-in config (repo -> ~/.config) # Hyprscrolling drop-in config (repo -> ~/.config)
repoConf = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf"; repoConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprscrolling.conf";
targetRel = "hypr/conf.d/90-hyprscrolling.conf"; targetRel = "hypr/conf.d/90-hyprscrolling.conf";
# Overflow indicator script (repo -> ~/.config) # Overflow indicator script (repo -> ~/.config)
repoOverflowScript = flakeRoot + "/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh"; repoOverflowScript = flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh";
targetOverflowRel = "hypr/scripts/hyprscroll-overflow.sh"; targetOverflowRel = "hypr/scripts/hyprscroll-overflow.sh";
# Adapt columnsize to monitor # Adapt columnsize to monitor
repoPerMonitorScript = flakeRoot + "/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh"; repoPerMonitorScript = flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh";
targetPerMonitor = "hypr/scripts/hyprscrolling-per-monitor.sh"; targetPerMonitor = "hypr/scripts/hyprscrolling-per-monitor.sh";
# Facilitate switching between scrolling and dwindle # Facilitate switching between scrolling and dwindle
repoSwitchScript = repoSwitchScript =
flakeRoot + "/assets/conf/desktop/hypr/scripts/toggle-layout-scrolling-dwindle.sh"; flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/toggle-layout-scrolling-dwindle.sh";
targetSwitchScript = "hypr/scripts/toggle-layout-scrolling-dwindle.sh"; targetSwitchScript = "hypr/scripts/toggle-layout-scrolling-dwindle.sh";
in in
{ {
@@ -2085,7 +2062,7 @@ For nice task-starting and -switching
# home/desktop/hyprshell.nix (Home-Manager module) # home/desktop/hyprshell.nix (Home-Manager module)
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoDir = flakeRoot + "/assets/conf/desktop/hypr/hyprshell"; repoDir = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprshell";
cfgRon = repoDir + "/config.ron"; cfgRon = repoDir + "/config.ron";
cssFile = repoDir + "/styles.css"; cssFile = repoDir + "/styles.css";
in in
@@ -2120,8 +2097,8 @@ This configures the desktop environment along with the peripherals. The comments
#+begin_src nix :tangle home/desktop/hyprland.nix :noweb tangle :mkdirp yes. #+begin_src nix :tangle home/desktop/hyprland.nix :noweb tangle :mkdirp yes.
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
hyprConf = flakeRoot + "/assets/conf/desktop/hypr/hyprland.conf"; hyprConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprland.conf";
bindingsConf = flakeRoot + "/assets/conf/desktop/hypr/bindings.conf"; bindingsConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/bindings.conf";
in in
{ {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
@@ -2139,7 +2116,7 @@ in
}; };
}; };
xdg.configFile."hypr/scripts/lid-lock.sh" = { xdg.configFile."hypr/scripts/lid-lock.sh" = {
source = lib.mkForce (flakeRoot + "/assets/conf/desktop/hypr/scripts/lid-lock.sh"); source = lib.mkForce (flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/lid-lock.sh");
executable = true; executable = true;
}; };
xdg.portal = { xdg.portal = {
@@ -2174,7 +2151,7 @@ let
else pkgs.elephant; else pkgs.elephant;
sessionTarget = "graphical-session.target"; sessionTarget = "graphical-session.target";
# All theme files now live here # All theme files now live here
repoThemesDir = flakeRoot + "/assets/conf/desktop/walker"; repoThemesDir = flakeRoot.outPath + "/assets/conf/desktop/walker";
in in
{ {
xdg.enable = true; xdg.enable = true;
@@ -2271,7 +2248,7 @@ Alacritty gets installed and configured
#+begin_src nix :tangle home/dev/alacritty.nix :noweb tangle :mkdirp yes. #+begin_src nix :tangle home/dev/alacritty.nix :noweb tangle :mkdirp yes.
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoAlacrittyConf = flakeRoot + "/assets/conf/dev/alacritty.toml"; repoAlacrittyConf = flakeRoot.outPath + "/assets/conf/dev/alacritty.toml";
in in
{ {
xdg.enable = true; xdg.enable = true;
@@ -2336,10 +2313,10 @@ Kitty gets installed and configured
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
catppuccinMochaConf = catppuccinMochaConf =
builtins.readFile (flakeRoot + "/assets/conf/dev/terminal/Catppuccin-Mocha.conf"); builtins.readFile (flakeRoot.outPath + "/assets/conf/dev/terminal/Catppuccin-Mocha.conf");
# Your own keymaps / other settings (but we will NOT rely on it for opacity) # Your own keymaps / other settings (but we will NOT rely on it for opacity)
repoKittyConfText = repoKittyConfText =
builtins.readFile (flakeRoot + "/assets/conf/dev/terminal/kitty.conf"); builtins.readFile (flakeRoot.outPath + "/assets/conf/dev/terminal/kitty.conf");
in in
{ {
xdg.enable = true; xdg.enable = true;
@@ -2384,7 +2361,7 @@ The aliases mentioned in ./assets/conf/dev/terminal/shells.conf will be added to
# - Instead, we create/remove files via home.activation (create only if missing). # - Instead, we create/remove files via home.activation (create only if missing).
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
terminalDir = flakeRoot + "/assets/conf/dev/terminal"; terminalDir = flakeRoot.outPath + "/assets/conf/dev/terminal";
enabledFile = terminalDir + "/enabled_shells.conf"; enabledFile = terminalDir + "/enabled_shells.conf";
aliasesFile = terminalDir + "/aliases.conf"; aliasesFile = terminalDir + "/aliases.conf";
trim = lib.strings.trim; trim = lib.strings.trim;
@@ -2612,7 +2589,7 @@ The configuration mentioned in ./assets/conf/dev/terminal/starship.toml will be
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoStarshipToml = flakeRoot + "/assets/conf/dev/terminal/starship.toml"; repoStarshipToml = flakeRoot.outPath + "/assets/conf/dev/terminal/starship.toml";
# The exact key that appears in the error: # The exact key that appears in the error:
targetKey = "${config.home.homeDirectory}/.config/starship.toml"; targetKey = "${config.home.homeDirectory}/.config/starship.toml";
@@ -1,7 +1,7 @@
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
moduleName = "install-flatpaks"; moduleName = "install-flatpaks";
flatpakConfPath = flakeRoot + "/assets/conf/apps/flatpaks.conf"; flatpakConfPath = flakeRoot.outPath + "/assets/conf/apps/flatpaks.conf";
raw = builtins.readFile flatpakConfPath; raw = builtins.readFile flatpakConfPath;
# Explicit "\n" so we never accidentally split into characters # Explicit "\n" so we never accidentally split into characters
rawLines = lib.splitString "\n" raw; rawLines = lib.splitString "\n" raw;
@@ -1,6 +1,6 @@
{ config, lib, pkgs, flakeRoot, inputs, ... }: { config, lib, pkgs, flakeRoot, inputs, ... }:
let let
packagesConfPath = flakeRoot + "/assets/conf/apps/packages.conf"; packagesConfPath = flakeRoot.outPath + "/assets/conf/apps/packages.conf";
raw = builtins.readFile packagesConfPath; raw = builtins.readFile packagesConfPath;
# IMPORTANT: explicit "\n" so we never accidentally split into characters # IMPORTANT: explicit "\n" so we never accidentally split into characters
rawLines = lib.splitString "\n" raw; rawLines = lib.splitString "\n" raw;
+2 -2
View File
@@ -53,7 +53,7 @@ in
home-manager.extraSpecialArgs = { home-manager.extraSpecialArgs = {
inherit user inputs; inherit user inputs;
flakeRoot = inputs.self; flakeRoot.outPath= inputs.self;
}; };
home-manager.backupFileExtension = "backup"; home-manager.backupFileExtension = "backup";
@@ -72,7 +72,7 @@ in
hostname = machine; hostname = machine;
inherit user; inherit user;
inherit inputs; inherit inputs;
flakeRoot = inputs.self; flakeRoot.outPath= inputs.self;
}; };
}; };
}) machines }) machines
+1 -1
View File
@@ -1,6 +1,6 @@
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
ollamaConfPath = flakeRoot + "/assets/conf/apps/ai/ollama/ollama.conf"; ollamaConfPath = flakeRoot.outPath + "/assets/conf/apps/ai/ollama/ollama.conf";
envVars = builtins.fromJSON (builtins.readFile ollamaConfPath); envVars = builtins.fromJSON (builtins.readFile ollamaConfPath);
in in
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
hypridleConf = flakeRoot + "/assets/conf/desktop/hypr/hypridle.conf"; hypridleConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hypridle.conf";
in in
{ {
home.packages = [ pkgs.hypridle ]; home.packages = [ pkgs.hypridle ];
+3 -3
View File
@@ -1,7 +1,7 @@
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
hyprConf = flakeRoot + "/assets/conf/desktop/hypr/hyprland.conf"; hyprConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprland.conf";
bindingsConf = flakeRoot + "/assets/conf/desktop/hypr/bindings.conf"; bindingsConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/bindings.conf";
in in
{ {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
@@ -19,7 +19,7 @@ in
}; };
}; };
xdg.configFile."hypr/scripts/lid-lock.sh" = { xdg.configFile."hypr/scripts/lid-lock.sh" = {
source = lib.mkForce (flakeRoot + "/assets/conf/desktop/hypr/scripts/lid-lock.sh"); source = lib.mkForce (flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/lid-lock.sh");
executable = true; executable = true;
}; };
xdg.portal = { xdg.portal = {
+2 -2
View File
@@ -1,7 +1,7 @@
{config, lib, pkgs, flakeRoot, ... }: {config, lib, pkgs, flakeRoot, ... }:
let let
lockPngSrc = flakeRoot + "/assets/lock.png"; lockPngSrc = flakeRoot.outPath + "/assets/lock.png";
hyprlockConf = flakeRoot + "/assets/conf/desktop/hypr/hyprlock.conf"; hyprlockConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprlock.conf";
in in
{ {
home.packages = [ pkgs.hyprlock ]; home.packages = [ pkgs.hyprlock ];
+4 -4
View File
@@ -1,17 +1,17 @@
{ config, lib, pkgs, flakeRoot,...}: { config, lib, pkgs, flakeRoot,...}:
let let
# Hyprscrolling drop-in config (repo -> ~/.config) # Hyprscrolling drop-in config (repo -> ~/.config)
repoConf = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf"; repoConf = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprscrolling.conf";
targetRel = "hypr/conf.d/90-hyprscrolling.conf"; targetRel = "hypr/conf.d/90-hyprscrolling.conf";
# Overflow indicator script (repo -> ~/.config) # Overflow indicator script (repo -> ~/.config)
repoOverflowScript = flakeRoot + "/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh"; repoOverflowScript = flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh";
targetOverflowRel = "hypr/scripts/hyprscroll-overflow.sh"; targetOverflowRel = "hypr/scripts/hyprscroll-overflow.sh";
# Adapt columnsize to monitor # Adapt columnsize to monitor
repoPerMonitorScript = flakeRoot + "/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh"; repoPerMonitorScript = flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/hyprscrolling-per-monitor.sh";
targetPerMonitor = "hypr/scripts/hyprscrolling-per-monitor.sh"; targetPerMonitor = "hypr/scripts/hyprscrolling-per-monitor.sh";
# Facilitate switching between scrolling and dwindle # Facilitate switching between scrolling and dwindle
repoSwitchScript = repoSwitchScript =
flakeRoot + "/assets/conf/desktop/hypr/scripts/toggle-layout-scrolling-dwindle.sh"; flakeRoot.outPath + "/assets/conf/desktop/hypr/scripts/toggle-layout-scrolling-dwindle.sh";
targetSwitchScript = "hypr/scripts/toggle-layout-scrolling-dwindle.sh"; targetSwitchScript = "hypr/scripts/toggle-layout-scrolling-dwindle.sh";
in in
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
# home/desktop/hyprshell.nix (Home-Manager module) # home/desktop/hyprshell.nix (Home-Manager module)
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoDir = flakeRoot + "/assets/conf/desktop/hypr/hyprshell"; repoDir = flakeRoot.outPath + "/assets/conf/desktop/hypr/hyprshell";
cfgRon = repoDir + "/config.ron"; cfgRon = repoDir + "/config.ron";
cssFile = repoDir + "/styles.css"; cssFile = repoDir + "/styles.css";
in in
@@ -1,42 +1,43 @@
#+begin_src nix :tangle home/desktop/wallpaper.nix :noweb tangle :mkdirp yes #+begin_src nix :tangle home/desktop/wallpaper.nix :noweb tangle :mkdirp yes
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoWallpaperDir = flakeRoot + "/assets/conf/desktop/wallpaper"; repoWallpaperDir = flakeRoot.outPath + "/assets/conf/desktop/wallpaper";
repoWallpaperConf = flakeRoot + "/assets/conf/desktop/wallpaper/wallpaper.conf"; repoWallpaperConf = flakeRoot.outPath + "/assets/conf/desktop/wallpaper/wallpaper.conf";
userRelRoot = "nixos_conf/wallpaperstuff"; userRelRoot = "nixos_conf/wallpaperstuff";
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}"; userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
userConfPath = "${userAbsRoot}/wallpaper.conf"; userConfPath = "${userAbsRoot}/wallpaper.conf";
# Exclude wallpaper.conf so HM does NOT manage it (avoids backup collisions) # Exclude wallpaper.conf so HM does NOT manage it (avoids backup collisions)
repoWallpapersOnly = lib.cleanSourceWith { repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir; src = repoWallpaperDir;
filter = path: type: filter = path: type: (builtins.baseNameOf path) != "wallpaper.conf";
(builtins.baseNameOf path) != "wallpaper.conf";
}; };
in in
{ {
home.packages = [ pkgs.wpaperd ]; home.packages = [ pkgs.wpaperd ];
# Sync everything *except* wallpaper.conf into ~/nixos_conf/wallpaperstuff # Sync everything *except* wallpaper.conf into ~/nixos_conf/wallpaperstuff
home.file."${userRelRoot}" = { home.file."${userRelRoot}" = {
source = repoWallpapersOnly; source = repoWallpapersOnly;
recursive = true; recursive = true;
}; };
# Now safely overwrite the config every activation (no HM collision) # Now safely overwrite the config every activation (no HM collision)
home.activation.wallpaperConfForce = home.activation.wallpaperConfForce = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail
set -euo pipefail mkdir -p "${userAbsRoot}"
mkdir -p "${userAbsRoot}" install -m 0644 "${repoWallpaperConf}" "${userConfPath}"
install -m 0644 "${repoWallpaperConf}" "${userConfPath}"
''; '';
systemd.user.services.wpaperd = { systemd.user.services.wpaperd = {
Unit = { Unit = {
Description = "wpaperd wallpaper daemon"; Description = "wpaperd wallpaper daemon";
After = [ "default.target" ]; After = [ "default.target" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${userConfPath}";
Restart = "on-failure";
RestartSec = 1;
};
Install = {
WantedBy = [ "default.target" ];
};
}; };
Service = { }
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${userConfPath}";
Restart = "on-failure";
RestartSec = 1;
};
Install.WantedBy = [ "default.target" ];
;
+1 -1
View File
@@ -10,7 +10,7 @@ let
else pkgs.elephant; else pkgs.elephant;
sessionTarget = "graphical-session.target"; sessionTarget = "graphical-session.target";
# All theme files now live here # All theme files now live here
repoThemesDir = flakeRoot + "/assets/conf/desktop/walker"; repoThemesDir = flakeRoot.outPath + "/assets/conf/desktop/walker";
in in
{ {
xdg.enable = true; xdg.enable = true;
+159 -182
View File
@@ -1,203 +1,180 @@
{ config, lib, pkgs, flakeRoot, ... }: { config, lib, pkgs, flakeRoot, ... }:
let let
# Where your numbered wallpapers live (1.*, 2.*, ... 9.*)
userRelRoot = "nixos_conf/wallpaperstuff"; userRelRoot = "nixos_conf/wallpaperstuff";
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}"; userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
picturesDir = "${userAbsRoot}/pictures"; picturesDir = "${userAbsRoot}/pictures";
# (Optional) still sync your repo wallpapers/scripts into ~/nixos_conf/wallpaperstuff repoWallpaperDir = flakeRoot.outPath + "/assets/conf/desktop/wallpaper";
repoWallpaperDir = flakeRoot + "/assets/conf/desktop/wallpaper";
repoWallpapersOnly = lib.cleanSourceWith { repoWallpapersOnly = lib.cleanSourceWith {
src = repoWallpaperDir; src = repoWallpaperDir;
filter = path: type: true; filter = path: type: true;
}; };
daemonRel = "hypr/scripts/hyprpaper-ws-daemon.sh"; daemonRel = ".config/hypr/scripts/hyprpaper-ws-daemon.sh";
setRel = "hypr/scripts/set-wallpaper.sh"; setRel = ".config/hypr/scripts/set-wallpaper.sh";
in in
{ {
home.packages = [ home.packages = [
pkgs.hyprpaper pkgs.hyprpaper
pkgs.socat pkgs.socat
pkgs.jq pkgs.jq
pkgs.findutils pkgs.findutils
pkgs.coreutils pkgs.coreutils
pkgs.gnused pkgs.gnused
pkgs.gawk pkgs.gawk
]; ];
# Keep your existing "sync wallpapers into a writable dir" pattern # Sync wallpapers into a writable directory
home.file."${userRelRoot}" = { home.file."${userRelRoot}" = {
source = repoWallpapersOnly; source = repoWallpapersOnly;
recursive = true; recursive = true;
}; };
# Hyprpaper config (hyprpaper reads this; it does NOT need to write it) # Hyprpaper config
# `ipc = true` enables `hyprctl hyprpaper ...` commands. :contentReference[oaicite:0]{index=0} home.file.".config/hypr/hyprpaper.conf" = {
xdg.configFile."hypr/hyprpaper.conf".text = lib.mkForce '' text = ''
ipc = true ipc = true
splash = false splash = false
''; '';
# Workspace wallpaper daemon: listens to socket2, applies w-<id>=... mapping
# Uses workspacev2 to get numeric workspace id. :contentReference[oaicite:1]{index=1}
xdg.configFile."${daemonRel}" = {
executable = true;
text = lib.mkForce ''
#!/usr/bin/env bash
set -euo pipefail
: "''${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR not set}"
: "''${HYPRLAND_INSTANCE_SIGNATURE:?HYPRLAND_INSTANCE_SIGNATURE not set}"
SOCK="''${XDG_RUNTIME_DIR}/hypr/''${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
[[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
PICTURES_DIR="''${1:-${picturesDir}}"
FIT_MODE="fill" # hyprpaper fit_mode: contain|cover|tile|fill :contentReference[oaicite:2]{index=2}
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config"
focused_monitor() {
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
}
map_file_for_monitor() {
local mon="''${1}"
echo "''${MAP_ROOT}/''${mon}/defaults.conf"
}
ensure_map_file() {
local mon="''${1}"
local f
f="$(map_file_for_monitor "''${mon}")"
mkdir -p "$(dirname "''${f}")"
if [[ ! -f "''${f}" ]]; then
# Seed with 1..9 from picturesDir if present, else empty entries
{
for i in 1 2 3 4 5 6 7 8 9; do
seed="$(ls -1 "''${PICTURES_DIR}/''${i}."* 2>/dev/null | head -n 1 || true)"
echo "w-''${i}= ''${seed}"
done
} > "''${f}"
fi
echo "''${f}"
}
get_wall_for_ws() {
local mon="''${1}"
local wsid="''${2}"
local f key val
f="$(ensure_map_file "''${mon}")"
key="w-''${wsid}"
# accept "w-1=/path" or "w-1= /path"
val="$(awk -F= -v k="''${key}" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "''${f}" || true)"
echo "''${val}"
}
apply_wallpaper() {
local mon="''${1}"
local wsid="''${2}"
local file
file="$(get_wall_for_ws "''${mon}" "''${wsid}")"
[[ -n "''${file}" ]] || return 0
[[ -f "''${file}" ]] || return 0
# Apply via IPC
# hyprpaper wallpaper { monitor path fit_mode } model is per monitor. :contentReference[oaicite:3]{index=3}
hyprctl hyprpaper wallpaper "''${mon}, ''${file}, ''${FIT_MODE}" >/dev/null
}
# Initial apply on startup
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
handle() {
local line="''${1}"
case "''${line}" in
workspacev2* )
# workspacev2>>ID,NAME :contentReference[oaicite:4]{index=4}
local payload wsid
payload="''${line#*>>}"
wsid="''${payload%%,*}"
mon="$(focused_monitor || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
focusedmon* )
# focusedmon>>MON,WORKSPACENAME :contentReference[oaicite:5]{index=5}
# When monitor focus changes, re-apply for the active workspace id.
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "''${mon}" && -n "''${wsid}" ]] && apply_wallpaper "''${mon}" "''${wsid}"
;;
esac
}
socat -U - UNIX-CONNECT:"''${SOCK}" | while read -r line; do
handle "''${line}" || true
done
'';
}; };
# Workspace wallpaper daemon
# CLI setter in the style of your inspiration script. home.file."${daemonRel}" = {
# Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper] executable = true;
xdg.configFile."${setRel}" = { text = ''
executable = true; #!/usr/bin/env bash
text = lib.mkForce '' set -euo pipefail
#!/usr/bin/env bash : "${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR not set}"
set -euo pipefail : "${HYPRLAND_INSTANCE_SIGNATURE:?HYPRLAND_INSTANCE_SIGNATURE not set}"
SOCK="${XDG_RUNTIME_DIR}/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock"
HYPR_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/hypr" [[ -S "$SOCK" ]] || { echo "Hyprland socket not found: $SOCK" >&2; exit 1; }
MAP_ROOT="''${HYPR_DIR}/hyprpaper/config" PICTURES_DIR="${1:-${picturesDir}}"
FIT_MODE="fill" # hyprpaper fit_mode: contain|cover|tile|fill
usage() { HYPR_DIR="${config.xdg.configHome}/hypr"
echo "Usage: set-wallpaper.sh <workspace_id> <monitor> [wallpaper_path]" MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
} focused_monitor() {
hyprctl -j monitors | jq -r '.[] | select(.focused==true) | .name' | head -n 1
wsid="''${1:-}" }
mon="''${2:-}" map_file_for_monitor() {
wp="''${3:-}" local mon="$1"
echo "${MAP_ROOT}/${mon}/defaults.conf"
[[ -n "''${wsid}" ]] || { usage; exit 1; } }
[[ -n "''${mon}" ]] || { usage; exit 1; } ensure_map_file() {
local mon="$1"
cfg="''${MAP_ROOT}/''${mon}/defaults.conf" local f
mkdir -p "$(dirname "''${cfg}")" f="$(map_file_for_monitor "$mon")"
[[ -f "''${cfg}" ]] || touch "''${cfg}" mkdir -p "$(dirname "$f")"
if [[ ! -f "$f" ]]; then
if [[ -z "''${wp}" ]]; then # Seed with 1..9 from picturesDir if present, else empty entries
# Random pick from your defaults folder if you want; adjust path if needed: {
wp="$(find "$HOME/.config/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)" for i in 1 2 3 4 5 6 7 8 9; do
[[ -n "''${wp}" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; } seed="$(ls -1 "${PICTURES_DIR}/${i}."* 2>/dev/null | head -n 1 || true)"
fi echo "w-${i}=${seed}"
done
# Ensure key exists; if not, append it } > "$f"
key="w-''${wsid}" fi
if ! grep -q "^''${key}=" "''${cfg}"; then echo "$f"
echo "''${key}=" >> "''${cfg}" }
fi get_wall_for_ws() {
local mon="$1"
# Set mapping local wsid="$2"
${pkgs.gnused}/bin/sed -i "s|^''${key}=.*|''${key}= ''${wp}|g" "''${cfg}" local f key val
f="$(ensure_map_file "$mon")"
# If this monitor is currently showing that workspace id, apply immediately key="w-${wsid}"
curws="$(hyprctl -j monitors | jq -r --arg m "''${mon}" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)" val="$(awk -F= -v k="$key" '$1==k {sub(/^[[:space:]]+/, "", $2); print $2; exit}' "$f" || true)"
if [[ "''${curws}" == "''${wsid}" ]]; then echo "$val"
hyprctl hyprpaper wallpaper "''${mon}, ''${wp}, fill" >/dev/null }
fi apply_wallpaper() {
''; local mon="$1"
local wsid="$2"
local file
file="$(get_wall_for_ws "$mon" "$wsid")"
[[ -n "$file" ]] || return 0
[[ -f "$file" ]] || return 0
hyprctl hyprpaper wallpaper "$mon, $file, $FIT_MODE" >/dev/null
}
# Initial apply on startup
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
handle() {
local line="$1"
case "$line" in
workspacev2* )
# workspacev2>>ID,NAME
local payload wsid
payload="${line#*>>}"
wsid="${payload%%,*}"
mon="$(focused_monitor || true)"
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
;;
focusedmon* )
# focusedmon>>MON,WORKSPACENAME
mon="$(focused_monitor || true)"
wsid="$(hyprctl -j activeworkspace | jq -r '.id' | head -n 1 || true)"
[[ -n "$mon" && -n "$wsid" ]] && apply_wallpaper "$mon" "$wsid"
;;
esac
}
socat -U - UNIX-CONNECT:"$SOCK" | while read -r line; do
handle "$line" || true
done
'';
};
# CLI setter
home.file."${setRel}" = {
executable = true;
text = ''
#!/usr/bin/env bash
set -euo pipefail
HYPR_DIR="${config.xdg.configHome}/hypr"
MAP_ROOT="${HYPR_DIR}/hyprpaper/config"
usage() {
echo "Usage: $0 <workspace_id> <monitor> [wallpaper_path]"
}
wsid="${1:-}"
mon="${2:-}"
wp="${3:-}"
[[ -n "$wsid" ]] || { usage; exit 1; }
[[ -n "$mon" ]] || { usage; exit 1; }
cfg="${MAP_ROOT}/${mon}/defaults.conf"
mkdir -p "$(dirname "$cfg")"
[[ -f "$cfg" ]] || touch "$cfg"
if [[ -z "$wp" ]]; then
wp="$(find "${config.home.homeDirectory}/.config/wallpapers/defaults" -type f 2>/dev/null | shuf -n 1 || true)"
[[ -n "$wp" ]] || { echo "No wallpaper found (random). Provide a path as arg 3."; exit 1; }
fi
key="w-${wsid}"
if ! grep -q "^${key}=" "$cfg"; then
echo "${key}=" >> "$cfg"
fi
${pkgs.gnused}/bin/sed -i "s|^${key}=.*|${key}= ${wp}|g" "$cfg"
curws="$(hyprctl -j monitors | jq -r --arg m "$mon" '.[] | select(.name==$m) | .activeWorkspace.id' | head -n 1 || true)"
if [[ "$curws" == "$wsid" ]]; then
hyprctl hyprpaper wallpaper "$mon, $wp, fill" >/dev/null
fi
'';
}; };
# Services # Services
systemd.user.services.hyprpaper = { systemd.user.services.hyprpaper = {
Unit = { Unit = {
Description = "hyprpaper wallpaper daemon"; Description = "hyprpaper wallpaper daemon";
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ]; After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
Service = {
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
Restart = "on-failure";
RestartSec = 1;
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
systemd.user.services.hyprpaper-ws-daemon = { systemd.user.services.hyprpaper-ws-daemon = {
Unit = { Unit = {
Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)"; Description = "Workspace->wallpaper mapping daemon (hyprpaper + socket2)";
PartOf = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" "hyprpaper.service" ]; After = [ "graphical-session.target" "hyprpaper.service" ];
}; };
Service = { Service = {
ExecStart = "${pkgs.bash}/bin/bash ${config.xdg.configHome}/${daemonRel} ${picturesDir}"; ExecStart = "${pkgs.bash}/bin/bash ${daemonRel} ${picturesDir}";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 1; RestartSec = 1;
}; };
Install = { WantedBy = [ "graphical-session.target" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoAlacrittyConf = flakeRoot + "/assets/conf/dev/alacritty.toml"; repoAlacrittyConf = flakeRoot.outPath + "/assets/conf/dev/alacritty.toml";
in in
{ {
xdg.enable = true; xdg.enable = true;
+2 -2
View File
@@ -1,10 +1,10 @@
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
catppuccinMochaConf = catppuccinMochaConf =
builtins.readFile (flakeRoot + "/assets/conf/dev/terminal/Catppuccin-Mocha.conf"); builtins.readFile (flakeRoot.outPath + "/assets/conf/dev/terminal/Catppuccin-Mocha.conf");
# Your own keymaps / other settings (but we will NOT rely on it for opacity) # Your own keymaps / other settings (but we will NOT rely on it for opacity)
repoKittyConfText = repoKittyConfText =
builtins.readFile (flakeRoot + "/assets/conf/dev/terminal/kitty.conf"); builtins.readFile (flakeRoot.outPath + "/assets/conf/dev/terminal/kitty.conf");
in in
{ {
xdg.enable = true; xdg.enable = true;
+1 -1
View File
@@ -15,7 +15,7 @@
# - Instead, we create/remove files via home.activation (create only if missing). # - Instead, we create/remove files via home.activation (create only if missing).
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
terminalDir = flakeRoot + "/assets/conf/dev/terminal"; terminalDir = flakeRoot.outPath + "/assets/conf/dev/terminal";
enabledFile = terminalDir + "/enabled_shells.conf"; enabledFile = terminalDir + "/enabled_shells.conf";
aliasesFile = terminalDir + "/aliases.conf"; aliasesFile = terminalDir + "/aliases.conf";
trim = lib.strings.trim; trim = lib.strings.trim;
+1 -1
View File
@@ -1,7 +1,7 @@
{ config, pkgs, lib, flakeRoot, ... }: { config, pkgs, lib, flakeRoot, ... }:
let let
repoStarshipToml = flakeRoot + "/assets/conf/dev/terminal/starship.toml"; repoStarshipToml = flakeRoot.outPath + "/assets/conf/dev/terminal/starship.toml";
# The exact key that appears in the error: # The exact key that appears in the error:
targetKey = "${config.home.homeDirectory}/.config/starship.toml"; targetKey = "${config.home.homeDirectory}/.config/starship.toml";