99 lines
2.9 KiB
Nix
99 lines
2.9 KiB
Nix
{ config, lib, pkgs, flakeRoot, ... }:
|
|
|
|
let
|
|
# Repo inputs
|
|
repoWallpaperDir = flakeRoot + "/assets/conf/desktop/wallpaper";
|
|
|
|
# Where we sync assets to (writable)
|
|
userRelRoot = "nixos_conf/wallpaperstuff";
|
|
userAbsRoot = "${config.home.homeDirectory}/${userRelRoot}";
|
|
|
|
picturesDir = "${userAbsRoot}/pictures";
|
|
|
|
# Writable runtime TOML (NOT under ~/.config)
|
|
runtimeConf = "${userAbsRoot}/wpaperd-runtime.toml";
|
|
|
|
# Your generator script (synced from repo into userAbsRoot)
|
|
wsScript = "${userAbsRoot}/wpaperd-workspace-1to9.sh";
|
|
|
|
# Sync everything in repoWallpaperDir to ~/nixos_conf/wallpaperstuff,
|
|
# but keep it simple: we exclude no files here unless you want to.
|
|
repoWallpapersOnly = lib.cleanSourceWith {
|
|
src = repoWallpaperDir;
|
|
filter = path: type: true;
|
|
};
|
|
in
|
|
{
|
|
home.packages = [
|
|
pkgs.wpaperd
|
|
];
|
|
|
|
# 1) Sync your wallpaper assets + scripts into a writable location
|
|
home.file."${userRelRoot}" = {
|
|
source = repoWallpapersOnly;
|
|
recursive = true;
|
|
};
|
|
|
|
# 2) Ensure we have a writable runtime config (created if missing)
|
|
#
|
|
# NOTE: We intentionally do NOT create ~/.config/wpaperd/config.toml via HM,
|
|
# because HM places managed files in /nix/store and symlinks them (read-only),
|
|
# which breaks apps/scripts that want to write there.
|
|
home.activation.ensureWpaperdRuntimeConf =
|
|
lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
mkdir -p "${userAbsRoot}"
|
|
mkdir -p "${picturesDir}"
|
|
|
|
if [ ! -f "${runtimeConf}" ]; then
|
|
cat > "${runtimeConf}" <<'EOF'
|
|
[default]
|
|
mode = "stretch"
|
|
|
|
# Fallback for outputs not explicitly listed:
|
|
[any]
|
|
path = "__WALLPAPER_DIR__"
|
|
EOF
|
|
# default: point [any].path at your pictures dir
|
|
${pkgs.gnused}/bin/sed -i "s|__WALLPAPER_DIR__|${picturesDir}|g" "${runtimeConf}"
|
|
fi
|
|
'';
|
|
|
|
# 3) wpaperd user service: always use the writable runtime config
|
|
systemd.user.services.wpaperd = {
|
|
Unit = {
|
|
Description = "wpaperd wallpaper daemon (runtime config)";
|
|
PartOf = [ "graphical-session.target" ];
|
|
After = [ "graphical-session.target" ];
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${runtimeConf}";
|
|
Restart = "on-failure";
|
|
RestartSec = 1;
|
|
};
|
|
|
|
Install = {
|
|
WantedBy = [ "graphical-session.target" ];
|
|
};
|
|
};
|
|
|
|
# 4) Optional: run your workspace generator once per login, then restart wpaperd
|
|
systemd.user.services.wpaperd-workspaces-init = {
|
|
Unit = {
|
|
Description = "Generate workspace wallpapers (wpaperd runtime config)";
|
|
PartOf = [ "graphical-session.target" ];
|
|
After = [ "graphical-session.target" ];
|
|
};
|
|
|
|
Service = {
|
|
Type = "oneshot";
|
|
ExecStart = "${pkgs.bash}/bin/bash ${wsScript} ${picturesDir}";
|
|
ExecStartPost = "${pkgs.systemd}/bin/systemctl --user restart wpaperd";
|
|
};
|
|
|
|
Install = {
|
|
WantedBy = [ "graphical-session.target" ];
|
|
};
|
|
};
|
|
}
|