-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
80 lines (68 loc) · 2.19 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
{
description = "My Haskell project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems =
[ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
forAllSystems =
nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
});
haskellPackages = system:
nixpkgsFor.${system}.haskellPackages;
packageName = system: with builtins;
let
cabalFileName =
let
cabalFiles =
((filter ((nixpkgsFor.${system}).lib.hasSuffix ".cabal")) (attrNames (readDir ./.)));
in
head cabalFiles;
matches =
(match "^.*name\:\ *([^[:space:]]*).*$" (readFile "${./.}\/${cabalFileName}"));
in
head matches;
in
{
packages =
forAllSystems (system:
let
pkgs =
nixpkgsFor.${system};
in
{
default =
# (haskellPackages system).callCabal2nix (packageName system) self {};
import ./default.nix ((haskellPackages system) // { lib = pkgs.lib; SDL = pkgs.SDL; });
}
);
devShell =
forAllSystems (system:
let
pkgs =
nixpkgsFor.${system};
in
(haskellPackages system).shellFor {
# The packages that the shell is for.
packages = p: [
self.packages.${system}.default
];
buildInputs = with (haskellPackages system);
[ haskell-language-server
cabal-install
pkgs.SDL
pkgs.SDL.dev
];
# Add build inputs of the following derivations.
inputsFrom = [ ];
# Enables Hoogle for the builtin packages.
withHoogle = true;
}
);
};
}