From 957aba2281ca457e992fa7374e090a31820306ee Mon Sep 17 00:00:00 2001 From: intercalations Date: Sun, 27 Feb 2022 13:55:08 -0500 Subject: [PATCH 1/3] Allow passing of GHC version; make snapshot current --- README.md | 6 ++++++ init-haskell | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 60a4373..62d2643 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,12 @@ mkdir myprojectname && cd myprojectname init-haskell ``` +The above will default to using GHC 8.10.7. If you'd like to use a different version, simply pass the full version as an argument: + +``` +init-haskell 9.2.1 +``` + ### Build and run ``` diff --git a/init-haskell b/init-haskell index 2bd54b5..d164790 100755 --- a/init-haskell +++ b/init-haskell @@ -5,6 +5,14 @@ set -Eeuxo pipefail # init-haskell location base=$(dirname "$(readlink -f "$0")") +ghc=${1:-8.10.7} +ghcparts=(${ghc//./ }) +ghcmajor=${ghcparts[0]} +ghcminor=${ghcparts[1]} +ghcpatch=${ghcparts[2]} + +today=$(date +"%Y-%m-%d") + # Variables data=$(mktemp) projectname=${PWD##*/} @@ -12,11 +20,11 @@ cat <$data { "author": "$(git config user.name)" , "email": "$(git config user.email)" , "ghc": - { major: 8 - , minor: 10 - , patch: 7 + { major: ${ghcmajor} + , minor: ${ghcminor} + , patch: ${ghcpatch} } -, "snapshot": "2022-01-01T00:00:00Z" +, "snapshot": "${today}T00:00:00Z" , "projectname": "${projectname}" } EOF From b4dee518d9d3450ebd8c962c62adac0e0d23158e Mon Sep 17 00:00:00 2001 From: intercalations Date: Mon, 28 Feb 2022 08:23:06 -0500 Subject: [PATCH 2/3] Fix handling of snapshot --- init-haskell | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/init-haskell b/init-haskell index d164790..3aadbd4 100755 --- a/init-haskell +++ b/init-haskell @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell --pure --keep NIX_SSL_CERT_FILE --keep GITHUB_TOKEN -i bash -p git mustache-go niv direnv nix +#! nix-shell --pure --keep NIX_SSL_CERT_FILE --keep GITHUB_TOKEN -i bash -p git mustache-go jq niv direnv nix set -Eeuxo pipefail # init-haskell location @@ -11,7 +11,12 @@ ghcmajor=${ghcparts[0]} ghcminor=${ghcparts[1]} ghcpatch=${ghcparts[2]} -today=$(date +"%Y-%m-%d") +snapshot="2022-01-01T00:00:00Z" +cabaltimestamp=~/.cabal/packages/hackage.haskell.org/timestamp.json + +if [ -f $cabaltimestamp ]; then + snapshot=$(jq '.signed | select(._type == "Timestamp") | .expires' $cabaltimestamp) +fi # Variables data=$(mktemp) @@ -24,7 +29,7 @@ cat <$data , minor: ${ghcminor} , patch: ${ghcpatch} } -, "snapshot": "${today}T00:00:00Z" +, "snapshot": "${snapshot}" , "projectname": "${projectname}" } EOF From 9f6495b32c46808fb4d71e59a8885555e1de5c9c Mon Sep 17 00:00:00 2001 From: intercalations Date: Sun, 1 May 2022 17:32:22 -0400 Subject: [PATCH 3/3] Prevent double quotes --- init-haskell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init-haskell b/init-haskell index 3aadbd4..e012e0f 100755 --- a/init-haskell +++ b/init-haskell @@ -15,7 +15,7 @@ snapshot="2022-01-01T00:00:00Z" cabaltimestamp=~/.cabal/packages/hackage.haskell.org/timestamp.json if [ -f $cabaltimestamp ]; then - snapshot=$(jq '.signed | select(._type == "Timestamp") | .expires' $cabaltimestamp) + snapshot=$(jq -r '.signed | select(._type == "Timestamp") | .expires' $cabaltimestamp) fi # Variables