forked from avh4/elm-format
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request avh4#559 from avh4/release-prep
Automate updating the nix package
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nixpkgs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -exo pipefail | ||
|
||
ELM_FORMAT_VERSION="$(git describe --abbrev=8)" | ||
BRANCH="elm-format-$ELM_FORMAT_VERSION" | ||
|
||
if [ ! -d nixpkgs ]; then | ||
git clone https://github.com/NixOS/nixpkgs.git nixpkgs | ||
fi | ||
|
||
pushd nixpkgs | ||
git fetch origin master | ||
if git branch | grep " ${BRANCH}$"; then | ||
git checkout "$BRANCH" | ||
git reset --hard origin/master | ||
else | ||
git checkout -b "$BRANCH" origin/master | ||
fi | ||
popd | ||
|
||
cabal2nix --no-check cabal://indents-0.3.3 > nixpkgs/pkgs/development/compilers/elm/packages/indents.nix | ||
cabal2nix --no-check cabal://tasty-quickcheck-0.9.2 > nixpkgs/pkgs/development/compilers/elm/packages/tasty-quickcheck.nix | ||
./generate_derivation.sh > nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix | ||
|
||
pushd nixpkgs | ||
rm -f result | ||
nix-build -A elmPackages.elm-format | ||
git status | ||
result/bin/elm-format | head -n1 | ||
popd | ||
|
||
set +x | ||
|
||
echo | ||
echo "Everything looks good!" | ||
echo "You will need to make a PR from the $BRANCH branch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p git cabal2nix nix-prefetch-git jq | ||
|
||
# This script generates the nix derivation for elm-format intended for nixpkgs: | ||
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/elm/packages/elm-format.nix | ||
|
||
# To use this script, run: | ||
# | ||
# $ ./generate_derivation.sh > elm-format.nix | ||
# | ||
# This might take a bit of time if the dependencies are not already in the nix | ||
# store. If you already have all the dependencies installed, feel free to remove | ||
# them from the shebang to speed up the process. | ||
|
||
set -exo pipefail | ||
|
||
REV="$(git rev-parse HEAD)" | ||
VERSION="$(git describe --abbrev=8 "$REV")" | ||
ROOTDIR="$(git rev-parse --show-toplevel)" | ||
SHA="$(nix-prefetch-git --url "$ROOTDIR" --rev "$REV" --quiet --no-deepClone | jq --raw-output .sha256)" | ||
|
||
PATCH=$(cat <<END | ||
src = fetchgit { | ||
url = "http://github.com/avh4/elm-format"; | ||
sha256 = "$SHA"; | ||
rev = "$REV"; | ||
}; | ||
postPatch = '' | ||
sed -i "s|desc <-.*||" ./Setup.hs | ||
sed -i "s|gitDescribe = .*|gitDescribe = \\\\\\\\\"$VERSION\\\\\\\\\"\"|" ./Setup.hs | ||
''; | ||
END | ||
) | ||
|
||
# quoteSubst from https://stackoverflow.com/a/29613573 | ||
quoteSubst() { | ||
IFS= read -d '' -r < <(sed -e ':a' -e '$!{N;ba' -e '}' -e 's/[&/\]/\\&/g; s/\n/\\&/g' <<<"$1") | ||
printf %s "${REPLY%$'\n'}" | ||
} | ||
|
||
cabal2nix --no-haddock "$ROOTDIR" | | ||
sed "s#^{ mkDerivation#{ mkDerivation, fetchgit#" | | ||
sed "s#\\s*src = .*;#$(quoteSubst "$PATCH")#" |