depot/third_party/nixpkgs/pkgs/tools/misc/glasgow/default.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

82 lines
1.8 KiB
Nix

{ lib
, python3
, fetchFromGitHub
, sdcc
, yosys
, icestorm
, nextpnr
}:
python3.pkgs.buildPythonApplication rec {
pname = "glasgow";
version = "unstable-2023-09-20";
# python -m setuptools_scm
realVersion = "0.1.dev1798+g${lib.substring 0 7 src.rev}";
src = fetchFromGitHub {
owner = "GlasgowEmbedded";
repo = "glasgow";
rev = "e9a9801d5be3dcba0ee188dd8a6e9115e337795d";
sha256 = "sha256-ztB3I/jrDSm1gKB1e5igivUVloq+YYhkshDlWg75NMA=";
};
nativeBuildInputs = [
python3.pkgs.setuptools-scm
sdcc
];
propagatedBuildInputs = with python3.pkgs; [
aiohttp
amaranth
appdirs
bitarray
crc
fx2
libusb1
packaging
pyvcd
setuptools
];
nativeCheckInputs = [ yosys icestorm nextpnr ];
enableParallelBuilding = true;
preBuild = ''
make -C firmware LIBFX2=${python3.pkgs.fx2}/share/libfx2
cp firmware/glasgow.ihex software/glasgow
cd software
export SETUPTOOLS_SCM_PRETEND_VERSION="${realVersion}"
'';
# installCheck tries to build_ext again
doInstallCheck = false;
postInstall = ''
mkdir -p $out/etc/udev/rules.d
cp $src/config/99-glasgow.rules $out/etc/udev/rules.d
'';
checkPhase = ''
# tests attempt to cache bitstreams
# for linux:
export XDG_CACHE_HOME=$TMPDIR
# for darwin:
export HOME=$TMPDIR
${python3.interpreter} -W ignore::DeprecationWarning test.py
'';
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;
maintainers = with maintainers; [ thoughtpolice ];
mainProgram = "glasgow";
};
}