init flake

This commit is contained in:
Robin Appelman 2024-07-08 20:28:15 +02:00
commit a6d41bbaa3
17 changed files with 623 additions and 0 deletions

59
pkgs/python/amaranth.nix Normal file
View file

@ -0,0 +1,59 @@
{
lib,
buildPythonPackage,
pythonOlder,
fetchFromGitHub,
pdm-backend,
pyvcd,
jinja2,
importlib-resources,
importlib-metadata,
git,
# for tests
pytestCheckHook,
symbiyosys,
yices,
yosys,
}:
buildPythonPackage rec {
pname = "amaranth-041";
format = "pyproject";
version = "0.4.1";
disabled = pythonOlder "3.8";
src = fetchFromGitHub {
owner = "amaranth-lang";
repo = "amaranth";
rev = "refs/tags/v${version}";
hash = "sha256-VMgycvxkphdpWIib7aZwh588En145RgYlG2Zfi6nnDo=";
};
nativeBuildInputs = [
git
pdm-backend
];
propagatedBuildInputs =
[
jinja2
pyvcd
]
++ lib.optional (pythonOlder "3.9") importlib-resources
++ lib.optional (pythonOlder "3.8") importlib-metadata;
nativeCheckInputs = [
pytestCheckHook
symbiyosys
yices
yosys
];
pythonImportsCheck = ["amaranth"];
meta = with lib; {
description = "A modern hardware definition language and toolchain based on Python";
homepage = "https://amaranth-lang.org/docs/amaranth";
license = licenses.bsd2;
maintainers = with maintainers; [emily thoughtpolice pbsds];
};
}

View file

@ -0,0 +1,54 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
python3Packages,
pkgs,
amaranth-041,
luna-usb,
pyusb,
pyvcd,
prompt-toolkit,
pyxdg,
setuptools,
setuptools-git-versioning,
}: let
in
buildPythonPackage rec {
pname = "apollo-fpga";
version = "1.0.6";
pyproject = true;
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "apollo";
rev = "3a0e3a214eb1e6a9434b8e0bf15bcf7cf54f8242";
hash = "sha256-t3XtBzinMysIBgONPIGLqFXpzBaCqMfY3sufjtRc7Io=";
};
nativeBuildInputs = [
setuptools
setuptools-git-versioning
];
propagatedBuildInputs = [
amaranth-041
luna-usb
pyusb
pyvcd
prompt-toolkit
pyxdg
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
meta = {
description = "Amaranth HDL framework for monitoring, hacking, and developing USB devices";
homepage = "https://github.com/greatscottgadgets/luna";
license = lib.licenses.bsd3;
};
}

9
pkgs/python/default.nix Normal file
View file

@ -0,0 +1,9 @@
py-final: _py-prev: {
amaranth-041 = py-final.callPackage ./amaranth.nix {};
luna-usb = py-final.callPackage ./luna-usb.nix {};
luna-soc = py-final.callPackage ./luna-soc.nix {};
apollo-fpga = py-final.callPackage ./apollo-fpga.nix {};
pyfwup = py-final.callPackage ./pyfwup.nix {};
pygreat-2024 = py-final.callPackage ./pygreat.nix {};
usb-protocol = py-final.callPackage ./usb-protocol.nix {};
}

44
pkgs/python/luna-soc.nix Normal file
View file

@ -0,0 +1,44 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
python3Packages,
pkgs,
luna-usb,
setuptools,
setuptools-git-versioning,
}: let
in
buildPythonPackage rec {
pname = "luna-soc";
version = "0.2.0";
pyproject = true;
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "luna-soc";
rev = "0.2.0";
hash = "sha256-P8P32hM1cVXENcDpCrmPe8BvkMCWdeEgHwbIU94uLe8=";
};
nativeBuildInputs = [
setuptools
setuptools-git-versioning
];
propagatedBuildInputs = [
luna-usb
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
meta = {
description = "Amaranth HDL framework for monitoring, hacking, and developing USB devices";
homepage = "https://github.com/greatscottgadgets/luna";
license = lib.licenses.bsd3;
};
}

52
pkgs/python/luna-usb.nix Normal file
View file

@ -0,0 +1,52 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
setuptools,
setuptools-git-versioning,
pyvcd,
pyusb,
libusb1,
pyserial,
amaranth-041,
usb-protocol,
}: let
in
buildPythonPackage rec {
pname = "luna-usb";
version = "0.1.1";
pyproject = true;
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "luna";
rev = "0.1.1";
hash = "sha256-81GJF3QLERCmvZXYlQvb1vzJFeGMSMNMwuGoaBJE8Zg=";
};
nativeBuildInputs = [
setuptools
setuptools-git-versioning
];
propagatedBuildInputs = [
pyusb
libusb1
pyserial
amaranth-041
pyvcd
usb-protocol
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
meta = {
description = "Amaranth HDL framework for monitoring, hacking, and developing USB devices";
homepage = "https://github.com/greatscottgadgets/luna";
license = lib.licenses.bsd3;
};
}

45
pkgs/python/pyfwup.nix Normal file
View file

@ -0,0 +1,45 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
python3Packages,
pyusb,
tqdm,
setuptools,
setuptools-git-versioning,
}: let
in
buildPythonPackage rec {
pname = "pyfwup";
version = "0.4.0";
pyproject = true;
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "pyfwup";
rev = "0.4.0";
hash = "sha256-JSaAEGobdLqpSj9yvKrAsXfdkHpXSCcuGYRxz2QJqck=";
};
nativeBuildInputs = [
setuptools
setuptools-git-versioning
];
propagatedBuildInputs = [
pyusb
tqdm
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
meta = {
description = "python library providing utilities, data structures, constants, parsers, and tools for working with USB data";
homepage = "https://github.com/greatscottgadgets/python-usb-protocol";
license = lib.licenses.bsd3;
};
}

54
pkgs/python/pygreat.nix Normal file
View file

@ -0,0 +1,54 @@
{
lib,
buildPythonPackage,
isPy3k,
fetchFromGitHub,
future,
pyusb,
setuptools,
setuptools-git-versioning,
}:
buildPythonPackage rec {
pname = "pygreat-2024";
version = "v2024.0.1";
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "libgreat";
rev = "v2024.0.1";
hash = "sha256-k+0dGBohKglQEFN13mGsw0C6pCeQDRp+CwPW2GuKfuY=";
};
nativeBuildInputs = [
setuptools
setuptools-git-versioning
];
propagatedBuildInputs = [
future
pyusb
];
pyproject = true;
postPatch = ''
substituteInPlace host/pyproject.toml \
--replace-fail '"backports.functools_lru_cache",' "" \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
disabled = !isPy3k;
preBuild = ''
cd host
substituteInPlace setup.py --replace "'backports.functools_lru_cache'" ""
substituteInPlace pygreat/comms.py --replace "from backports.functools_lru_cache import lru_cache as memoize_with_lru_cache" "from functools import lru_cache as memoize_with_lru_cache"
echo "$version" > ../VERSION
'';
meta = with lib; {
description = "Python library for talking with libGreat devices";
homepage = "https://greatscottgadgets.com/greatfet/";
license = with licenses; [bsd3];
};
}

View file

@ -0,0 +1,42 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
construct,
setuptools,
setuptools-git-versioning,
}: let
in
buildPythonPackage rec {
pname = "usb-protocol";
version = "0.9.1";
pyproject = true;
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "python-usb-protocol";
rev = "0.9.1";
hash = "sha256-CYbXs/SRC1FAVEzfw0gwf6U0qQ9Q34nyuj5yfjHfDn8=";
};
nativeBuildInputs = [
setuptools
setuptools-git-versioning
];
propagatedBuildInputs = [
construct
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace-fail 'dynamic = ["version"]' 'version = "${version}"'
'';
meta = {
description = "python library providing utilities, data structures, constants, parsers, and tools for working with USB data";
homepage = "https://github.com/greatscottgadgets/python-usb-protocol";
license = lib.licenses.bsd3;
};
}