Skip to content

Commit 70359f1

Browse files
committed
Add test for hpack support
1 parent b47c956 commit 70359f1

File tree

6 files changed

+63
-0
lines changed

6 files changed

+63
-0
lines changed

runtest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ TESTS=(
1111
./nix/find-haskell-paths
1212
./example
1313
./test/simple
14+
./test/hpack
1415
./test/with-subdir
1516
./doc
1617
)

test/hpack/flake.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
# Since there is no flake.lock file (to avoid incongruent haskell-flake
3+
# pinning), we must specify revisions for *all* inputs to ensure
4+
# reproducibility.
5+
inputs = {
6+
nixpkgs.url = "github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7";
7+
flake-parts.url = "github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f";
8+
9+
# We do not specify a value for this input, because it is explicitly
10+
# specified using --override-input to point to ../. For example,
11+
# `nix build --override-input haskell-flake ..`
12+
haskell-flake = { };
13+
};
14+
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
15+
flake-parts.lib.mkFlake { inherit inputs; } {
16+
systems = nixpkgs.lib.systems.flakeExposed;
17+
imports = [
18+
inputs.haskell-flake.flakeModule
19+
];
20+
perSystem = { self', pkgs, ... }: {
21+
haskellProjects.default = { };
22+
# haskell-flake doesn't set the default package, but you can do it here.
23+
packages.default = self'.packages.haskell-flake-test;
24+
};
25+
};
26+
}

test/hpack/package.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: haskell-flake-test
2+
version: 0.1.0.0
3+
license: NONE
4+
author: Joe
5+
maintainer: [email protected]
6+
7+
ghc-options:
8+
- -Wall
9+
10+
default-language: Haskell2010
11+
12+
executables:
13+
haskell-flake-test:
14+
main: Main.hs
15+
dependencies:
16+
- base
17+
source-dirs: src

test/hpack/script

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Toml.Type.Value (Value(Bool))
2+
3+
main :: IO ()
4+
main = do
5+
putStrLn ("I depend on the `tomland` package. Here's a TOML-flavored boolean: " <> show (Bool True))

test/hpack/src/Main.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main where
2+
3+
main :: IO ()
4+
main = do
5+
putStrLn "Hello world, from hpack test"

test/hpack/test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source ../common.sh
2+
set -euxo pipefail
3+
4+
# First, build the flake
5+
logHeader "Testing nix build"
6+
nix build ${OVERRIDE_HASKELL_FLAKE}
7+
# Run the devshell test script in a nix develop shell.
8+
logHeader "Testing nix devshell"
9+
nix develop ${OVERRIDE_HASKELL_FLAKE} -c echo

0 commit comments

Comments
 (0)