2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2023-03-04 12:14:45 +00:00
|
|
|
, python3
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, sdcc
|
|
|
|
, yosys
|
|
|
|
, icestorm
|
|
|
|
, nextpnr
|
|
|
|
}:
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "glasgow";
|
2024-07-03 19:18:45 +00:00
|
|
|
version = "unstable-2024-06-28";
|
2023-10-09 19:29:22 +00:00
|
|
|
realVersion = "0.1.dev1798+g${lib.substring 0 7 src.rev}";
|
2024-07-03 19:18:45 +00:00
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "GlasgowEmbedded";
|
|
|
|
repo = "glasgow";
|
2024-07-03 19:18:45 +00:00
|
|
|
rev = "a599e3caa64c2e445358894fd050e16917f2ee42";
|
|
|
|
sha256 = "sha256-5qg0/j1MgwHMOjySBY5cKuQqlqltV5cXcR/Ap6J9vys=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
nativeBuildInputs = [
|
2024-07-03 19:18:45 +00:00
|
|
|
python3.pkgs.unittestCheckHook
|
|
|
|
python3.pkgs.pdm-backend
|
2023-05-24 13:37:59 +00:00
|
|
|
sdcc
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
2023-05-24 13:37:59 +00:00
|
|
|
aiohttp
|
2022-01-13 20:06:32 +00:00
|
|
|
amaranth
|
2023-10-09 19:29:22 +00:00
|
|
|
appdirs
|
2023-05-24 13:37:59 +00:00
|
|
|
bitarray
|
|
|
|
crc
|
2020-04-24 23:36:52 +00:00
|
|
|
fx2
|
|
|
|
libusb1
|
2023-10-09 19:29:22 +00:00
|
|
|
packaging
|
2024-07-03 19:18:45 +00:00
|
|
|
platformdirs
|
2020-04-24 23:36:52 +00:00
|
|
|
pyvcd
|
2023-05-24 13:37:59 +00:00
|
|
|
setuptools
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ yosys icestorm nextpnr ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
preBuild = ''
|
2023-03-04 12:14:45 +00:00
|
|
|
make -C firmware LIBFX2=${python3.pkgs.fx2}/share/libfx2
|
2020-04-24 23:36:52 +00:00
|
|
|
cp firmware/glasgow.ihex software/glasgow
|
|
|
|
cd software
|
2024-07-03 19:18:45 +00:00
|
|
|
export PDM_BUILD_SCM_VERSION="${realVersion}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# installCheck tries to build_ext again
|
|
|
|
doInstallCheck = false;
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/etc/udev/rules.d
|
2024-07-03 19:18:45 +00:00
|
|
|
cp $src/config/70-cypress.rules $out/etc/udev/rules.d
|
|
|
|
cp $src/config/70-glasgow.rules $out/etc/udev/rules.d
|
2023-10-09 19:29:22 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-03 19:18:45 +00:00
|
|
|
preCheck = ''
|
2023-10-09 19:29:22 +00:00
|
|
|
# tests attempt to cache bitstreams
|
|
|
|
# for linux:
|
|
|
|
export XDG_CACHE_HOME=$TMPDIR
|
|
|
|
# for darwin:
|
|
|
|
export HOME=$TMPDIR
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
makeWrapperArgs = [
|
|
|
|
"--set" "YOSYS" "${yosys}/bin/yosys"
|
|
|
|
"--set" "ICEPACK" "${icestorm}/bin/icepack"
|
|
|
|
"--set" "NEXTPNR_ICE40" "${nextpnr}/bin/nextpnr-ice40"
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Software for Glasgow, a digital interface multitool";
|
|
|
|
homepage = "https://github.com/GlasgowEmbedded/Glasgow";
|
|
|
|
license = licenses.bsd0;
|
2024-06-20 14:57:18 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
2024-01-02 11:29:13 +00:00
|
|
|
mainProgram = "glasgow";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|