Regenerated
This commit is contained in:
+26
-22
@@ -340,36 +340,40 @@ EOF
|
||||
** =generated/modules/users/copy_2_home.nix=
|
||||
This copies stuff to the user home-folder
|
||||
#+BEGIN_SRC nix :tangle generated/modules/users/copy_2_home.nix :noweb tangle :mkdirp yes :eval never-html
|
||||
{ lib, config, pkgs, ... }:
|
||||
{ config, pkgs, lib, flakeRoot, ... }:
|
||||
|
||||
let
|
||||
username = config.users.users.defaultUser or "henrov";
|
||||
homeDir = config.home.homeDirectory or "/home/${username}";
|
||||
assetPath = "${config.flakeRoot}/assets/copy_2_home";
|
||||
username = config.users.users.defaultUser or "henrov";
|
||||
homeDir = "/home/${username}";
|
||||
assetPath = "${flakeRoot}/assets/copy_2_home";
|
||||
in
|
||||
{
|
||||
_module.args.hmUsers = {
|
||||
${username} = {
|
||||
# Ensure rsync is available for the activation script
|
||||
home.packages = [ pkgs.rsync ];
|
||||
# Ensure rsync is available system-wide
|
||||
environment.systemPackages = [ pkgs.rsync ];
|
||||
|
||||
# Activation script: copy assets after all other Home Manager activations
|
||||
home.activation.copyAssets = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
echo "Copying assets from ${assetPath} to ${homeDir} ..."
|
||||
systemd.user.services.copyAssets = {
|
||||
description = "Copy assets to home directory";
|
||||
|
||||
if [ ! -d "${assetPath}" ]; then
|
||||
echo "Error: source directory ${assetPath} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
wantedBy = [ "default.target" ]; # run after login
|
||||
|
||||
mkdir -p "${homeDir}"
|
||||
|
||||
# Copy recursively, preserve symlinks, overwrite existing files
|
||||
rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/"
|
||||
|
||||
echo "Done copying assets."
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
};
|
||||
|
||||
script = ''
|
||||
echo "Copying assets from ${assetPath} to ${homeDir} ..."
|
||||
|
||||
if [ ! -d "${assetPath}" ]; then
|
||||
echo "ERROR: ${assetPath} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${homeDir}"
|
||||
|
||||
${pkgs.rsync}/bin/rsync -a --no-owner --no-group "${assetPath}/" "${homeDir}/"
|
||||
|
||||
echo "Done copying assets."
|
||||
'';
|
||||
};
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
Reference in New Issue
Block a user