depot/third_party/nixpkgs/pkgs/tools/misc/glasgow/default.nix

96 lines
2 KiB
Nix
Raw Normal View History

{ lib
, python3
, fetchFromGitHub
, sdcc
, yosys
, icestorm
, nextpnr
, unstableGitUpdater
}:
python3.pkgs.buildPythonApplication rec {
pname = "glasgow";
version = "0-unstable-2024-09-10";
# 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;
src = fetchFromGitHub {
owner = "GlasgowEmbedded";
repo = "glasgow";
rev = "f2c0ecbe0d47d96f940e77f9def209e9c57d3962";
sha256 = "sha256-aNzNh/YkWjnHiO+QWbJu2Y3kL/53kDvVn/8Ncz2kpFI=";
};
nativeBuildInputs = [
2024-07-03 19:18:45 +00:00
python3.pkgs.pdm-backend
sdcc
];
propagatedBuildInputs = with python3.pkgs; [
typing-extensions
amaranth
packaging
2024-07-03 19:18:45 +00:00
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
2024-07-03 19:18:45 +00:00
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
'';
2024-07-03 19:18:45 +00:00
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";
};
}