From 145d695164395ec9ca234a299b91b28cef8ed621 Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Sun, 9 Feb 2025 01:23:53 -0500 Subject: [PATCH] 309 current 2025-02-09 01:23:40 25.05.20241217.d3c42f1 6.6.66 * --- home/home.nix | 63 ++++++++++++++++------------------------- home/scripts/test/tb.sh | 2 -- home/tb.nix | 29 +++++++++---------- 3 files changed, 38 insertions(+), 56 deletions(-) delete mode 100644 home/scripts/test/tb.sh diff --git a/home/home.nix b/home/home.nix index ca44d0d..b9047d8 100644 --- a/home/home.nix +++ b/home/home.nix @@ -4,45 +4,6 @@ lib, ... }: let - # 1) Recursively collect all scripts into a *list* of { name, value } items - # readScriptsRecursively = dir: let - # entries = builtins.readDir dir; - # names = builtins.attrNames entries; - # in - # lib.concatMap ( - # entry: let - # fullPath = "${dir}/${entry}"; - # entryInfo = entries.${entry}; - # in - # if entryInfo.type == "directory" - # then - # # Recursively gather more {name, value} items - # readScriptsRecursively fullPath - # else - # # For each file, produce one record - # [ - # { - # name = entry; - # value = fullPath; - # } - # ] - # ) - # names; - # # 2) Convert that list of {name, value} into an attribute set - # scripts = lib.attrsets.listToAttrs (readScriptsRecursively ./scripts); - # # 3) Map over the attrset to create shell applications - # scriptDerivations = - # lib.attrsets.mapAttrs - # (scriptName: scriptPath: - # pkgs.writeShellApplication { - # name = scriptName; - # runtimeInputs = with pkgs; [ - # # put your dependencies here - # netcat - # ]; - # text = builtins.readFile scriptPath; - # }) - # scripts; in { # home.packages = builtins.attrValues scriptDerivations; @@ -72,4 +33,28 @@ in { }; programs.home-manager.enable = true; + + home.packages = with pkgs; + [ + # any other "normal" packages go here + ] + ++ ( + with lib; let + # This function extracts the base file name from a path. + basename = path: lib.lists.last (lib.strings.splitString "/" (toString path)); + + # Adjust this path to wherever your scripts are. + # If your home-manager config is in ~/dotfiles/home.nix, + # and your scripts are in ~/dotfiles/bin/bin, you could do: + files = lib.filesystem.listFilesRecursive ./scripts; + in + # For each script found, create a derivation installed in $PATH + lib.lists.forEach files ( + file: + pkgs.writeScriptBin + (basename file) # the new package's name + + (builtins.readFile file) + ) + ); } diff --git a/home/scripts/test/tb.sh b/home/scripts/test/tb.sh deleted file mode 100644 index f58d5a5..0000000 --- a/home/scripts/test/tb.sh +++ /dev/null @@ -1,2 +0,0 @@ -file=$1 -cat "$1" | nc termbin.com 9999 diff --git a/home/tb.nix b/home/tb.nix index da4549e..07d0abe 100644 --- a/home/tb.nix +++ b/home/tb.nix @@ -1,16 +1,15 @@ -# scripts.nix -# {pkgs, ...}: { - # home.packages = with pkgs; [ - # (writeShellApplication { - # name = "termbin"; - # runtimeInputs = with pkgs; [ - # netcat - # ]; +{pkgs, ...}: { + home.packages = with pkgs; [ + (writeShellApplication { + name = "termbin"; + runtimeInputs = with pkgs; [ + netcat + ]; - # text = '' - # file=$1 - # cat "$1" | nc termbin.com 9999 - # ''; - # }) - # ]; -# } + text = '' + file=$1 + cat "$1" | nc termbin.com 9999 + ''; + }) + ]; +}