Regenerated
This commit is contained in:
+26
-13
@@ -287,31 +287,44 @@ in {
|
||||
** =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, ... }:
|
||||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
username = config.defaultUser or "henrov";
|
||||
|
||||
# Absolute path to assets folder
|
||||
assetPath = ../../../assets/copy_2_home;
|
||||
|
||||
# readDir gives all entries in the folder
|
||||
entries = builtins.readDir assetPath;
|
||||
# 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);
|
||||
|
||||
# generate xdg-style home.file entries
|
||||
homeFiles = lib.genAttrs (builtins.attrNames entries) (name: {
|
||||
# source path in store
|
||||
source = "${assetPath}/${name}";
|
||||
# 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} = {
|
||||
# recursively copy all files under the top-level folder into home
|
||||
home.file = lib.mkMerge (map (name: {
|
||||
# target path in home
|
||||
name = name;
|
||||
value = { source = "${assetPath}/${name}"; };
|
||||
}) (builtins.attrNames entries));
|
||||
# Merge with other modules safely
|
||||
home.file = lib.mkMerge [
|
||||
homeFiles
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user