From 8bcb72013b10284304d6813e11e66382daebcf33 Mon Sep 17 00:00:00 2001 From: saji Date: Thu, 18 Apr 2024 11:58:49 -0500 Subject: [PATCH] add litex --- flake.nix | 23 +++++++++++++++++++---- litex/default.nix | 11 +++++++++++ litex/litex.nix | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 litex/default.nix create mode 100644 litex/litex.nix diff --git a/flake.nix b/flake.nix index 1f52d38..8cb8a25 100644 --- a/flake.nix +++ b/flake.nix @@ -7,13 +7,24 @@ outputs = inputs@{ nixpkgs, ... }: let + # litex-overlay = final: prev: { + # pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + # (python-final: python-prev: { + # litex = python-final.callPackage (import ./litex.nix) { }; + # # can add more packages here! + # }) + # ]; + # }; + litex-overlay = import ./litex; systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; forAllSystems = function: nixpkgs.lib.genAttrs systems (system: function ( import nixpkgs { inherit system; config.allowUnfree = true; - overlays = []; # patches, version pins here. + overlays = [ + litex-overlay + ]; # patches, version pins, new pkgs here. } )); @@ -21,9 +32,12 @@ devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ - python3 - python3Packages.cocotb - python3Packages.cocotb-bus + (python3.withPackages (ps: with ps; [ + cocotb + cocotb-bus + litex + amaranth + ])) yosys nextpnr # simulators @@ -33,6 +47,7 @@ trellis # loader openfpgaloader + ecpdap # easier to poke probes. ]; }; diff --git a/litex/default.nix b/litex/default.nix new file mode 100644 index 0000000..34ae2fd --- /dev/null +++ b/litex/default.nix @@ -0,0 +1,11 @@ +# an overlay to +let + tag = "2023.12"; +in final: prev: { + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ + (python-final: python-prev: { + litex = python-final.callPackage(import ./litex.nix tag) { }; + }) + ]; +} + diff --git a/litex/litex.nix b/litex/litex.nix new file mode 100644 index 0000000..5619107 --- /dev/null +++ b/litex/litex.nix @@ -0,0 +1,36 @@ +tag: { + pkgs +, lib +, buildPythonPackage +, pyserial +, migen +, requests +, colorama +, packaging +, setuptools +}: buildPythonPackage { + pname = "litex"; + version = "${tag}"; + pyproject = true; + + src = pkgs.fetchFromGitHub { + owner = "enjoy-digital"; + repo = "litex"; + rev = "${tag}"; + hash = "sha256-OcwqYLQ7ec2vTewdIJqP/aTCJ4yI43OIOkTMD/hIKO0="; + }; + + buildInputs = [ + setuptools + ]; + + propagatedBuildInputs = [ + migen + requests + pyserial + colorama + packaging + ]; + + doCheck = false; +}