Skip to content

Commit 30ea5d8

Browse files
committed
tools.s: init
Run packages from superconfig with a short command. Uses ~/src/superconfig if available, falls back to built-in flake reference.
1 parent 64a2f4c commit 30ea5d8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tools/s/flake-module.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ self, ... }:
2+
{
3+
perSystem =
4+
{ pkgs, ... }:
5+
{
6+
packages.s = pkgs.writers.writeDashBin "s" ''
7+
set -efu
8+
9+
# Use local checkout if it exists, otherwise fall back to self
10+
if [ -d "$HOME/src/superconfig" ]; then
11+
flake="$HOME/src/superconfig"
12+
else
13+
flake="${self}"
14+
fi
15+
16+
if [ $# -eq 0 ]; then
17+
echo "Usage: s <package> [args...]" >&2
18+
echo "Runs a package from superconfig ($flake)" >&2
19+
exit 1
20+
fi
21+
22+
pkg="$1"
23+
shift
24+
25+
exec ${pkgs.nix}/bin/nix run "$flake#$pkg" -- "$@"
26+
'';
27+
};
28+
}

0 commit comments

Comments
 (0)