Fixing build system

main
Sam Hatfield 2020-08-12 23:58:48 -05:00
parent e7e51484f7
commit 74ae85f43a
Signed by: sehqlr
GPG Key ID: 7338CA919BC087F3
7 changed files with 43 additions and 35 deletions

2
.envrc
View File

@ -1 +1 @@
eval "$(lorri direnv)"
eval "$(lorri direnv)"

8
.gitignore vendored
View File

@ -1,8 +1,6 @@
dist-newstyle
*.cabal
*.nix
stack.yaml*
.stack-work
dist*
spell.cabal
shell.nix
result
cabal.project.local
test/dictionary.txt

View File

@ -1,36 +1,25 @@
PROJECT_NAME = spell
DICTIONARY_PATH = /usr/share/dict/american-english
GENERATED_FILES = $(PROJECT_NAME).cabal default.nix shell.nix test/dictionary.txt
NIX_RUN_PREFIX = nix run nixpkgs
CABAL2NIX_CMD = $(NIX_RUN_PREFIX).cabal2nix -c cabal2nix
CABAL_CMD = $(NIX_RUN_PREFIX).cabal-install -c cabal
HPACK_CMD = $(NIX_RUN_PREFIX).haskellPackages.hpack -c hpack
STACK_CMD = $(NIX_RUN_PREFIX).stack -c stack
GENERATED_FILES = spell.cabal default.nix test/dictionary.txt
.PHONY: build
build: $(PROJECT_NAME).cabal stack.yaml default.nix
$(CABAL_CMD) build
build: default.nix
nix build -f release.nix
.PHONY: generate
.PHONY: generate ungenerate
generate: $(GENERATED_FILES)
$(PROJECT_NAME).cabal: package.yaml
$(HPACK_CMD)
ungenerate:
rm $(GENERATED_FILES)
spell.cabal: package.yaml
hpack
default.nix: package.yaml
$(CABAL2NIX_CMD) . > $@
shell.nix: package.yaml
$(CABAL2NIX_CMD) --shell . > $@
cabal2nix . > $@
test/dictionary.txt:
cp $(DICTIONARY_PATH) $@
.PHONY: ungenerate
ungenerate:
rm $(GENERATED_FILES)
.PHONY: clean
clean:
cabal clean

View File

@ -1,11 +1,5 @@
# base-project: Haskell repo that builds in cabal, stack, and nix
# spell
## Generate files
`make generate`
This will generate cabal, stack, and nix files
# Multibuild
`make build` or just `make` will build the package with cabal, stack, and nix

23
default.nix Normal file
View File

@ -0,0 +1,23 @@
{ mkDerivation, array, base, criterion, hedgehog, hpack
, optparse-applicative, stdenv, tasty, tasty-hedgehog, tasty-th
, text
}:
mkDerivation {
pname = "spell";
version = "0.0.0.0";
src = ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [ array base text ];
libraryToolDepends = [ hpack ];
executableHaskellDepends = [
array base optparse-applicative text
];
testHaskellDepends = [
array base hedgehog tasty tasty-hedgehog tasty-th text
];
benchmarkHaskellDepends = [ array base criterion text ];
prePatch = "hpack";
description = "This is a Haskell project, by sehqlr";
license = stdenv.lib.licenses.bsd3;
}

View File

@ -16,9 +16,8 @@ category: Other
dependencies:
- base
- text
- array
- optparse-applicative
- text
library:
source-dirs: src
@ -33,6 +32,7 @@ executables:
- -with-rtsopts=-N
dependencies:
- spell
- optparse-applicative
benchmarks:
spell-benchmark:

4
release.nix Normal file
View File

@ -0,0 +1,4 @@
let pkgs = import <nixpkgs> {};
in
pkgs.haskellPackages.callPackage ./default.nix { }