From b223caa6f9daba36ffd8fd3e324ce03f19baf961 Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Sun, 26 Jan 2025 00:30:25 -0500 Subject: [PATCH] 306 current 2025-01-25 22:09:05 25.05.20241217.d3c42f1 6.6.66 * --- home/home.nix | 84 +++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/home/home.nix b/home/home.nix index 3f3d335..9dda9d1 100644 --- a/home/home.nix +++ b/home/home.nix @@ -4,46 +4,50 @@ lib, ... }: let - # readScriptsRecursively = dir: let - # entries = builtins.readDir dir; # This gives an attrset of filenames -> { "type": "regular"|"directory", ...} - # names = builtins.attrNames entries; - # in - # # We convert all items to a list of name/value pairs; then flatten them - # lib.attrsets.listToAttrs (lib.concatMap ( - # entry: let - # fullPath = "${dir}/${entry}"; - # entryInfo = entries.${entry}; # e.g., {type="regular"|"directory",size=...} - # in - # if entryInfo.type == "directory" - # then - # # Recursively read sub-directory - # builtins.attrValues (readScriptsRecursively fullPath) - # else - # # For a file, produce an attribute set item - # [ - # { - # name = entry; - # value = fullPath; - # } - # ] - # ) - # names); - # scripts = readScriptsRecursively ./scripts; - # scriptDerivations = - # lib.attrsets.mapAttrs ( - # scriptName: scriptPath: - # pkgs.writeShellApplication { - # name = scriptName; - # # Pick whatever runtime dependencies you need - # runtimeInputs = with pkgs; [ - # # Example: netcat, bashInteractive, curl, etc. - # netcat - # ]; - # # The text of the shell script is read directly from the file - # text = builtins.readFile scriptPath; - # } - # ) - # scripts; + readScriptsRecursively = dir: let + entries = builtins.readDir dir; # This gives an attrset of filenames -> { "type": "regular"|"directory", ...} + names = builtins.attrNames entries; + in + # We convert all items to a list of name/value pairs; then flatten them + lib.attrsets.listToAttrs (lib.concatMap ( + entry: let + fullPath = "${dir}/${entry}"; + entryInfo = entries.${entry}; # e.g., {type="regular"|"directory",size=...} + in + if entryInfo.type == "directory" + then + # Recursively read sub-directory + builtins.attrValues (readScriptsRecursively fullPath) + else + # For a file, produce an attribute set item + [ + { + name = entry; + value = fullPath; + } + ] + ) + names); + + scripts = readScriptsRecursively ./scripts; + + scriptDerivations = + lib.attrsets.mapAttrs ( + scriptName: scriptPath: + pkgs.writeShellApplication { + name = scriptName; + + # Pick whatever runtime dependencies you need + runtimeInputs = with pkgs; [ + # Example: netcat, bashInteractive, curl, etc. + netcat + ]; + + # The text of the shell script is read directly from the file + text = builtins.readFile scriptPath; + } + ) + scripts; in { home.username = "synchronous"; home.homeDirectory = "/home/synchronous";