-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
138 lines (134 loc) · 4.58 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
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
{
description = "A Flake for building coq and providing devShells for the coq-tinyram project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-doom-emacs.url = "github:nix-community/nix-doom-emacs";
emacs.url = "github:cmacrae/emacs";
};
outputs =
{ self
, nixpkgs
, emacs
, nix-doom-emacs
}:
with builtins;
let
compiler = "ghc884";
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# System types to support.
supportedSystems = [ "x86_64-linux" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
});
sharedBuildInputs = pkgs:
(with pkgs; [
ocaml
dune_2
coqPackages.coq
coqPackages.coq-ext-lib
coqPackages.ITree
])
++
(with pkgs.haskell.packages.${compiler}; [
ghc
cabal-install
]);
tinyram = system: nixpkgsFor.${system}.tinyram;
in
{
herculesCI.ciSystems = [ "x86_64-linux" ];
overlay = final: prev: {
tinyram-hs-src = final.stdenv.mkDerivation {
name = "tinyram-hs-src";
src = ./src;
buildInputs = sharedBuildInputs final;
buildPhase = ''
dune build
'';
installPhase = ''
mkdir -p $out
cp -r ./. $out
'';
};
tinyram-hs-src-2 = final.stdenv.mkDerivation {
name = "tinyram-hs-src-2";
src = final.tinyram-hs-src;
phases = ["unpackPhase" "installPhase"];
installPhase = ''
mkdir -p $out
cp -r ./. $out
cp ./_build/default/Tinyram_VM.hs $out/src
'';
};
tinyram = final.haskell.packages.${compiler}.callCabal2nix "coq-tinyram" final.tinyram-hs-src-2 {};
};
# the default devShell used when running `nix develop`
devShell = forAllSystems (system: self.devShells.${system}.defaultShell);
defaultPackage = forAllSystems tinyram;
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor."${system}";
in
{
# In case we don't want to provide an editor, this defaultShell will
# provide only coq packages we need.
defaultShell = pkgs.mkShell {
buildInputs = sharedBuildInputs pkgs;
};
# This is the defaultShell, but overriden to add one additional buildInput,
# vscodium!
vscodium = self.devShells.${system}.defaultShell.overrideAttrs (old: {
buildInputs =
let
vscodeWithCoq = pkgs.vscode-with-extensions.override {
vscode = pkgs.vscodium;
vscodeExtensions = pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "VSCoq";
publisher = "maximedenes";
version = "0.3.6";
sha256 = "sha256-b0gCaEzt5yAj53oLFZSXSD3bum9J1fYes/uf9+OlUek=";
}
{
name = "Haskell";
publisher = "haskell";
version = "2.1.3";
sha256 = "sha256-OWV8i1XPO1BUc66nIIKoJmzs0D95O0+FJE1hxpYqPBw=";
}
{
name = "language-haskell";
publisher = "justusadam";
version = "3.3.0";
sha256 = "sha256-2rlomc4qjca1Mv5lxgT/4AARzuG8e4kgshielpBeBYk=";
}
];
};
in
old.buildInputs
++ [
vscodeWithCoq
];
});
# This is the defaultShell, but overriden to add one additional buildInput,
# emacs!
emacs = self.devShells.${system}.defaultShell.overrideAttrs (old: {
buildInputs =
let
doom-emacsWithCoq = nix-doom-emacs.package.${system} {
doomPrivateDir = ./nix/doom.d;
};
in
old.buildInputs
++ [
doom-emacsWithCoq
];
});
});
};
}