Files
nixos/Droidnix/generated/modules/users/copy_2_home.nix
T
2026-03-22 07:31:28 +00:00

42 lines
1.1 KiB
Nix

{ lib, config, ... }:
let
username = config.defaultUser or "henrov";
# Absolute path to assets folder
assetPath = ../../../assets/copy_2_home;
# Helper: recursively list all files in assetPath
recursiveListFiles = path:
let
entries = builtins.readDir path;
in
concatMap (name: let full = "${path}/${name}"; in
if builtins.isDir full
then recursiveListFiles full
else [ full ]
) (builtins.attrNames entries);
# All files in the folder (full paths)
allFiles = recursiveListFiles assetPath;
# Map each file to a home.file entry
homeFiles = lib.genAttrs (allFiles) (f: {
# Compute relative path from assetPath
relative = builtins.substring (builtins.stringLength assetPath + 1) (builtins.stringLength f - builtins.stringLength assetPath - 1) f;
name = relative; # target path in $HOME
value = { source = f; }; # source path
});
in
{
_module.args.hmUsers = {
${username} = {
# Merge with other modules safely
home.file = lib.mkMerge [
homeFiles
];
};
};
}