packages/cynthion: Build bitstreams

This commit is contained in:
Artemis Tosini 2024-07-10 03:42:46 +00:00
parent 2a1528fdab
commit beb7e02f11
Signed by: artemist
GPG key ID: EE5227935FE3FF18

View file

@ -1,4 +1,12 @@
{ fetchFromGitHub, python3 }: {
fetchFromGitHub,
python3,
zsh,
stdenv,
yosys,
nextpnr,
trellis,
}:
let let
pyfwup = python3.pkgs.buildPythonPackage rec { pyfwup = python3.pkgs.buildPythonPackage rec {
@ -174,42 +182,76 @@ let
rev = version; rev = version;
hash = "sha256-eLimS2gghT52tV01ZlFs8xEwwibB4yezl3eW7zrHpW8="; hash = "sha256-eLimS2gghT52tV01ZlFs8xEwwibB4yezl3eW7zrHpW8=";
}; };
cynthion = python3.pkgs.buildPythonApplication {
pname = "cynthion";
inherit version src;
sourceRoot = "${src.name}/cynthion/python";
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail '"setuptools-git-versioning<2"' "" \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
postInstall = ''
install -D assets/54-cynthion.rules $out/lib/udev/rules.d/54-cynthion.rules
'';
pyproject = true;
nativeBuildInputs = with python3.pkgs; [ setuptools ];
propagatedBuildInputs =
[
amaranth
apollo-fpga
pyfwup
pygreat
luna-usb
luna-soc
]
++ (with python3.pkgs; [
future
libusb1
prompt-toolkit
pyserial
pyusb
tabulate
tomli
tqdm
]);
};
cynthion-bitstreams = stdenv.mkDerivation rec {
pname = "cynthion-bistreams";
inherit version src;
sourceRoot = "${src.name}/cynthion/python";
postPatch = ''
substituteInPlace Makefile --replace-fail '/bin/zsh' '${zsh}/bin/zsh'
rm -r assets
mkdir assets
'';
nativeBuildInputs = [
python3
cynthion
yosys
nextpnr
trellis
];
buildPhase = ''
make bitstreams
'';
installPhase = ''
mv assets $out
'';
};
in in
python3.pkgs.buildPythonApplication { cynthion.overrideAttrs (attrs: {
pname = "cynthion"; postPatch =
inherit version src; attrs.postPatch
+ ''
sourceRoot = "${src.name}/cynthion/python"; ln -s ${cynthion-bitstreams}/* assets
'';
postPatch = '' })
substituteInPlace pyproject.toml \
--replace-fail '"setuptools-git-versioning<2"' "" \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
postInstall = ''
install -D assets/54-cynthion.rules $out/lib/udev/rules.d/54-cynthion.rules
'';
pyproject = true;
nativeBuildInputs = with python3.pkgs; [ setuptools ];
propagatedBuildInputs =
[
amaranth
apollo-fpga
pyfwup
pygreat
luna-usb
luna-soc
]
++ (with python3.pkgs; [
future
libusb1
prompt-toolkit
pyserial
pyusb
tabulate
tomli
tqdm
]);
}