git.iko.soy/typeable/rollbar-hs
on master help sign in
Move to a nix-based setup

With nix, we get more reproducable builds. Everything that goes into making the build can be specified. The dependencies we need for development/CI can be made the same. And, we ought to be able to parameterize the build better. When we want to check if things compile on 8.4.x, we can change the compiler to that version in one place. Assuming this works out, it should make for a lower amount of overall work.

commit79f82a54ac407657360a94b8ebe40b196289d25c authorjoneshf <jones3.hardy@gmail.com> dateThu 9 Aug 2018, 07:51 (8 years ago) parent4a7a221
4 files changed+95−109
Makefile+31−43 default.nix+21 shell.nix+43 stack.yaml−66
Makefile+31−43
@@ -1,64 +1,52 @@
1−BIN ?= bin
21CABAL ?= cabal
2+CABAL_FLAGS ?=
33DIST ?= dist
4−EMPTY ?= .make
5−PROJECT_NAME ?= rollbar-hs
6−STACK ?= stack
7−STACK_WORK ?= .stack-work
8−VERBOSITY ?= warn
4+GHCID ?= ghcid
5+GHCID_FLAGS ?= --ghc-options=-fno-code
6+HPACK ?= hpack
7+NIX_SHELL ?= nix-shell
8+NIX_SHELL_FLAGS ?=
9+PROJECT_NAME := rollbar-hs
910
1011CABAL_FILE := $(PROJECT_NAME).cabal
12+CONFIGURE := $(DIST)/setup-config
1113DOC_TEST := $(DIST)/build/doc-test/doc-test
12−GHCID := $(BIN)/ghcid
13−STACK_FLAGS := --verbosity $(VERBOSITY)
1414
1515.DEFAULT_GOAL := build
1616
17−$(BIN) $(DIST) $(EMPTY):
18− mkdir -p $@
19−
2017$(CABAL_FILE): package.yaml
21− # `stack` has no way to run `hpack` directly.
22− # We can run `hpack` indirectly with little overhead.
23− $(STACK) $(STACK_FLAGS) build --dry-run
24−
25−$(DOC_TEST):
26− rm -f $(EMPTY)/build
27− $(MAKE) $(EMPTY)/build
28−
29−$(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml src/**/*.hs test/**/*.hs | $(DIST)
30− $(STACK) $(STACK_FLAGS) build --no-run-tests --test
31− cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST)
32− touch $@
18+ $(HPACK)
3319
34−$(EMPTY)/stack-setup: | $(EMPTY)
35− $(STACK) $(STACK_FLAGS) setup
36− touch $@
20+$(CONFIGURE): $(CABAL_FILE)
21+ $(CABAL) $(CABAL_FLAGS) configure --enable-tests
3722
38−$(GHCID): $(EMPTY)/stack-setup | $(BIN)
39− $(STACK) $(STACK_FLAGS) install ghcid --local-bin-path $(BIN)
23+.PHONY: build
24+build $(DOC_TEST): $(CONFIGURE) default.nix
25+ $(CABAL) $(CABAL_FLAGS) build
4026
41−.PHONT: build
42−build: $(EMPTY)/build
43−
44−.PHONY: cabal-check
45−cabal-check: $(CABAL_FILE)
46− $(CABAL) check
27+.PHONY: check
28+check: $(CABAL_FILE)
29+ $(CABAL) $(CABAL_FLAGS) check
4730
4831.PHONY: clean
4932clean:
5033 rm -f $(CABAL_FILE)
51− rm -fr $(BIN)
34+ rm -f default.nix
5235 rm -fr $(DIST)
53− rm -fr $(EMPTY)
54− rm -fr $(STACK_WORK)
36+
37+default.nix: $(CABAL_FILE)
38+ cabal2nix . > $@
5539
5640.PHONY: sdist
57−sdist: cabal-check | $(DIST)
58− $(CABAL) sdist
41+sdist: check
42+ $(CABAL) $(CABAL_FLAGS) sdist
43+
44+.PHONY: shell
45+shell:
46+ $(NIX_SHELL) --pure $(NIX_SHELL_FLAGS)
5947
6048.PHONY: test
61−test: $(EMPTY)/build test-doc-test
49+test: test-doc-test
6250
6351.PHONY: test-doc-test
6452test-doc-test: $(DOC_TEST)
@@ -66,8 +54,8 @@ test-doc-test: $(DOC_TEST)
6654
6755.PHONY: upload-hackage
6856upload-hackage: sdist
69− @ $(CABAL) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz
57+ @ $(CABAL) $(CABAL_FLAGS) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz
7058
7159.PHONY: watch
72−watch: $(GHCID)
73− $(GHCID)
60+watch: $(CONFIGURE)
61+ $(GHCID) --command "cabal repl lib:$(PROJECT_NAME) $(GHCID_FLAGS)"
default.nixnew file+21
@@ -0,0 +1,21 @@
1+{ mkDerivation, aeson, base, bytestring, case-insensitive, hostname
2+, hspec, hspec-golden-aeson, http-client, http-conduit, http-types
3+, network, QuickCheck, stdenv, text, time, unordered-containers
4+, uuid
5+}:
6+mkDerivation {
7+ pname = "rollbar-hs";
8+ version = "0.3.1.0";
9+ src = ./.;
10+ libraryHaskellDepends = [
11+ aeson base bytestring case-insensitive hostname http-client
12+ http-conduit http-types network text time unordered-containers uuid
13+ ];
14+ testHaskellDepends = [
15+ aeson base bytestring case-insensitive hspec hspec-golden-aeson
16+ QuickCheck text unordered-containers
17+ ];
18+ homepage = "https://github.com/joneshf/rollbar-hs#readme";
19+ description = "Core Rollbar data types and APIs";
20+ license = stdenv.lib.licenses.bsd3;
21+}
shell.nixnew file+43
@@ -0,0 +1,43 @@
1+{ compiler ? "ghc822" }:
2+
3+let
4+
5+ default = haskell-packages.callPackage (import ./default.nix) {};
6+
7+ derivation = nixpkgs.haskell.lib.addBuildTools default tools;
8+
9+ haskell-packages = nixpkgs.haskell.packages.${compiler};
10+
11+ nixpkgs = import nixpkgs-tarball {};
12+
13+ nixpkgs-revision = "120b013e0c082d58a5712cde0a7371ae8b25a601";
14+
15+ nixpkgs-sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f";
16+
17+ nixpkgs-tarball = builtins.fetchTarball {
18+ sha256 = nixpkgs-sha256;
19+ url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgs-revision}.tar.gz";
20+ };
21+
22+ # Tools affected by the compiler version.
23+ tools-compiler = [
24+ haskell-packages.cabal-install
25+ haskell-packages.ghc
26+ haskell-packages.ghcid
27+ haskell-packages.hpack
28+ ];
29+
30+ # Tools that deal with the basic project infrastructure.
31+ tools-infrastructure = [
32+ nixpkgs.cabal2nix
33+ nixpkgs.curl
34+ ];
35+
36+ # All of the tools.
37+ tools =
38+ tools-compiler ++
39+ tools-infrastructure;
40+
41+in
42+
43+ derivation.env
stack.yamldeleted−66
@@ -1,66 +0,0 @@
1−# This file was automatically generated by 'stack init'
2−#
3−# Some commonly used options have been documented as comments in this file.
4−# For advanced use and comprehensive documentation of the format, please see:
5−# https://docs.haskellstack.org/en/stable/yaml_configuration/
6−
7−# Resolver to choose a 'specific' stackage snapshot or a compiler version.
8−# A snapshot resolver dictates the compiler version and the set of packages
9−# to be used for project dependencies. For example:
10−#
11−# resolver: lts-3.5
12−# resolver: nightly-2015-09-21
13−# resolver: ghc-7.10.2
14−# resolver: ghcjs-0.1.0_ghc-7.10.2
15−# resolver:
16−# name: custom-snapshot
17−# location: "./custom-snapshot.yaml"
18−resolver: lts-10.5
19−
20−# User packages to be built.
21−# Various formats can be used as shown in the example below.
22−#
23−# packages:
24−# - some-directory
25−# - https://example.com/foo/bar/baz-0.0.2.tar.gz
26−# - location:
27−# git: https://github.com/commercialhaskell/stack.git
28−# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
29−# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
30−# extra-dep: true
31−# subdirs:
32−# - auto-update
33−# - wai
34−#
35−# A package marked 'extra-dep: true' will only be built if demanded by a
36−# non-dependency (i.e. a user package), and its test suites and benchmarks
37−# will not be run. This is useful for tweaking upstream packages.
38−packages:
39−- .
40−# Dependency packages to be pulled from upstream that are not in the resolver
41−# (e.g., acme-missiles-0.3)
42−# extra-deps: []
43−
44−# Override default flag values for local packages and extra-deps
45−# flags: {}
46−
47−# Extra package databases containing global packages
48−# extra-package-dbs: []
49−
50−# Control whether we use the GHC we find on the path
51−# system-ghc: true
52−#
53−# Require a specific version of stack, using version ranges
54−# require-stack-version: -any # Default
55−# require-stack-version: ">=1.6"
56−#
57−# Override the architecture used by stack, especially useful on Windows
58−# arch: i386
59−# arch: x86_64
60−#
61−# Extra directories used by stack for building
62−# extra-include-dirs: [/path/to/dir]
63−# extra-lib-dirs: [/path/to/dir]
64−#
65−# Allow a newer minor version of GHC than the snapshot specifies
66−# compiler-check: newer-minor