new wallpaperthingie

This commit is contained in:
2026-03-17 18:36:22 +00:00
parent 76662cbca6
commit 1f42d99ac5
@@ -1,57 +1,50 @@
# file: wallpaper-copy.nix
# file: configuration.nix snippet
{
lib,
config,
pkgs,
lib,
flakeRoot,
...
}:
let
sourceDir = "${flakeRoot}/assets/hyprland/wallpaperstuff";
# Determine the username safely (fallback to "default" if home-manager is not present)
username =
if lib.attrExists "home" config && lib.attrExists "username" config.home then
config.home.username
else
"default";
# Determine target directory
targetDir =
if lib.attrExists "home" config then
"${config.home.homeDirectory}/Droidnix/wallpaperstuff"
else
"$HOME/Droidnix/wallpaperstuff";
# Path to wallpaperstuff folder in the flake
wallpaperDir = "${flakeRoot}/assets/hyprland/wallpaperstuff";
wallpaperConf = "${wallpaperDir}/wallpaper.conf";
in
{
options.wallpaper.enable = lib.mkEnableOption "Copy wallpaperstuff dir";
# Make wpaperd available system-wide
environment.systemPackages = [
pkgs.wpaperd
];
config = lib.mkIf config.wallpaper.enable {
# User-level systemd service for wpaperd
systemd.user.services.wpaperd = {
description = "wpaperd wallpaper daemon";
after = [ "default.target" ];
# System activation (runs on nixos-rebuild switch)
system.activationScripts.copyWallpapers = {
text = ''
echo "=== Copying wallpaperstuff (system activation) ==="
mkdir -p "${targetDir}"
cp -rT "${sourceDir}" "${targetDir}"
echo "Done."
'';
deps = [ ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.wpaperd}/bin/wpaperd --config ${wallpaperConf}";
Restart = "on-failure";
RestartSec = 1;
};
# Home Manager activation (runs when home-manager switch is executed)
home-manager.users.${username}.home.activation.copyWallpapers =
lib.mkIf (lib.attrExists "home" config)
{
description = "Copy wallpaperstuff to user home";
script = ''
echo "=== Copying wallpaperstuff (home-manager activation) ==="
mkdir -p "${targetDir}"
cp -rT "${sourceDir}" "${targetDir}"
echo "Done."
'';
};
install = {
WantedBy = [ "default.target" ];
};
};
# Optional: ensure the directory exists
system.activationScripts.copyWallpaperConf = {
text = ''
echo "=== Ensuring wallpaper config exists ==="
mkdir -p "${wallpaperDir}/pictures"
if [ ! -f "${wallpaperConf}" ]; then
touch "${wallpaperConf}"
fi
echo "Done."
'';
deps = [ ];
};
}