From 7671bfd4d311cd863c4a3bef547b2f7d6093b8aa Mon Sep 17 00:00:00 2001 From: baldo Date: Thu, 19 May 2022 11:55:38 +0200 Subject: [PATCH] Add wrapper scripts for node / yarn on NixOS. --- nix/lib.inc.sh | 10 ++++++++++ nix/node | 6 ++++++ nix/yarn | 6 ++++++ shell.nix | 1 + 4 files changed, 23 insertions(+) create mode 100644 nix/lib.inc.sh create mode 100755 nix/node create mode 100755 nix/yarn diff --git a/nix/lib.inc.sh b/nix/lib.inc.sh new file mode 100644 index 0000000..0e83f35 --- /dev/null +++ b/nix/lib.inc.sh @@ -0,0 +1,10 @@ +function wrap() { + local TOOL="$1" + local REPO="$2" + shift + shift + + SHELL_NIX="$REPO/shell.nix" + QUOTED_ARGS="$(printf "${1+ %q}" "$@")" + exec nix-shell "$SHELL_NIX" --pure --command "$TOOL $QUOTED_ARGS" +} diff --git a/nix/node b/nix/node new file mode 100755 index 0000000..0642232 --- /dev/null +++ b/nix/node @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +REPO=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +source "$REPO/nix/lib.inc.sh" + +wrap node "$REPO" "$@" diff --git a/nix/yarn b/nix/yarn new file mode 100755 index 0000000..ad1671a --- /dev/null +++ b/nix/yarn @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +REPO=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +source "$REPO/nix/lib.inc.sh" + +wrap yarn "$REPO" "$@" diff --git a/shell.nix b/shell.nix index dd47264..6934ce6 100644 --- a/shell.nix +++ b/shell.nix @@ -12,6 +12,7 @@ stdenv.mkDerivation rec { nodejs-16_x rsync sqlite + yarn zlib ];