This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
shell.nix
85 lines (77 loc) · 2.26 KB
/
shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
let
packages = import ./.;
inherit (packages) pkgs dex easy-purescript-nix;
inherit (pkgs) lib stdenv utillinux python3 nixpkgs-fmt;
inherit (dex) haskell pre-commit-hooks-nix stylish-haskell purty-pre-commit;
inherit (easy-purescript-nix) purs spago zephyr purty;
# Configure project pre-commit hooks
pre-commit-check = pre-commit-hooks-nix.run {
src = ./.;
tools = {
stylish-haskell = stylish-haskell;
nixpkgs-fmt = nixpkgs-fmt;
shellcheck = pkgs.shellcheck;
purty = purty-pre-commit;
};
hooks = {
purty.enable = true;
stylish-haskell.enable = true;
hlint.enable = true;
nixpkgs-fmt = {
enable = true;
# While nixpkgs-fmt does exclude patterns specified in `.ignore` this
# does not appear to work inside the hook. For now we have to thus
# maintain excludes here *and* in `./.ignore` and *keep them in sync*.
excludes = [ ".*nix/sources.nix$" ".*/packages.nix$" ];
};
shellcheck.enable = true;
png-optimization = {
enable = true;
name = "png-optimization";
description = "Ensure that PNG files are optimized";
entry = "${pkgs.optipng}/bin/optipng";
files = "\\.png$";
};
};
};
nixpkgsInputs = (with pkgs;
[
libsodium-vrf
xz
ghcid
niv
nixpkgs-fmt
nodejs-14_x
z3
zlib
nodePackages.parcel-bundler
] ++ lib.optionals stdenv.isDarwin [ clang ]);
localInputs = (with dex; [
hlint
cabal-install
haskell-language-server
stylish-haskell
purs
spago
zephyr
purty
]);
devInputs = (with pkgs; [ haskellPackages.hasktags haskellPackages.hpc ]);
in
haskell.project.shellFor {
withHoogle = false;
shellHook = ''
${pre-commit-check.shellHook}
''
# Work around https://github.com/NixOS/nix/issues/3345, which makes
# tests etc. run single-threaded in a nix-shell.
# Sets the affinity to cores 0-1000 for $$ (current PID in bash)
# Only necessary for linux - darwin doesn't even expose thread
# affinity APIs!
+ lib.optionalString stdenv.isLinux ''
${utillinux}/bin/taskset -pc 0-1000 $$
'' + ''
export PATH=$(pwd)/.ghcup/bin:$PATH
'';
nativeBuildInputs = nixpkgsInputs ++ localInputs ++ devInputs;
}