Files
nixos/Droidnix/generated/hyprland/decorations/rotating_wallpaper.nix
T
2026-03-17 18:31:18 +00:00

58 lines
1.5 KiB
Nix

# file: wallpaper-copy.nix
{
lib,
config,
pkgs,
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";
in
{
options.wallpaper.enable = lib.mkEnableOption "Copy wallpaperstuff dir";
config = lib.mkIf config.wallpaper.enable {
# 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 = [ ];
};
# 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."
'';
};
};
}