blob: 373a1d38889e24278e6a09fa5a4010979bc5c3f3 (
plain) (
blame)
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
|
{ lib
, python3
, fetchFromGitHub
, sdcc
, yosys
, icestorm
, nextpnr
, unstableGitUpdater
}:
python3.pkgs.buildPythonApplication rec {
pname = "glasgow";
version = "0-unstable-2024-06-27";
# from `pdm show`
realVersion = let
tag = builtins.elemAt (lib.splitString "-" version) 0;
rev = lib.substring 0 7 src.rev;
in "${tag}.1.dev2085+g${rev}";
pyproject = true;
src = fetchFromGitHub {
owner = "GlasgowEmbedded";
repo = "glasgow";
rev = "a599e3caa64c2e445358894fd050e16917f2ee42";
sha256 = "sha256-5qg0/j1MgwHMOjySBY5cKuQqlqltV5cXcR/Ap6J9vys=";
};
nativeBuildInputs = [
python3.pkgs.pdm-backend
sdcc
];
propagatedBuildInputs = with python3.pkgs; [
typing-extensions
amaranth
packaging
platformdirs
fx2
libusb1
pyvcd
aiohttp
];
nativeCheckInputs = [
python3.pkgs.unittestCheckHook
yosys
icestorm
nextpnr
];
enableParallelBuilding = true;
preBuild = ''
make -C firmware LIBFX2=${python3.pkgs.fx2}/share/libfx2
cp firmware/glasgow.ihex software/glasgow
cd software
export PDM_BUILD_SCM_VERSION="${realVersion}"
'';
# installCheck tries to build_ext again
doInstallCheck = false;
postInstall = ''
mkdir -p $out/etc/udev/rules.d
cp $src/config/*.rules $out/etc/udev/rules.d
'';
preCheck = ''
export PYTHONWARNINGS="ignore::DeprecationWarning"
# tests attempt to cache bitstreams
# for linux:
export XDG_CACHE_HOME=$TMPDIR
# for darwin:
export HOME=$TMPDIR
'';
makeWrapperArgs = [
"--set" "YOSYS" "${yosys}/bin/yosys"
"--set" "ICEPACK" "${icestorm}/bin/icepack"
"--set" "NEXTPNR_ICE40" "${nextpnr}/bin/nextpnr-ice40"
];
passthru.updateScript = unstableGitUpdater {
hardcodeZeroVersion = true;
};
meta = with lib; {
description = "Software for Glasgow, a digital interface multitool";
homepage = "https://github.com/GlasgowEmbedded/Glasgow";
license = licenses.bsd0;
maintainers = with maintainers; [ thoughtpolice ];
mainProgram = "glasgow";
};
}
|