34 lines
839 B
Nix
34 lines
839 B
Nix
{ lib, config, pkgs, flakeRoot, ... }:
|
|
let
|
|
username = config.defaultUser or "henrov";
|
|
scriptsPath = flakeRoot + "/generated/.config/scripts";
|
|
|
|
# Get all files in the scripts directory recursively
|
|
scriptFiles = lib.filesystem.listFilesRecursive scriptsPath;
|
|
|
|
# Convert a file path to a relative string like ".config/scripts/foo.sh"
|
|
toRelative = file:
|
|
let
|
|
fullStr = toString file;
|
|
baseStr = toString (flakeRoot + "/generated/");
|
|
in
|
|
lib.removePrefix baseStr fullStr;
|
|
|
|
# Build the attrset entry for each file
|
|
toFileEntry = file: {
|
|
name = toRelative file;
|
|
value = {
|
|
text = builtins.readFile file;
|
|
executable = true;
|
|
force = true;
|
|
};
|
|
};
|
|
in
|
|
{
|
|
home-manager.users = {
|
|
${username} = {
|
|
home.file = builtins.listToAttrs (map toFileEntry scriptFiles);
|
|
};
|
|
};
|
|
}
|