From 3bdbb47aeb4bdd0bb1607d811d9c672e2a94876a Mon Sep 17 00:00:00 2001 From: Grey Jones Date: Sun, 30 Aug 2026 12:22:47 +0100 Subject: [PATCH] localBinFromStringAttrs: first iteration, convenient wrapper --- flake.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index f7dfc6d..cb2dff9 100644 --- a/flake.nix +++ b/flake.nix @@ -22,11 +22,19 @@ setAttrByStrPath = strPath: value: nixpkgs.lib.setAttrByPath (nixpkgs.lib.strings.splitString "." strPath) value; - homeFilesFromStringAttrs = { dir, attrs, exec ? false }: mergeListsToAttrs (map (x: "${dir}/${x}") (builtins.attrNames attrs)) (map (x: { - text = x; + homeFilesFromStringAttrs = { dir, attrs, exec ? false }: mergeListsToAttrs (map (x: "${dir}/${x}") (builtins.attrNames attrs)) (map (y: { + text = y; executable = exec; }) (builtins.attrValues attrs)); + prependShebangToString = x: "#!/usr/bin/env bash\n" + x; + + localBinFromStringAttrs = attrs: homeFilesFromStringAttrs { + dir = ".local/bin"; + attrs = builtins.mapAttrs (name: value: prependShebangToString value) attrs; + exec = true; + }; + mergeListsToAttrs = names: values: nixpkgs.lib.listToAttrs (nixpkgs.lib.zipListsWith (name: value: { inherit name value; }) names values); }; }