-
Notifications
You must be signed in to change notification settings - Fork 118
/
default.nix
109 lines (88 loc) · 2.64 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
# This is a NIX shell script to install the dependencies required by DDlog,
# but unfortunately it has not been kept up-to-date.
{ ghc ? null
, pkgs ? import <nixpkgs> { }
, buildStatic ? true
} @ args:
let
ghc = args.ghc or pkgs.haskell.compiler.ghc865Binary;
java = pkgs.adoptopenjdk-bin;
rust-toolchain = "1.52.1";
lib = pkgs.lib;
flatbuffers-java = pkgs.runCommand "flatbuffers-java" {
buildInputs = [ java ];
} ''
mkdir -p $out
cp -r ${pkgs.flatbuffers.src}/java $out/
chmod -R +w $out/java
javac $out/java/com/google/flatbuffers/*.java
rm -rf $out/java/com/google/flatbuffers/*.java
'';
stack-shell = pkgs.haskell.lib.buildStackProject {
inherit ghc;
name = "stack-shell";
CLASSPATH = "${flatbuffers-java}/java";
shellHook = ''
export PATH="$HOME/.local/bin:$PATH"
'';
nativeBuildInputs = lib.optional buildStatic [
pkgs.glibc
pkgs.glibc.static
pkgs.pkgsStatic.gmp
pkgs.pkgsStatic.libffi
];
buildInputs = [
pkgs.flatbuffers
pkgs.zlib
java
pkgs.gitMinimal
pkgs.rustup
pkgs.cacert
];
};
dev-shell = stack-shell.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [
pkgs.stack
pkgs.go
];
shellHook = (old.shellHook or "") + ''
export GOCACHE=$TMPDIR/go-cache
export GOPATH="$TMPDIR/go"
mkdir -p "''${GOPATH}/pkg/mod/cache/download"
unset STACK_IN_NIX_SHELL
alias stack="stack --nix-shell-file ${builtins.toPath ./.}/tools/stack-shell.nix --nix-pure --no-install-ghc --skip-ghc-check"
function initial-setup {
rustup default ${rust-toolchain}
stack build
stack install
}
function ddlog-run {
local program="$1"
local program_noext=''${program%.*}
if [ ! -f "$program" ]; then
>&2 echo "You are trying to run $program, but it does not exist"
return
fi
local input_file="$2"
if [ -z "$input_file" ]; then
local dat_name="$program_noext.dat"
if [ -f "$dat_name" ]; then
>&2 echo "Using $dat_name as an input file"
input_file="$dat_name"
fi
fi
ddlog -i "$program" -L '${builtins.toPath ./lib}' || return
(cd "''${program_noext}_ddlog" && cargo build --release)
if [ -z "$input_file" ]; then
"''${program_noext}_ddlog/target/release/$(basename "$program_noext")_cli"
else
"''${program_noext}_ddlog/target/release/$(basename "$program_noext")_cli" --no-print < "$input_file"
fi
}
'';
});
in dev-shell // {
inherit
stack-shell
;
}