@@ -1,40 +0,0 @@
1−#!/usr/bin/env bash
2−
3−###
4−### This script runs 'nix-build' with ./fetch-source.nix and copies a subset
5−### of the resulting store path into the current working directory.
6−###
7−### To disable running chmod, you may set the environment
8−### variable "FIX_RIGHTS" to "no".
9−###
10−
11−set -euo pipefail
12−
13−# 'nix-build' command
14−NIX_BUILD_BIN="${NIX_BUILD_BIN:-"/usr/bin/env nix-build"}"
15−
16−# where to place the yarn2nix source
17−TARGET_DIR="${TARGET_DIR:-"./yarn2nix"}"
18−
19−# whether to run 'chmod -R u=rwX,g=rX,o-rwx' on copied files in $TARGET_DIR
20−FIX_RIGHTS="${FIX_RIGHTS:-"yes"}"
21−
22−fetch_git_source() {
23− [[ -f ./fetch-source.nix ]] && ret="$($NIX_BUILD_BIN --no-out-link ./fetch-source.nix)" && ec="$?" || ec="$?"
24− if [[ "$ec" == "0" ]]; then
25− echo "$ret"
26− else
27− printf "error: failed at 'fetch_git_source()' with '%s'" "$ret"
28− fi
29−}
30−
31−result="$(fetch_git_source)"
32−if [[ "$result" == "/nix/store"* ]]; then
33− mkdir -p "$TARGET_DIR"
34− cp -Rv \
35− "${result}/"{bin,internal,lib,nix,default.nix,package.json,yarn.nix,yarn.lock,LICENSE.txt} \
36− "$TARGET_DIR"
37− [[ "$FIX_RIGHTS" = "yes" ]] \
38− && chmod -v "u=rwX,g=rX,o-rwx" -R \
39− "$TARGET_DIR/"{bin,internal,lib,nix,default.nix,package.json,yarn.nix,yarn.lock,LICENSE.txt}
40−fi