-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathflake.nix
91 lines (80 loc) · 2.37 KB
/
flake.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
86
87
88
89
90
91
{
description = "Smoke";
inputs = {
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self
, flake-compat
, flake-utils
, nixpkgs
}:
flake-utils.lib.eachDefaultSystem (system:
let
ghcVersion = lib.strings.fileContents ./ghc.version;
ghcName = "ghc" + lib.strings.stringAsChars (c: if c == "." then "" else c) ghcVersion;
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) lib haskell;
inherit (haskell.lib) overrideCabal justStaticExecutables doStrip;
hsPkgs = haskell.packages.${ghcName};
# required libraries with static linking enabled
staticLibs = with pkgs; [
(gmp6.override { withStatic = true; })
(libffi.overrideAttrs (old: { dontDisableStatic = true; }))
(libiconv.overrideAttrs (old: { enableStatic = true; enableShared = false; }))
(openssl.override { static = true; })
zlib.static
];
smoke =
let
drv = hsPkgs.callCabal2nix "smoke" (pkgs.nix-gitignore.gitignoreSource [ ] ./.) {
# Override tar with the patched version; see stack.yaml for details.
tar = hsPkgs.tar_0_6_3_0;
};
in
haskell.lib.addExtraLibraries drv staticLibs;
in
{
packages.default = smoke;
apps.default = flake-utils.lib.mkApp {
drv = overrideCabal (justStaticExecutables (doStrip smoke)) {
enableSharedExecutables = false;
enableSharedLibraries = false;
};
};
formatter = pkgs.nixpkgs-fmt;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
coreutils
dos2unix
findutils
gnumake
gnused
nixpkgs-fmt
yq
# Haskell development
hsPkgs.haskell-language-server
hsPkgs.hlint
hsPkgs.hpack
hsPkgs.hspec-discover
hsPkgs.ormolu
stack
# testing
git
ruby
];
STACK_IN_NIX_SHELL = true;
};
devShells.lint = pkgs.mkShell {
buildInputs = with pkgs; [
hsPkgs.hlint
hsPkgs.hpack
hsPkgs.ormolu
];
STACK_IN_NIX_SHELL = true;
};
});
}