-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
88 lines (80 loc) · 2.75 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
{
description = "Advent of Code Haskell solutions";
inputs = {
nixpkgs.url = "nixpkgs/23.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
version = "1.0.0";
name = "advent-of-code-haskell";
pkgs = nixpkgs.legacyPackages.${system};
lib = nixpkgs.lib;
haskellPkgs = pkgs.haskell.packages.ghc925; # The version should match with resolver!
haskellLib = pkgs.haskell.lib;
requirements = pkgs.callPackage ./requirements.nix {};
devRequirements = with pkgs; [
stack-wrapped
cabal-install
custom-hls
haskellPkgs.ormolu
hlint
];
custom-hls = lib.trivial.pipe haskellPkgs.haskell-language-server [
fastBuild
hls925Fix
dynamicBuild
];
# https://github.com/NixOS/nixpkgs/blob/30d709aa1b9d620351fb457e6ed805a0d4908774/pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix#L76
hls925Fix = drv: haskellLib.compose.disableCabalFlag "fourmolu" (drv.override { hls-fourmolu-plugin = null; });
fastBuild = drv: drv.overrideScope (hself: hsuper: {
mkDerivation = args: hsuper.mkDerivation (args // {
doHaddock = false;
doCheck = false;
doBenchmark = false;
doCoverage = false;
enableLibraryProfiling = false;
});
});
dynamicBuild = drv: lib.trivial.pipe drv [
(haskellLib.compose.overrideCabal (old: {
enableSharedExecutables = true;
}))
(haskellLib.compose.enableCabalFlag "dynamic")
];
# https://docs.haskellstack.org/en/stable/nix_integration/#supporting-both-nix-and-non-nix-developers
stack-wrapped = pkgs.symlinkJoin {
name = "stack";
version = pkgs.stack.version;
paths = [ pkgs.stack ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--no-nix \
--system-ghc \
--no-install-ghc \
"
'';
};
in
{
defaultPackage = pkgs.stdenv.mkDerivation {
inherit name;
inherit version;
src = ./.;
installPhase = "echo 'dummy app'";
};
devShell = (pkgs.haskell.lib.buildStackProject {
inherit name;
inherit version;
ghc = haskellPkgs.ghc;
stack = stack-wrapped;
buildInputs = requirements;
}).overrideAttrs (final: prev: {
buildInputs = prev.buildInputs ++ devRequirements;
});
}
);
}