306 current 2025-01-25 22:09:05 25.05.20241217.d3c42f1 6.6.66 *

This commit is contained in:
2025-01-26 00:34:11 -05:00
parent b223caa6f9
commit 6cbbe35b1c

View File

@@ -4,51 +4,49 @@
lib, lib,
... ...
}: let }: let
readScriptsRecursively = dir: let # readScriptsRecursively = dir: let
entries = builtins.readDir dir; # This gives an attrset of filenames -> { "type": "regular"|"directory", ...} # entries = builtins.readDir dir; # This gives an attrset of filenames -> { "type": "regular"|"directory", ...}
names = builtins.attrNames entries; # names = builtins.attrNames entries;
in # in
# We convert all items to a list of name/value pairs; then flatten them # # We convert all items to a list of name/value pairs; then flatten them
lib.attrsets.listToAttrs (lib.concatMap ( # lib.attrsets.listToAttrs (lib.concatMap (
entry: let # entry: let
fullPath = "${dir}/${entry}"; # fullPath = "${dir}/${entry}";
entryInfo = entries.${entry}; # e.g., {type="regular"|"directory",size=...} # entryInfo = entries.${entry}; # e.g., {type="regular"|"directory",size=...}
in # in
if entryInfo.type == "directory" # if entryInfo.type == "directory"
then # then
# Recursively read sub-directory # # Recursively read sub-directory
builtins.attrValues (readScriptsRecursively fullPath) # builtins.attrValues (readScriptsRecursively fullPath)
else # else
# For a file, produce an attribute set item # # For a file, produce an attribute set item
[ # [
{ # {
name = entry; # name = entry;
value = fullPath; # value = fullPath;
} # }
] # ]
) # )
names); # names);
# scripts = readScriptsRecursively ./scripts;
scripts = readScriptsRecursively ./scripts; # scriptDerivations =
# lib.attrsets.mapAttrs (
scriptDerivations = # scriptName: scriptPath:
lib.attrsets.mapAttrs ( # pkgs.writeShellApplication {
scriptName: scriptPath: # name = scriptName;
pkgs.writeShellApplication { # # Pick whatever runtime dependencies you need
name = scriptName; # runtimeInputs = with pkgs; [
# # Example: netcat, bashInteractive, curl, etc.
# Pick whatever runtime dependencies you need # netcat
runtimeInputs = with pkgs; [ # ];
# Example: netcat, bashInteractive, curl, etc. # # The text of the shell script is read directly from the file
netcat # text = builtins.readFile scriptPath;
]; # }
# )
# The text of the shell script is read directly from the file # scripts;
text = builtins.readFile scriptPath;
}
)
scripts;
in { in {
# home.packages = builtins.attrValues scriptDerivations;
home.username = "synchronous"; home.username = "synchronous";
home.homeDirectory = "/home/synchronous"; home.homeDirectory = "/home/synchronous";
imports = [ imports = [