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 new file mode 100755 index 000000000..53efeaade --- /dev/null +++ b/package/nix/generate_derivation.sh @@ -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 <