Skip to content

Commit 7fec317

Browse files
authored
Merge pull request #127 from srid/project-module-test
Add test for verifying default project modules
2 parents 6256c9f + c8cdbba commit 7fec317

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

runtest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ TESTS=(
1313
./test/simple
1414
./test/hpack
1515
./test/with-subdir
16+
./test/project-module
1617
./doc
1718
)
1819

test/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# haskell-flake tests
2+
3+
The following tests are available:
4+
5+
| Directory | Description |
6+
| --- | --- |
7+
| `simple/` | Basic functionalities |
8+
| `hpack` | `hpack` support |
9+
| `with-subdir` | Prevent redundant rebuilds when parent contents change |
10+
| `project-module`| Default project modules are generated correctly |
11+

test/project-module/flake.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 = { };
7+
flake-parts = { };
8+
haskell-flake = { };
9+
10+
haskell-multi-nix.url = "github:srid/haskell-multi-nix/d6ac6ccab559f886d1fc7da8cab44b99cb0c2c3d";
11+
haskell-multi-nix.inputs.haskell-flake.follows = "haskell-flake";
12+
haskell-multi-nix.inputs.nixpkgs.follows = "nixpkgs";
13+
haskell-multi-nix.inputs.flake-parts.follows = "flake-parts";
14+
};
15+
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
16+
flake-parts.lib.mkFlake { inherit inputs; } {
17+
systems = nixpkgs.lib.systems.flakeExposed;
18+
imports = [
19+
inputs.haskell-flake.flakeModule
20+
];
21+
perSystem = { self', pkgs, ... }: {
22+
haskellProjects.default = {
23+
imports = [ inputs.haskell-multi-nix.haskellFlakeProjectModules.output ];
24+
};
25+
packages.default = self'.packages.haskell-flake-test;
26+
};
27+
};
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cabal-version: 3.0
2+
name: haskell-flake-test
3+
version: 0.1.0.0
4+
license: NONE
5+
author: Joe
6+
maintainer: [email protected]
7+
build-type: Simple
8+
9+
common warnings
10+
ghc-options: -Wall
11+
12+
executable haskell-flake-test
13+
import: warnings
14+
main-is: Main.hs
15+
build-depends:
16+
base,
17+
foo
18+
hs-source-dirs: src
19+
default-language: Haskell2010

test/project-module/src/Main.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Main where
2+
3+
import Foo
4+
5+
main :: IO ()
6+
main = do
7+
fooFunc

test/project-module/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_ALL}
7+
8+
logHeader "Testing nix devshell"
9+
nix develop ${OVERRIDE_ALL} -c echo

0 commit comments

Comments
 (0)