mirror of
https://github.com/typeable/rollbar-hs.git
synced 2024-07-14 17:10:36 +03:00
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.
This commit is contained in:
parent
4a7a221ace
commit
79f82a54ac
74
Makefile
74
Makefile
@ -1,64 +1,52 @@
|
||||
BIN ?= bin
|
||||
CABAL ?= cabal
|
||||
CABAL_FLAGS ?=
|
||||
DIST ?= dist
|
||||
EMPTY ?= .make
|
||||
PROJECT_NAME ?= rollbar-hs
|
||||
STACK ?= stack
|
||||
STACK_WORK ?= .stack-work
|
||||
VERBOSITY ?= warn
|
||||
GHCID ?= ghcid
|
||||
GHCID_FLAGS ?= --ghc-options=-fno-code
|
||||
HPACK ?= hpack
|
||||
NIX_SHELL ?= nix-shell
|
||||
NIX_SHELL_FLAGS ?=
|
||||
PROJECT_NAME := rollbar-hs
|
||||
|
||||
CABAL_FILE := $(PROJECT_NAME).cabal
|
||||
CONFIGURE := $(DIST)/setup-config
|
||||
DOC_TEST := $(DIST)/build/doc-test/doc-test
|
||||
GHCID := $(BIN)/ghcid
|
||||
STACK_FLAGS := --verbosity $(VERBOSITY)
|
||||
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
$(BIN) $(DIST) $(EMPTY):
|
||||
mkdir -p $@
|
||||
|
||||
$(CABAL_FILE): package.yaml
|
||||
# `stack` has no way to run `hpack` directly.
|
||||
# We can run `hpack` indirectly with little overhead.
|
||||
$(STACK) $(STACK_FLAGS) build --dry-run
|
||||
$(HPACK)
|
||||
|
||||
$(DOC_TEST):
|
||||
rm -f $(EMPTY)/build
|
||||
$(MAKE) $(EMPTY)/build
|
||||
$(CONFIGURE): $(CABAL_FILE)
|
||||
$(CABAL) $(CABAL_FLAGS) configure --enable-tests
|
||||
|
||||
$(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml src/**/*.hs test/**/*.hs | $(DIST)
|
||||
$(STACK) $(STACK_FLAGS) build --no-run-tests --test
|
||||
cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST)
|
||||
touch $@
|
||||
.PHONY: build
|
||||
build $(DOC_TEST): $(CONFIGURE) default.nix
|
||||
$(CABAL) $(CABAL_FLAGS) build
|
||||
|
||||
$(EMPTY)/stack-setup: | $(EMPTY)
|
||||
$(STACK) $(STACK_FLAGS) setup
|
||||
touch $@
|
||||
|
||||
$(GHCID): $(EMPTY)/stack-setup | $(BIN)
|
||||
$(STACK) $(STACK_FLAGS) install ghcid --local-bin-path $(BIN)
|
||||
|
||||
.PHONT: build
|
||||
build: $(EMPTY)/build
|
||||
|
||||
.PHONY: cabal-check
|
||||
cabal-check: $(CABAL_FILE)
|
||||
$(CABAL) check
|
||||
.PHONY: check
|
||||
check: $(CABAL_FILE)
|
||||
$(CABAL) $(CABAL_FLAGS) check
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(CABAL_FILE)
|
||||
rm -fr $(BIN)
|
||||
rm -f default.nix
|
||||
rm -fr $(DIST)
|
||||
rm -fr $(EMPTY)
|
||||
rm -fr $(STACK_WORK)
|
||||
|
||||
default.nix: $(CABAL_FILE)
|
||||
cabal2nix . > $@
|
||||
|
||||
.PHONY: sdist
|
||||
sdist: cabal-check | $(DIST)
|
||||
$(CABAL) sdist
|
||||
sdist: check
|
||||
$(CABAL) $(CABAL_FLAGS) sdist
|
||||
|
||||
.PHONY: shell
|
||||
shell:
|
||||
$(NIX_SHELL) --pure $(NIX_SHELL_FLAGS)
|
||||
|
||||
.PHONY: test
|
||||
test: $(EMPTY)/build test-doc-test
|
||||
test: test-doc-test
|
||||
|
||||
.PHONY: test-doc-test
|
||||
test-doc-test: $(DOC_TEST)
|
||||
@ -66,8 +54,8 @@ test-doc-test: $(DOC_TEST)
|
||||
|
||||
.PHONY: upload-hackage
|
||||
upload-hackage: sdist
|
||||
@ $(CABAL) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz
|
||||
@ $(CABAL) $(CABAL_FLAGS) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz
|
||||
|
||||
.PHONY: watch
|
||||
watch: $(GHCID)
|
||||
$(GHCID)
|
||||
watch: $(CONFIGURE)
|
||||
$(GHCID) --command "cabal repl lib:$(PROJECT_NAME) $(GHCID_FLAGS)"
|
||||
|
21
default.nix
Normal file
21
default.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ mkDerivation, aeson, base, bytestring, case-insensitive, hostname
|
||||
, hspec, hspec-golden-aeson, http-client, http-conduit, http-types
|
||||
, network, QuickCheck, stdenv, text, time, unordered-containers
|
||||
, uuid
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "rollbar-hs";
|
||||
version = "0.3.1.0";
|
||||
src = ./.;
|
||||
libraryHaskellDepends = [
|
||||
aeson base bytestring case-insensitive hostname http-client
|
||||
http-conduit http-types network text time unordered-containers uuid
|
||||
];
|
||||
testHaskellDepends = [
|
||||
aeson base bytestring case-insensitive hspec hspec-golden-aeson
|
||||
QuickCheck text unordered-containers
|
||||
];
|
||||
homepage = "https://github.com/joneshf/rollbar-hs#readme";
|
||||
description = "Core Rollbar data types and APIs";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
43
shell.nix
Normal file
43
shell.nix
Normal file
@ -0,0 +1,43 @@
|
||||
{ compiler ? "ghc822" }:
|
||||
|
||||
let
|
||||
|
||||
default = haskell-packages.callPackage (import ./default.nix) {};
|
||||
|
||||
derivation = nixpkgs.haskell.lib.addBuildTools default tools;
|
||||
|
||||
haskell-packages = nixpkgs.haskell.packages.${compiler};
|
||||
|
||||
nixpkgs = import nixpkgs-tarball {};
|
||||
|
||||
nixpkgs-revision = "120b013e0c082d58a5712cde0a7371ae8b25a601";
|
||||
|
||||
nixpkgs-sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f";
|
||||
|
||||
nixpkgs-tarball = builtins.fetchTarball {
|
||||
sha256 = nixpkgs-sha256;
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgs-revision}.tar.gz";
|
||||
};
|
||||
|
||||
# Tools affected by the compiler version.
|
||||
tools-compiler = [
|
||||
haskell-packages.cabal-install
|
||||
haskell-packages.ghc
|
||||
haskell-packages.ghcid
|
||||
haskell-packages.hpack
|
||||
];
|
||||
|
||||
# Tools that deal with the basic project infrastructure.
|
||||
tools-infrastructure = [
|
||||
nixpkgs.cabal2nix
|
||||
nixpkgs.curl
|
||||
];
|
||||
|
||||
# All of the tools.
|
||||
tools =
|
||||
tools-compiler ++
|
||||
tools-infrastructure;
|
||||
|
||||
in
|
||||
|
||||
derivation.env
|
66
stack.yaml
66
stack.yaml
@ -1,66 +0,0 @@
|
||||
# This file was automatically generated by 'stack init'
|
||||
#
|
||||
# Some commonly used options have been documented as comments in this file.
|
||||
# For advanced use and comprehensive documentation of the format, please see:
|
||||
# https://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||
|
||||
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
|
||||
# A snapshot resolver dictates the compiler version and the set of packages
|
||||
# to be used for project dependencies. For example:
|
||||
#
|
||||
# resolver: lts-3.5
|
||||
# resolver: nightly-2015-09-21
|
||||
# resolver: ghc-7.10.2
|
||||
# resolver: ghcjs-0.1.0_ghc-7.10.2
|
||||
# resolver:
|
||||
# name: custom-snapshot
|
||||
# location: "./custom-snapshot.yaml"
|
||||
resolver: lts-10.5
|
||||
|
||||
# User packages to be built.
|
||||
# Various formats can be used as shown in the example below.
|
||||
#
|
||||
# packages:
|
||||
# - some-directory
|
||||
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
|
||||
# - location:
|
||||
# git: https://github.com/commercialhaskell/stack.git
|
||||
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
|
||||
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
|
||||
# extra-dep: true
|
||||
# subdirs:
|
||||
# - auto-update
|
||||
# - wai
|
||||
#
|
||||
# A package marked 'extra-dep: true' will only be built if demanded by a
|
||||
# non-dependency (i.e. a user package), and its test suites and benchmarks
|
||||
# will not be run. This is useful for tweaking upstream packages.
|
||||
packages:
|
||||
- .
|
||||
# Dependency packages to be pulled from upstream that are not in the resolver
|
||||
# (e.g., acme-missiles-0.3)
|
||||
# extra-deps: []
|
||||
|
||||
# Override default flag values for local packages and extra-deps
|
||||
# flags: {}
|
||||
|
||||
# Extra package databases containing global packages
|
||||
# extra-package-dbs: []
|
||||
|
||||
# Control whether we use the GHC we find on the path
|
||||
# system-ghc: true
|
||||
#
|
||||
# Require a specific version of stack, using version ranges
|
||||
# require-stack-version: -any # Default
|
||||
# require-stack-version: ">=1.6"
|
||||
#
|
||||
# Override the architecture used by stack, especially useful on Windows
|
||||
# arch: i386
|
||||
# arch: x86_64
|
||||
#
|
||||
# Extra directories used by stack for building
|
||||
# extra-include-dirs: [/path/to/dir]
|
||||
# extra-lib-dirs: [/path/to/dir]
|
||||
#
|
||||
# Allow a newer minor version of GHC than the snapshot specifies
|
||||
# compiler-check: newer-minor
|
Loading…
Reference in New Issue
Block a user