-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
161 lines (159 loc) · 5.22 KB
/
Copy pathflake.nix
File metadata and controls
161 lines (159 loc) · 5.22 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
description = "NMOO";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nim-src = {
url = "github:nim-lang/Nim/devel";
flake = false;
};
nim-csources = {
url = "github:nim-lang/csources_v3";
flake = false;
};
nim-checksums = {
url = "github:nim-lang/checksums";
flake = false;
};
nimony = {
url = "github:nim-lang/nimony";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
nim-src,
nim-checksums,
nim-csources,
nimony,
...
}:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems =
f:
nixpkgs.lib.genAttrs supportedSystems (
system:
f {
inherit system;
pkgs = import nixpkgs {
inherit system;
overlays = [
(self: super: {
nim-devel =
(super.nim.override {
nim-unwrapped = super.nim-unwrapped.overrideAttrs (o: {
version = "devel";
src = nim-src;
configurePhase =
let
bootstrapCompiler = super.stdenv.mkDerivation {
pname = "nim-bootstrap";
version = "3";
src = nim-csources;
installPhase = ''
mkdir -p $out/bin
install -m 755 bin/nim $out/bin/nim
'';
};
niftools = super.stdenv.mkDerivation {
pname = "niftools";
version = "3";
src = nimony;
# TODO; find a way to use bootstrap compiler
buildInputs = [ super.nim ];
buildPhase = ''
nim c -o:nifler --nimcache:nimcache -d:release --noNimblePath --skipUserCfg --skipParentCfg src/nifler/nifler.nim
nim c -o:nifmake --nimcache:nimcache -d:release --noNimblePath --skipUserCfg --skipParentCfg src/nifmake/nifmake.nim
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
install -m 755 nifler $out/bin/nifler
install -m 755 nifmake $out/bin/nifmake
runHook postInstall
'';
};
in
''
runHook preConfigure
mkdir dist
cp ${bootstrapCompiler}/bin/nim bin/
cp -r ${nim-checksums} dist/checksums
cp -r ${nimony} dist/nimony
cp ${niftools}/bin/nifler bin/nifler
cp ${niftools}/bin/nifmake bin/nifmake
ls bin
echo 'define:nixbuild' >> config/nim.cfg
echo 'nimcache:nimcache' >> config/nim.cfg
runHook postConfigure
'';
installPhase = ''
./koch geninstall
${o.installPhase}
'';
});
}).overrideAttrs
(o: {
version = "devel";
unpackPhase = ''
runHook preUnpack
mkdir nim-$version
cp -r ${self.nim-unwrapped}/nim/config nim-$version/config
chmod +w -R nim-$version
cd nim-$version
runHook postUnpack
'';
});
})
];
};
}
);
in
{
packages = forAllSystems (
{ pkgs, ... }:
let
fs = pkgs.lib.fileset;
in
{
default = pkgs.buildNimPackage {
pname = "nmoo";
version = "0.1.0";
src = fs.toSource {
root = ./.;
fileset = fs.unions [
./nmoo.nimble
./src
./config.nims
];
};
nimFlags = [
"-d:release"
"-d:danger"
];
lockFile = ./lock.json;
buildInputs = [ pkgs.libxcrypt ];
nativeBuildInputs = [ pkgs.pkg-config ];
};
}
);
devShells = forAllSystems (
{ pkgs, ... }: {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nim-devel
nimble
nimlangserver
libxcrypt
watchexec
gdb
valgrind
];
};
}
);
};
}