From 1fb8d176c5fc381da777a39275211314a2ebe9a7 Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Sun, 26 Aug 2018 13:26:49 +0100 Subject: [PATCH 1/2] Add script to generate the elm-format nix derivation for nixpkgs --- package/nix/generate_derivation.sh | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 package/nix/generate_derivation.sh diff --git a/package/nix/generate_derivation.sh b/package/nix/generate_derivation.sh new file mode 100755 index 000000000..e7853064d --- /dev/null +++ b/package/nix/generate_derivation.sh @@ -0,0 +1,50 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p git haskellPackages.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, update the FLAVOR to the most recent flavor of elm-format +# and then run: +# +# $ ./generate_derivation.sh > elm-format.sh +# +# 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. + +FLAVOR="0.19" + +REV="$(git rev-parse HEAD)" +VERSION="$(git describe --abbrev=8)" +ROOTDIR="$(git rev-parse --show-toplevel)" +SHA="$(nix-prefetch-git --url "$ROOTDIR" --rev "$REV" --quiet --no-deepClone | jq .sha256)" + +PATCH=$(cat < Date: Tue, 2 Oct 2018 18:02:58 -0700 Subject: [PATCH 2/2] Automate preparing the nix formula --- PUBLISHING.md | 10 ++++++++ package/nix/.gitignore | 1 + package/nix/build.sh | 37 ++++++++++++++++++++++++++++++ package/nix/generate_derivation.sh | 23 +++++++------------ 4 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 package/nix/.gitignore create mode 100755 package/nix/build.sh diff --git a/PUBLISHING.md b/PUBLISHING.md index 36619501b..df80683ab 100644 --- a/PUBLISHING.md +++ b/PUBLISHING.md @@ -67,3 +67,13 @@ npm dist-tag add elm-format@ elm0.18.0 npm dist-tag add elm-format@ elm0.19.0 npm dist-tag add elm-format@ exp ``` + + +## Nix + +``` +cd package/nix +./build.sh +``` + +Then `cd nixpkgs`, push the resulting branch, and make a PR to https://github.com/NixOS/nixpkgs with the title "elm-format: [old version] -> [new version]" diff --git a/package/nix/.gitignore b/package/nix/.gitignore new file mode 100644 index 000000000..85104f126 --- /dev/null +++ b/package/nix/.gitignore @@ -0,0 +1 @@ +/nixpkgs diff --git a/package/nix/build.sh b/package/nix/build.sh new file mode 100755 index 000000000..9e252f7f7 --- /dev/null +++ b/package/nix/build.sh @@ -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" diff --git a/package/nix/generate_derivation.sh b/package/nix/generate_derivation.sh index e7853064d..53efeaade 100755 --- a/package/nix/generate_derivation.sh +++ b/package/nix/generate_derivation.sh @@ -1,37 +1,30 @@ #! /usr/bin/env nix-shell -#! nix-shell -i bash -p git haskellPackages.cabal2nix nix-prefetch-git jq +#! 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, update the FLAVOR to the most recent flavor of elm-format -# and then run: +# To use this script, run: # -# $ ./generate_derivation.sh > elm-format.sh +# $ ./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. -FLAVOR="0.19" +set -exo pipefail REV="$(git rev-parse HEAD)" -VERSION="$(git describe --abbrev=8)" +VERSION="$(git describe --abbrev=8 "$REV")" ROOTDIR="$(git rev-parse --show-toplevel)" -SHA="$(nix-prefetch-git --url "$ROOTDIR" --rev "$REV" --quiet --no-deepClone | jq .sha256)" +SHA="$(nix-prefetch-git --url "$ROOTDIR" --rev "$REV" --quiet --no-deepClone | jq --raw-output .sha256)" PATCH=$(cat <