-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
146 lines (131 loc) · 4.37 KB
/
default.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright : (c) 2022 Composewell Technologies
#
# CAUTION! a spelling mistake in arg string is ignored silently.
#
# To use a specific ghc version:
# nix-shell --argstr compiler "ghc943"
# nix-shell --arg editors true --arg hoogle true
{
nixpkgs ?
import (builtins.fetchTarball
https://github.com/NixOS/nixpkgs/archive/refs/tags/22.11.tar.gz)
# 23.05-pre
#https://github.com/NixOS/nixpkgs/archive/b68bd2e.tar.gz)
# Unfree for some vscode extensions
{ config.allowUnfree = true;
}
, compiler ? "default"
, editors ? true
, haskell-tools ? true
, hoogle ? true
, all ? false
}:
let
#------------------------------------------------------------------------------
# Packages available in the nix shell
#------------------------------------------------------------------------------
haskellLibDeps =
with hpkgs;
[ # Streamly packages
fusion-plugin
streamly-core
streamly
#streamly-bytestring
streamly-examples
streamly-coreutils
#streamly-lz4
streamly-metrics
streamly-process
streamly-shell
streamly-statistics
# Additional packages
hspec
tasty-bench
ghczdecode
];
vimCfg = import nix/vim/vim.nix {nixpkgs = nixpkgs;};
vscodium =
nixpkgs.pkgs.vscode-with-extensions.override
{ vscode = nixpkgs.pkgs.vscodium;
vscodeExtensions =
with nixpkgs.pkgs.vscode-extensions;
# Extensions from
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vscode/extensions/default.nix
[
# Needs to be installed explicitly for haskell.haskell to work
justusadam.language-haskell
haskell.haskell
#ms-vscode-remote.remote-ssh # unfree
]
# Extensions from marketplace
++ nixpkgs.pkgs.vscode-utils.extensionsFromVscodeMarketplace
[
#{
# name = "";
# publisher = "";
# version = "";
# sha256 = "";
#}
];
};
otherPackages =
[ nixpkgs.pkgs.cabal-install
nixpkgs.pkgs.par # paragraph formatting for vim
nixpkgs.pkgs.powerline-fonts # for vim status line
vimCfg.nvimCustom
] ++
( if (all || haskell-tools)
then
[ #nixpkgs.pkgs.hlint
#nixpkgs.haskellPackages.fourmolu
#nixpkgs.pkgs.ghcid
hpkgs.haskell-language-server
] else []
) ++
( if (all || editors)
then [ vscodium ]
else []
);
#------------------------------------------------------------------------------
# Generic stuff
#------------------------------------------------------------------------------
haskellPackages =
(import ./nix/haskellPackages.nix)
{ inherit nixpkgs;
inherit compiler;
};
hpkgs =
haskellPackages.override (old: {
overrides =
nixpkgs.lib.composeExtensions
(old.overrides or (_: _: {}))
(with nixpkgs.haskell.lib; self: super: {
# Add local packages here
# XXX Uses src = null, need to fix
#streamly = local super "streamly" ./. flags inShell;
});
});
# A fake package to add some additional deps to the shell env
additionalDeps = hpkgs.mkDerivation rec {
version = "0.1";
pname = "streamly-additional";
license = "BSD-3-Clause";
libraryHaskellDepends = haskellLibDeps;
setupHaskellDepends = with hpkgs; [
cabal-doctest
];
executableFrameworkDepends = with hpkgs;
# XXX On macOS cabal2nix does not seem to generate a
# dependency on Cocoa framework.
if builtins.currentSystem == "x86_64-darwin"
then [nixpkgs.darwin.apple_sdk.frameworks.Cocoa]
else [];
};
utils =
(import ./nix/utils.nix)
{ inherit nixpkgs; };
in if nixpkgs.lib.inNixShell
then
utils.mkShell
hpkgs (p: [additionalDeps]) otherPackages (all || hoogle) true
else abort "nix-shell only please!"