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