From 0d2719c39f8bde7ea5018abdf84c54452437ab76 Mon Sep 17 00:00:00 2001 From: saji Date: Sun, 22 Sep 2024 10:55:52 -0500 Subject: [PATCH] start working on making flake work --- flake.lock | 33 +++++++++++++++++++++++++++++++++ flake.nix | 27 ++++++--------------------- python.nix | 18 ++++++++++++++++++ 3 files changed, 57 insertions(+), 21 deletions(-) create mode 100644 python.nix diff --git a/flake.lock b/flake.lock index 5e857ba..13be019 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, "nixpkgs": { "locked": { "lastModified": 1723637854, @@ -18,8 +35,24 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0bbce4c..4296013 100644 --- a/flake.nix +++ b/flake.nix @@ -5,17 +5,9 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = inputs@{ nixpkgs, ... }: + outputs = inputs@{ nixpkgs, flake-utils, ... }: 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; + python-overlay = import ./python.nix; systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; forAllSystems = function: nixpkgs.lib.genAttrs systems (system: function ( @@ -23,38 +15,31 @@ inherit system; config.allowUnfree = true; overlays = [ - ]; # patches, version pins, new pkgs here. + python-overlay + ]; } )); in { packages = forAllSystems (pkgs: { sim = import ./sim/package.nix pkgs; + }); devShells = forAllSystems (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ (python3.withPackages (ps: with ps; [ - cocotb amaranth ])) yosys nextpnr - pkgsCross.riscv64.buildPackages.gcc - gnumake - wishbone-tool # simulators - verilog + iverilog verilator # support package trellis # loader openfpgaloader ecpdap # easier to poke probes. - - # for building the simulator - cmake - ninja - mdbook ]; }; }); diff --git a/python.nix b/python.nix new file mode 100644 index 0000000..5f96544 --- /dev/null +++ b/python.nix @@ -0,0 +1,18 @@ +# overlay python patched version with amaranth/boards updated. +final: prev: { + python3 = prev.python3.override { + packageOverrides = pyfinal: pyprev: { + amaranth = pyprev.amaranth.overridePythonAttrs { + version = "0.6.0.dev53"; + src = prev.pkgs.fetchFromGitHub { + owner = "amaranth-lang"; + repo = "amaranth"; + rev = "e30d822a7d93ee615e70e95a9958051dcc794802"; + hash = "sha256-A46CMWGvqUFTp3geFFccUM9M7iECmNndzWm2GxA8XbE"; + }; + doCheck = false; + # installCheckPhase = "${prev.python3.interpreter} -m unittest discover -t . -s tests -v"; + }; + }; + }; +}