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

91
pkgs/cynthion/default.nix Normal file
View file

@ -0,0 +1,91 @@
{
lib,
fetchFromGitHub,
buildPythonPackage,
python3Packages,
pkgs,
setuptools,
setuptools-git-versioning,
libusb1,
pyusb,
tomli,
future,
prompt-toolkit,
tabulate,
tqdm,
pyserial,
amaranth-041,
luna-usb,
luna-soc,
apollo-fpga,
pyfwup,
pygreat-2024,
zsh,
yosys,
nextpnr,
trellis,
}: let
in
buildPythonPackage rec {
pname = "cynthion";
version = "0.1.0";
outputs = ["out" "udev"];
pyproject = true;
src = import ./src.nix fetchFromGitHub;
nativeBuildInputs = [
setuptools
setuptools-git-versioning
zsh
yosys
nextpnr
trellis
];
propagatedBuildInputs = [
libusb1
pyusb
tomli
future
prompt-toolkit
tabulate
tqdm
pyserial
amaranth-041
luna-usb
luna-soc
apollo-fpga
pyfwup
pygreat-2024
trellis
];
postPatch = ''
substituteInPlace cynthion/python/Makefile \
--replace-fail 'SHELL := /bin/zsh' "SHELL := ${zsh}/bin/zsh"
substituteInPlace cynthion/python/src/commands/util.py \
--replace-fail "module_path, '../../assets/'" "\"$out/share/assets/\""
'';
preBuild = ''
cd cynthion/python
'';
postInstall = ''
mkdir -p $udev/lib/udev/rules.d
cp assets/54-cynthion.rules $udev/lib/udev/rules.d/54-cynthion.rules
make bitstreams
mkdir -p $out/share
ls -l
cp -r assets $out/share
'';
meta = {
description = "Cynthion is an all-in-one tool for building, testing, monitoring, and experimenting with USB device";
homepage = "https://github.com/greatscottgadgets/cynthion";
license = lib.licenses.bsd3;
};
}

6
pkgs/cynthion/src.nix Normal file
View file

@ -0,0 +1,6 @@
fetchFromGitHub: fetchFromGitHub {
owner = "greatscottgadgets";
repo = "cynthion";
rev = "db0fb8ecfee1c153219f029c0db627c6805e3d59";
hash = "sha256-BrxoRJ8bKBTENJgbYpi/fEHdCYThJEzKftH2Xo3u/3U=";
}

18
pkgs/cynthion/udev.nix Normal file
View file

@ -0,0 +1,18 @@
{
fetchFromGitHub,
stdenvNoCC,
...
}:
stdenvNoCC.mkDerivation {
pname = "cynthion-udev";
version = "0.1.0";
dontBuild = true;
dontFixup = true;
src = import ./src.nix fetchFromGitHub;
installPhase = ''
mkdir -p $out/lib/udev/rules.d
cp cynthion/python/assets/54-cynthion.rules $out/lib/udev/rules.d/54-cynthion.rules
'';
}

45
pkgs/packetry/default.nix Normal file
View file

@ -0,0 +1,45 @@
{
lib,
fetchFromGitHub,
rustPlatform,
pkg-config,
glib,
graphene,
gdk-pixbuf,
gtk4,
wrapGAppsHook,
}:
rustPlatform.buildRustPackage rec {
version = "0.1.0";
pname = "packetry";
src = fetchFromGitHub {
owner = "greatscottgadgets";
repo = "packetry";
rev = "7af5d7fd5c3cefe0291ea8eadcec5200dc6362d0";
hash = "sha256-jGCSI7aI5HenF5s2SKarABHQyCaRSag9jqnihT1WvGM=";
};
cargoSha256 = "sha256-h9fFP5VGjYKt42oN/VSghfKPco+1DEh+W3fktYO8RVY=";
nativeBuildInputs = [
wrapGAppsHook
pkg-config
];
doCheck = false;
buildInputs = [
glib
graphene
gdk-pixbuf
gtk4
];
meta = with lib; {
description = "A fast, intuitive USB 2.0 protocol analysis application for use with Cynthion.";
homepage = "https://github.com/greatscottgadgets/packetry/";
license = licenses.bsd3;
platforms = platforms.all;
};
}

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;
};
}