Files
nixos/Droidnix/generated/modules/users/copy_2_home.nix
T
2026-03-22 08:52:47 +00:00

34 lines
933 B
Nix

{ lib, config, pkgs, flakeRoot, ... }:
let
# User information
username = config.defaultUser or "henrov";
homeDir = config.home.homeDirectory or "/home/${username}";
# Absolute path to your assets folder
assetPath = "${flakeRoot}/assets/copy_2_home";
in
{
_module.args.hmUsers = {
${username} = {
# Activation script runs after everything else
home.activation.copyAssets = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
echo "Copying assets from ${assetPath} to ${homeDir} ..."
if [ ! -d "${assetPath}" ]; then
echo "Error: Source directory ${assetPath} does not exist."
exit 1
fi
# Ensure home directory exists
mkdir -p "${homeDir}"
# Copy everything recursively, preserve structure, overwrite existing
rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/"
echo "Done copying assets."
'';
};
};
}