alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
tools.bin_shim: init
author
lassulus
date
1 year ago
(Jul 9, 2025, 5:11 PM CEST)
commit
d045fd30
d045fd300cbc1511deb595237707e6d7afe0e84f
parent
c19efbb8
c19efbb8c825e5e4e0867eb03d6395f0b2fe94c9
+50
2 changed files
Expand all
Collapse all
Unified
Split
tools
bin_shim
bin_shim.sh
flake-module.nix
+24
tools/bin_shim/bin_shim.sh
View file
Reviewed
···
1
1
+
set -efu
2
2
+
# set -x
3
3
+
FLAKE=${FLAKE:-.}
4
4
+
echo "$FLAKE"
5
5
+
6
6
+
pkg=$1
7
7
+
shift
8
8
+
9
9
+
flake=$(nix flake prefetch "$FLAKE" --json 2>/dev/null | jq -r .storePath)
10
10
+
hash=$(echo "$flake" | md5sum | cut -d' ' -f1)
11
11
+
12
12
+
# Use XDG_RUNTIME_DIR if available, otherwise /tmp
13
13
+
if [ -n "${XDG_RUNTIME_DIR:-}" ] && [ -d "$XDG_RUNTIME_DIR" ]; then
14
14
+
cache_dir="$XDG_RUNTIME_DIR/bin_shim/$hash"
15
15
+
else
16
16
+
cache_dir="/tmp/bin_shim-$(id -u)/$hash"
17
17
+
fi
18
18
+
mkdir -p "$cache_dir"
19
19
+
if ! [ -e "$cache_dir"/"$pkg" ]; then
20
20
+
out=$(nix build "$flake"#"$pkg" --no-link --print-out-paths)
21
21
+
mainProgram=$(nix eval --raw "$flake"#"$pkg".meta.mainProgram)
22
22
+
echo "$out"/bin/"$mainProgram" > "$cache_dir"/"$pkg"
23
23
+
fi
24
24
+
exec "$(cat "$cache_dir"/"$pkg")" "$@"
+26
tools/bin_shim/flake-module.nix
View file
Reviewed
···
1
1
+
{ self, ... }:
2
2
+
{
3
3
+
perSystem =
4
4
+
{ pkgs, lib, ... }:
5
5
+
rec {
6
6
+
packages.bin_shim = pkgs.writeShellApplication {
7
7
+
name = "bin_shim";
8
8
+
runtimeInputs = [
9
9
+
pkgs.jq
10
10
+
];
11
11
+
text = builtins.readFile ./bin_shim.sh;
12
12
+
};
13
13
+
legacyPackages.bin_shim =
14
14
+
{
15
15
+
pkg_name,
16
16
+
name ? pkg_name,
17
17
+
}:
18
18
+
pkgs.writeScriptBin name ''
19
19
+
#!/bin/sh
20
20
+
set -efu
21
21
+
set -x
22
22
+
23
23
+
FLAKE=${self} ${lib.getExe packages.bin_shim} ${pkg_name} "$@"
24
24
+
'';
25
25
+
};
26
26
+
}