-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
203 lines (180 loc) · 5.56 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
{
description = "Ava BASIC";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
zig-overlay.url = github:mitchellh/zig-overlay;
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
zig-overlay.inputs.flake-utils.follows = "flake-utils";
zls.url = github:zigtools/zls/0.13.0;
zls.inputs.nixpkgs.follows = "nixpkgs";
zls.inputs.flake-utils.follows = "flake-utils";
zls.inputs.zig-overlay.follows = "zig-overlay";
zls.inputs.gitignore.follows = "gitignore";
gitignore.url = github:hercules-ci/gitignore.nix;
gitignore.inputs.nixpkgs.follows = "nixpkgs";
niar = {
url = github:charlottia/niar;
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
zig-overlay,
gitignore,
...
} @ inputs:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
zig = zig-overlay.packages.${system}."0.13.0";
zls = inputs.zls.packages.${system}.zls;
gitignoreSource = gitignore.lib.gitignoreSource;
python = inputs.niar.packages.${system}.python;
niar = inputs.niar.packages.${system}.niar;
basic-deps = pkgs.callPackage ./basic/deps.nix {};
soc-deps = pkgs.callPackage ./soc/deps.nix {inherit python;};
adc-deps = pkgs.callPackage ./adc/deps.nix {};
python-de = with python.pkgs; [
python-lsp-server
pyls-isort
pylsp-rope
];
in rec {
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell {
name = "ava";
inputsFrom = [
devShells.zig
devShells.avasoc
];
};
packages.avabasic = pkgs.stdenvNoCC.mkDerivation {
name = "avabasic";
version = "main";
src = gitignoreSource ./basic;
nativeBuildInputs = [zig];
dontConfigure = true;
dontInstall = true;
doCheck = true;
buildPhase = ''
mkdir -p .cache
ln -s ${basic-deps} .cache/p
zig build install --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache -Doptimize=ReleaseSafe --prefix $out
'';
checkPhase = ''
zig build test --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache
'';
};
# TODO: zon2nix doesn't support path-based dependencies.
# packages.avacore = pkgs.stdenvNoCC.mkDerivation {
# name = "avacore";
# version = "main";
# src = gitignoreSource ./core;
# nativeBuildInputs = [
# zig
# pkgs.llvmPackages.bintools
# ];
# dontConfigure = true;
# dontInstall = true;
# doCheck = true;
# buildPhase = ''
# mkdir -p .cache
# zig build install --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache -Doptimize=ReleaseSafe --prefix $out
# '';
# checkPhase = ''
# zig build test --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache
# '';
# };
devShells.zig = pkgs.mkShell {
name = "zig";
nativeBuildInputs = [
zig
zls
pkgs.llvmPackages.bintools
# adc
pkgs.libiconv
pkgs.SDL2
pkgs.pkg-config # See shellHook.
];
shellHook = ''
# See https://github.com/ziglang/zig/issues/18998.
unset NIX_CFLAGS_COMPILE
unset NIX_LDFLAGS
'';
};
packages.avasoc = python.pkgs.buildPythonApplication {
name = "avasoc";
src = ./soc;
pyproject = true;
build-system = [python.pkgs.pdm-backend];
nativeBuildInputs = [pkgs.makeWrapper];
buildInputs = [];
propagatedBuildInputs = [
niar
soc-deps.amaranth-stdio
soc-deps.amaranth-soc
];
doCheck = true;
nativeCheckInputs = with python.pkgs; [
python.pkgs.pytestCheckHook
python.pkgs.pytest-xdist
packages.avabasic
];
postFixup = ''
wrapProgram $out/bin/avasoc \
--run 'export NIAR_WORKING_DIRECTORY="$(pwd)"'
'';
};
devShells.avasoc = pkgs.mkShell {
name = "avasoc";
buildInputs =
python-de
++ (with python.pkgs; [
pytest
pytest-xdist
soc-deps.pytest-watcher
zig
zls
]);
inputsFrom = [packages.avasoc];
};
devShells.avasoc-pdm = pkgs.mkShell {
name = "avasoc-pdm";
buildInputs =
python-de
++ [
pkgs.python3
pkgs.pdm
pkgs.yosys
pkgs.icestorm
pkgs.nextpnr
zig
zls
];
};
# TODO: zon2nix doesn't support path-based dependencies.
# packages.adc = pkgs.stdenvNoCC.mkDerivation {
# name = "adc";
# version = "main";
# src = gitignoreSource ./adc;
# nativeBuildInputs = [
# zig
# pkgs.libiconv
# ];
# dontConfigure = true;
# dontInstall = true;
# doCheck = true;
# buildPhase = ''
# mkdir -p .cache
# ln -s ${adc-deps} .cache/p
# zig build install --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache -Doptimize=ReleaseSafe --prefix $out
# '';
# checkPhase = ''
# zig build test --cache-dir $(pwd)/.zig-cache --global-cache-dir $(pwd)/.cache
# '';
# };
});
}