This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
158 lines (134 loc) · 3.76 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
{
description = "Development shell for sh1107";
inputs = {
flake-utils.url = github:numtide/flake-utils;
hdx = {
url = github:charlottia/hdx?ref=stripped;
inputs.flake-utils.follows = "flake-utils";
};
nixpkgs.follows = "hdx/nixpkgs";
zig = {
url = github:mitchellh/zig-overlay;
inputs.nixpkgs.follows = "hdx/nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = inputs @ {
self,
nixpkgs,
flake-utils,
...
}: let
overlays = [
(final: prev: {
hdx = inputs.hdx.packages.${prev.system};
zig-overlay = inputs.zig.packages.${prev.system};
})
];
in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit overlays system;};
hdx = pkgs.hdx.default;
inherit (pkgs) lib;
inherit (hdx) python;
zig =
if pkgs.stdenv.isDarwin
then pkgs.zig-overlay.master
else pkgs.zig;
in rec {
formatter = pkgs.alejandra;
packages.default = python.pkgs.buildPythonPackage {
name = "sh1107";
format = "pyproject";
src = ./.;
nativeBuildInputs = builtins.attrValues {
inherit
(python.pkgs)
setuptools
black
# isort
# python-lsp-server
;
inherit
(pkgs.nodePackages)
pyright
;
inherit
(pkgs)
dfu-util
;
inherit
hdx
zig
;
};
#// lib.optionalAttrs (pkgs.stdenv.isDarwin) {
# XXX To use frameworks included below.
# inherit (pkgs.darwin.apple_sdk_11_0) xcodebuild;
#});
buildInputs =
builtins.attrValues {
inherit
(pkgs)
SDL2
iconv
;
inherit zig;
}
# XXX I'm getting issues linking against system (?) QuickLook/QuickLookUI, and I just
# cbf. Impure all frameworks against system for now.
# ++ lib.optionals (pkgs.stdenv.isDarwin) (with pkgs.darwin.apple_sdk_11_0.frameworks; [
# # CoreHaptics XXX
# AppKit
# AudioToolbox
# Carbon
# Cocoa
# CoreAudio
# CoreGraphics
# CoreVideo
# ForceFeedback
# Foundation
# GameController
# IOKit
# Metal
# MetalKit
# OpenGL
# Quartz
# QuartzCore
# QuickLook
# ])
;
dontAddExtraLibs = true;
preBuild = ''
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig"
'';
doCheck = true;
pythonImportsCheck = ["sh1107"];
checkPhase = ''
BOARDS=( icebreaker orangecrab )
SPEEDS=( 100000 400000 )
export CI=1
set -euo pipefail
echo "--- Unit tests."
python -m sh1107 test
for board in "''${BOARDS[@]}"; do
for speed in "''${SPEEDS[@]}"; do
echo "--- Building $board @ $speed."
python -m sh1107 build "$board" -s "$speed"
done
done
for opts in "-c" "-cfi"; do
echo "--- Building Virtual SH1107 ($opts)."
python -m sh1107 vsh "$opts"
# On Darwin, nix build may appear to fail, but the binary output looks OK.
# A true failure would exit non-zero?
done
echo "--- Formal verification."
python -m sh1107 formal
echo "--- All passed."
'';
};
checks.default = packages.default;
devShells.default = packages.default;
});
}