Regenerated

This commit is contained in:
2026-03-29 14:58:18 +00:00
parent c3b1bc2ab6
commit b176bed95a
3 changed files with 390 additions and 360 deletions
@@ -1,47 +1,57 @@
{ config, pkgs, lib, flakeRoot, ... }:
let
username = config.defaultUser or "henrov";
username = config.users.users.defaultUser or "henrov";
homeDir = "/home/${username}";
wallpaperSrc = "${flakeRoot}/assets/traveldroid/Wallpapers";
wallpaperDst = "${homeDir}/Wallpapers";
scriptFile = "${homeDir}/copy-wallpapers.sh";
in
{
############################
# Ensure bash exists
############################
environment.systemPackages = [ pkgs.bash ];
# Drop the script into home
############################
# Create the script in the user's home
############################
home-manager.users = {
${username} = {
home.file."copy-wallpapers.sh".text = ''
#!/usr/bin/env bash
set -e
echo "Copying wallpapers from ${wallpaperSrc} to ${wallpaperDst} ..."
if [ ! -d "${wallpaperSrc}" ]; then
echo "ERROR: ${wallpaperSrc} does not exist"
exit 1
fi
mkdir -p "${wallpaperDst}"
chown -R ${username}:${username} "${wallpaperDst}"
# Copy everything
cp -r "${wallpaperSrc}/." "${wallpaperDst}/"
# Fix permissions
chown -R ${username}:${username} "${wallpaperDst}"
chmod -R u+rwx "${wallpaperDst}"
echo "Done copying wallpapers."
'';
};
};
${username} = {
home.file."copy-wallpapers.sh".text = ''
#!/usr/bin/env bash
set -e
echo "Copying wallpapers from ${wallpaperSrc} to ${wallpaperDst} ..."
# User service that runs the script
if [ ! -d "${wallpaperSrc}" ]; then
echo "ERROR: ${wallpaperSrc} does not exist"
exit 1
fi
mkdir -p "${wallpaperDst}"
# Copy everything
cp -r "${wallpaperSrc}/." "${wallpaperDst}/"
# Fix permissions
chmod -R u+rwx "${wallpaperDst}"
echo "Done copying wallpapers."
'';
home.file."copy-wallpapers.sh".executable = true;
};
};
############################
# User systemd service that runs the script
############################
systemd.user.services.copyWallpapers = {
description = "Copy wallpapers from repo to ~/Wallpapers";
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${scriptFile}";
serviceConfig.ExecStart = scriptFile;
serviceConfig.Restart = "no";
};
}