Regenerated
This commit is contained in:
+29
-19
@@ -293,33 +293,43 @@ This copies stuff to the user home-folder
|
||||
{ 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
|
||||
# Absolute path to the assets folder
|
||||
assetPath = "${flakeRoot}/assets/copy_2_home";
|
||||
|
||||
# Helper function to recursively list files in a directory
|
||||
recursiveFiles = path:
|
||||
let
|
||||
entries = builtins.attrNames (builtins.readDir path);
|
||||
in
|
||||
lib.concatMap (name:
|
||||
let
|
||||
full = "${path}/${name}";
|
||||
in
|
||||
if builtins.isDir full
|
||||
then recursiveFiles full
|
||||
else [ full ]
|
||||
) entries;
|
||||
|
||||
# All files in assets folder
|
||||
allFiles = recursiveFiles assetPath;
|
||||
|
||||
# Map files to home.file entries
|
||||
homeFiles = lib.genAttrs allFiles (f: let
|
||||
relative = lib.replaceStrings [ "${assetPath}/" ] [ "" ] f;
|
||||
in {
|
||||
name = relative;
|
||||
value = { source = f; };
|
||||
});
|
||||
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."
|
||||
'';
|
||||
home.file = lib.mkMerge [
|
||||
homeFiles
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user