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
|
2024-07-27 06:49:29 +00:00
|
|
|
, unstableGitUpdater
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
python3.pkgs.buildPythonApplication rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "glasgow";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "0-unstable-2024-09-10";
|
2024-07-27 06:49:29 +00:00
|
|
|
# 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}";
|
|
|
|
|
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-09-19 14:19:46 +00:00
|
|
|
rev = "f2c0ecbe0d47d96f940e77f9def209e9c57d3962";
|
|
|
|
sha256 = "sha256-aNzNh/YkWjnHiO+QWbJu2Y3kL/53kDvVn/8Ncz2kpFI=";
|
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.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; [
|
2024-07-27 06:49:29 +00:00
|
|
|
typing-extensions
|
2022-01-13 20:06:32 +00:00
|
|
|
amaranth
|
2023-10-09 19:29:22 +00:00
|
|
|
packaging
|
2024-07-03 19:18:45 +00:00
|
|
|
platformdirs
|
2024-07-27 06:49:29 +00:00
|
|
|
fx2
|
|
|
|
libusb1
|
2020-04-24 23:36:52 +00:00
|
|
|
pyvcd
|
2024-07-27 06:49:29 +00:00
|
|
|
aiohttp
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
python3.pkgs.unittestCheckHook
|
|
|
|
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-27 06:49:29 +00:00
|
|
|
cp $src/config/*.rules $out/etc/udev/rules.d
|
2023-10-09 19:29:22 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-03 19:18:45 +00:00
|
|
|
preCheck = ''
|
2024-07-27 06:49:29 +00:00
|
|
|
export PYTHONWARNINGS="ignore::DeprecationWarning"
|
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"
|
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
passthru.updateScript = unstableGitUpdater {
|
|
|
|
hardcodeZeroVersion = true;
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|