-
Notifications
You must be signed in to change notification settings - Fork 24
/
shell.nix
66 lines (47 loc) · 1.2 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
{ nixpkgsPath ? <nixpkgs>
, overlays ? []
, compiler ? "default"
, opengl ? false
, demo ? true
}:
/* Usage:
A.
cabal clean
nix-build shell.nix
fltkhs-buttons
B.
nix-shell
cabal clean
cabal configure
cabal build
cabal run fltkhs-buttons
C.
nix-shell --arg opengl 'true'
cabal clean
cabal configure -fopengl
cabal build
cabal run fltkhs-example-opengl
*/
/*
This file is written manually, not generated automatically,
to lift the package's `.cabal` flags into `.nix` flags.
*/
let
# defaultNixpkgs = import nixpkgsPath {};
customNixpkgs = import nixpkgsPath { inherit overlays; };
# by default:
# customNixpkgs = import <nixpkgs> {};
/*
$ echo $NIX_PATH
nixpkgs=/home/sboo/.nix-defexpr/channels/nixpkgs
*/
inherit (customNixpkgs) pkgs;
flags = { cabalFlags = { inherit demo opengl; }; };
# same names/defaults as the `.cabal` flags
f = import ./default.nix;
haskellPackages = if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
drv = haskellPackages.callPackage f flags;
in
if pkgs.lib.inNixShell then drv.env else drv