This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/scripts/add-go-module.sh
2023-05-16 13:53:28 +01:00

36 lines
616 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p go gnumake
set -x
export GO111MODULE=on
SOURCE=$1
WRITE_PATH=$(realpath $2)
SOURCE_EXTRACTED=$(mktemp -du)
cp -r $SOURCE $SOURCE_EXTRACTED
chmod -R +w $SOURCE_EXTRACTED
cd $SOURCE_EXTRACTED
for module in $3; do
go get $module
done
echo -e "\nstorjds storj.io/ipfs-go-ds-storj/plugin 0" >> plugin/loader/preload_list
go mod tidy
make build
for module in $3; do
go get $module
done
make build
cp go.mod go.sum $WRITE_PATH
cp plugin/loader/preload.go $WRITE_PATH
nix run github:nix-community/gomod2nix -- --dir $SOURCE_EXTRACTED --outdir $WRITE_PATH