From 0856b53afe74619a072e3753442ff05aa94291ee Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 8 Jun 2024 20:47:33 +0200 Subject: init-project script --- bin/init-project | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 bin/init-project (limited to 'bin') diff --git a/bin/init-project b/bin/init-project new file mode 100755 index 0000000..ec5e19c --- /dev/null +++ b/bin/init-project @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +if [ -f "default.nix" ]; then + echo "default.nix already exists in this directory" + #exit 1 +fi + +git init -b main . + +nixpkgsURL="https://github.com/NixOS/nixpkgs" + +echo "Fetching tags from $nixpkgsURL..." + +line=$(git ls-remote --tags "$nixpkgsURL" | \ + grep -P 'refs/tags/[0-9]{2}\.[0-9]{2}$' | \ + sort -k2 | \ + tail -n1) +echo "$line" + +commit="$(echo "$line" | awk '{print $1}')" +version="$(echo "$line" | awk '{print $2}' | cut -d/ -f3)" +archiveURL="$nixpkgsURL/archive/$commit.tar.gz" + +echo "prefetching $archiveURL..." +sha256="$(nix-prefetch-url --type sha256 --unpack "$archiveURL")" + +cat >default.nix <