This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools: simplify bin_shim to just nix run

+4 -37
-25
tools/bin_shim/bin_shim.sh
··· 1 - #!/bin/sh 2 - set -efu 3 - # set -x 4 - FLAKE=${FLAKE:-.} 5 - echo "$FLAKE" 6 - 7 - pkg=$1 8 - shift 9 - 10 - flake=$(nix flake prefetch "$FLAKE" --json 2>/dev/null | jq -r .storePath) 11 - hash=$(echo "$flake" | md5sum | cut -d' ' -f1) 12 - 13 - # Use XDG_RUNTIME_DIR if available, otherwise /tmp 14 - if [ -n "${XDG_RUNTIME_DIR:-}" ] && [ -d "$XDG_RUNTIME_DIR" ]; then 15 - cache_dir="$XDG_RUNTIME_DIR/bin_shim/$hash" 16 - else 17 - cache_dir="/tmp/bin_shim-$(id -u)/$hash" 18 - fi 19 - mkdir -p "$cache_dir" 20 - if ! [ -e "$cache_dir"/"$pkg" ]; then 21 - out=$(nix build "$flake"#"$pkg" --no-link --print-out-paths) 22 - mainProgram=$(nix eval --raw "$flake"#"$pkg".meta.mainProgram) 23 - echo "$out"/bin/"$mainProgram" > "$cache_dir"/"$pkg" 24 - fi 25 - exec "$(cat "$cache_dir"/"$pkg")" "$@"
+4 -12
tools/bin_shim/flake-module.nix
··· 1 - { self, ... }: 1 + { ... }: 2 2 { 3 3 perSystem = 4 - { pkgs, lib, ... }: 5 - rec { 6 - packages.bin_shim = pkgs.writeShellApplication { 7 - name = "bin_shim"; 8 - runtimeInputs = [ 9 - pkgs.jq 10 - ]; 11 - text = builtins.readFile ./bin_shim.sh; 12 - }; 4 + { pkgs, ... }: 5 + { 13 6 legacyPackages.bin_shim = 14 7 { 15 8 pkg_name, ··· 18 11 pkgs.writeScriptBin name '' 19 12 #!/bin/sh 20 13 set -efu 21 - set -x 22 14 23 - FLAKE=${self} ${lib.getExe packages.bin_shim} ${pkg_name} "$@" 15 + nix --extra-experimental-features 'flakes nix-command' run .#${pkg_name} -- "$@" 24 16 ''; 25 17 }; 26 18 }