Compare commits

..

2 commits

Author SHA1 Message Date
Saji ccdbc98cb0 add flake/nix formatter (nixfmt)
Some checks failed
Verilator Unit Tests / Test (push) Failing after 3m35s
2024-09-26 01:46:28 -05:00
Saji 79927f0cbd flake now works with pyproject and flake-parts 2024-09-25 19:21:38 -05:00
15 changed files with 212 additions and 206 deletions

View file

@ -1,29 +1,32 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-parts": {
"inputs": { "inputs": {
"systems": "systems" "nixpkgs-lib": [
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1726560853, "lastModified": 1726153070,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=",
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "flake-parts",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "flake-utils", "owner": "hercules-ci",
"type": "indirect" "repo": "flake-parts",
"type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1723637854, "lastModified": 1726937504,
"narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=", "narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9", "rev": "9357f4f23713673f310988025d9dc261c20e70c6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -35,24 +38,9 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs" "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", "root": "root",

115
flake.nix
View file

@ -3,60 +3,75 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
}; };
outputs = inputs@{ self, nixpkgs, flake-utils, ... }: outputs =
let inputs@{ flake-parts, ... }:
python-overlay = import ./python.nix; flake-parts.lib.mkFlake { inherit inputs; } {
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 = [
python-overlay
];
}
));
in {
packages = forAllSystems (pkgs: {
niar = pkgs.python3.buildPythonPackage {
name = "niar";
version = pyproject-toml.project.version;
src = ./.;
pyproject = true;
build-system = [pkgs.python3.pdm-backend]; systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
propagatedBuildInpusts = [ perSystem =
pkgs.python3.amaranth {
pkgs.python3.amaranth-boards config,
]; self',
inputs',
pkgs,
system,
...
}:
{
formatter = pkgs.nixfmt-rfc-style;
packages.default = pkgs.python3.pkgs.buildPythonPackage {
name = "groovylight";
version = "0.0.1";
src = ./.;
format = "pyproject";
doCheck = true; build-system = [ pkgs.python3.pkgs.pdm-backend ];
nativeCheckInputs = [python3.pkgs.pytestCheckHook];
}; propagatedBuildInputs = [
}); pkgs.python3.pkgs.amaranth
devShells = forAllSystems (pkgs: { pkgs.python3.pkgs.amaranth-boards
default = pkgs.mkShell { ];
packages = with pkgs; [
(python3.withPackages (pypkgs: with pypkgs; [ doCheck = true;
amaranth nativeCheckInputs = with pkgs; [
amaranth-boards python3.pkgs.pytestCheckHook
])) yosys
yosys nextpnr
nextpnr trellis
# simulators openfpgaloader
iverilog ];
verilator
# support package };
trellis devShells.default = pkgs.mkShell {
# loader packages = with pkgs; [
openfpgaloader (python3.withPackages (
ecpdap # easier to poke probes. pypkgs: with pypkgs; [
]; amaranth
amaranth-boards
self'.packages.default
]
))
yosys
nextpnr
# support package
trellis
# loader
openfpgaloader
ecpdap # easier to poke probes.
];
};
}; };
}); };
};
} }

View file

@ -1,20 +1,24 @@
# an overlay to # an overlay to
let let
tag = "2023.12"; tag = "2023.12";
in final: prev: { in
wishbone-tool = prev.callPackage(import ./wishbone-tool.nix) { }; final: prev: {
wishbone-tool = prev.callPackage (import ./wishbone-tool.nix) { };
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
(python-final: python-prev: { (python-final: python-prev: {
litex = python-final.callPackage(import ./litex.nix tag) { }; litex = python-final.callPackage (import ./litex.nix tag) { };
litedram = python-final.callPackage(import ./litedram.nix tag) { }; litedram = python-final.callPackage (import ./litedram.nix tag) { };
liteeth = python-final.callPackage(import ./liteeth.nix tag) { }; liteeth = python-final.callPackage (import ./liteeth.nix tag) { };
litescope = python-final.callPackage(import ./litescope.nix tag) { }; litescope = python-final.callPackage (import ./litescope.nix tag) { };
litespi = python-final.callPackage(import ./litespi.nix tag) { }; litespi = python-final.callPackage (import ./litespi.nix tag) { };
liteiclink = python-final.callPackage(import ./liteiclink.nix tag) { }; liteiclink = python-final.callPackage (import ./liteiclink.nix tag) { };
pythondata-cpu-vexriscv = python-final.callPackage(import ./pythondata-cpu-vexriscv.nix tag) { }; pythondata-cpu-vexriscv = python-final.callPackage (import ./pythondata-cpu-vexriscv.nix tag) { };
pythondata-software-compiler_rt = python-final.callPackage(import ./pythondata-software-compiler_rt.nix tag) { }; pythondata-software-compiler_rt =
pythondata-software-picolibc = python-final.callPackage(import ./pythondata-software-picolibc.nix tag) { }; python-final.callPackage (import ./pythondata-software-compiler_rt.nix tag)
{ };
pythondata-software-picolibc =
python-final.callPackage (import ./pythondata-software-picolibc.nix tag)
{ };
}) })
]; ];
} }

View file

@ -1,10 +1,12 @@
tag: { tag:
pkgs {
, lib pkgs,
, buildPythonPackage lib,
, migen buildPythonPackage,
, pyyaml migen,
}: buildPythonPackage { pyyaml,
}:
buildPythonPackage {
pname = "litedram"; pname = "litedram";
version = "${tag}"; version = "${tag}";

View file

@ -1,12 +1,14 @@
tag: { tag:
pkgs {
, lib pkgs,
, buildPythonPackage lib,
, migen buildPythonPackage,
, setuptools migen,
, litex setuptools,
, pyyaml litex,
}: buildPythonPackage { pyyaml,
}:
buildPythonPackage {
pname = "liteeth"; pname = "liteeth";
version = "${tag}"; version = "${tag}";
@ -17,17 +19,11 @@ tag: {
hash = "sha256-DUNwDzcFLVmL5F/ZWmok7T7jO7ixC9IuDr1WUarnAqk="; hash = "sha256-DUNwDzcFLVmL5F/ZWmok7T7jO7ixC9IuDr1WUarnAqk=";
}; };
buildInputs = [ buildInputs = [ litex ];
litex
];
propagatedBuildInputs = [ propagatedBuildInputs = [ migen ];
migen
];
nativeCheckInputs = [ nativeCheckInputs = [ pyyaml ];
pyyaml
];
checkPhase = '' checkPhase = ''
python -m unittest test python -m unittest test

View file

@ -1,8 +1,10 @@
tag: { tag:
pkgs {
, buildPythonPackage pkgs,
, litex buildPythonPackage,
}: buildPythonPackage { litex,
}:
buildPythonPackage {
pname = "liteiclink"; pname = "liteiclink";
version = "${tag}"; version = "${tag}";
@ -13,9 +15,7 @@ tag: {
hash = "sha256-5Hp5vFqmfkXo1q60FvOkToTy952svirChIPIvkam04M="; hash = "sha256-5Hp5vFqmfkXo1q60FvOkToTy952svirChIPIvkam04M=";
}; };
buildInputs = [ buildInputs = [ litex ];
litex
];
checkPhase = '' checkPhase = ''
python -m unittest test python -m unittest test

View file

@ -1,11 +1,13 @@
tag: { tag:
pkgs {
, lib pkgs,
, buildPythonPackage lib,
, migen buildPythonPackage,
, setuptools migen,
, litex setuptools,
}: buildPythonPackage { litex,
}:
buildPythonPackage {
pname = "litescope"; pname = "litescope";
version = "${tag}"; version = "${tag}";
@ -16,9 +18,7 @@ tag: {
hash = "sha256-OWC+XwB+BzlCQkPKJCbQ0W4T6JbsInldrn9jYYjWypM="; hash = "sha256-OWC+XwB+BzlCQkPKJCbQ0W4T6JbsInldrn9jYYjWypM=";
}; };
buildInputs = [ buildInputs = [ litex ];
litex
];
checkPhase = '' checkPhase = ''
python -m unittest test python -m unittest test

View file

@ -1,11 +1,13 @@
tag: { tag:
pkgs {
, lib pkgs,
, buildPythonPackage lib,
, migen buildPythonPackage,
, setuptools migen,
, litex setuptools,
}: buildPythonPackage { litex,
}:
buildPythonPackage {
pname = "litespi"; pname = "litespi";
version = "${tag}"; version = "${tag}";
@ -16,16 +18,11 @@ tag: {
hash = "sha256-XYeWokF1IGtZWRK+6jhRSN91MOV5vyh5aO08sbtFBxw="; hash = "sha256-XYeWokF1IGtZWRK+6jhRSN91MOV5vyh5aO08sbtFBxw=";
}; };
buildInputs = [ buildInputs = [ litex ];
litex
];
propagatedBuildInputs = [ propagatedBuildInputs = [ migen ];
migen
];
nativeCheckInputs = [ nativeCheckInputs = [ ];
];
checkPhase = '' checkPhase = ''
python -m unittest test python -m unittest test

View file

@ -1,13 +1,15 @@
tag: { tag:
pkgs {
, lib pkgs,
, buildPythonPackage lib,
, pyserial buildPythonPackage,
, migen pyserial,
, requests migen,
, packaging requests,
, pexpect packaging,
}: buildPythonPackage { pexpect,
}:
buildPythonPackage {
pname = "litex"; pname = "litex";
version = "${tag}"; version = "${tag}";
@ -18,9 +20,7 @@ tag: {
hash = "sha256-OcwqYLQ7ec2vTewdIJqP/aTCJ4yI43OIOkTMD/hIKO0="; hash = "sha256-OcwqYLQ7ec2vTewdIJqP/aTCJ4yI43OIOkTMD/hIKO0=";
}; };
buildInputs = [ buildInputs = [ migen ];
migen
];
propagatedBuildInputs = [ propagatedBuildInputs = [
requests requests

View file

@ -1,7 +1,6 @@
tag: { tag:
pkgs { pkgs, buildPythonPackage }:
, buildPythonPackage buildPythonPackage rec {
}: buildPythonPackage rec {
pname = "pythondata-cpu-vexriscv"; pname = "pythondata-cpu-vexriscv";
version = "${tag}"; version = "${tag}";

View file

@ -1,7 +1,6 @@
tag: { tag:
pkgs { pkgs, buildPythonPackage }:
, buildPythonPackage buildPythonPackage rec {
}: buildPythonPackage rec {
pname = "pythondata-software-compiler_rt"; pname = "pythondata-software-compiler_rt";
version = "${tag}"; version = "${tag}";

View file

@ -1,7 +1,6 @@
tag: { tag:
pkgs { pkgs, buildPythonPackage }:
, buildPythonPackage buildPythonPackage rec {
}: buildPythonPackage rec {
pname = "pythondata-software-picolibc"; pname = "pythondata-software-picolibc";
version = "${tag}"; version = "${tag}";

View file

@ -1,4 +1,8 @@
{ lib, fetchFromGitHub, rustPlatform }: {
lib,
fetchFromGitHub,
rustPlatform,
}:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "wishbone-tool"; pname = "wishbone-tool";
@ -12,6 +16,5 @@ rustPlatform.buildRustPackage rec {
}; };
sourceRoot = "${src.name}/wishbone-tool"; sourceRoot = "${src.name}/wishbone-tool";
cargoHash = "sha256-kWvtZEXtb5bZ7/hd8jsr41UGSDOuDU4tyKWAL0kDoIg="; cargoHash = "sha256-kWvtZEXtb5bZ7/hd8jsr41UGSDOuDU4tyKWAL0kDoIg=";
} }

View file

@ -13,6 +13,10 @@ requires-python = "==3.12.*"
readme = "README.md" readme = "README.md"
license = {text = "MIT"} license = {text = "MIT"}
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
[tool.pdm.dev-dependencies] [tool.pdm.dev-dependencies]
dev = [ dev = [
"basedpyright", "basedpyright",

View file

@ -1,30 +1,30 @@
# overlay python patched version with amaranth/boards updated. # overlay python patched version with amaranth/boards updated.
final: prev: { final: prev: {
python3 = prev.python3.override { python3 = prev.python3.override {
packageOverrides = pyfinal: pyprev: { packageOverrides = pyfinal: pyprev: {
amaranth = pyprev.amaranth.overridePythonAttrs { amaranth = pyprev.amaranth.overridePythonAttrs {
version = "0.6.0.dev53"; version = "0.6.0.dev53";
src = prev.pkgs.fetchFromGitHub { src = prev.pkgs.fetchFromGitHub {
owner = "amaranth-lang"; owner = "amaranth-lang";
repo = "amaranth"; repo = "amaranth";
rev = "e30d822a7d93ee615e70e95a9958051dcc794802"; rev = "e30d822a7d93ee615e70e95a9958051dcc794802";
# hash = "sha256-A46CMWGvqUFTp3geFFccUM9M7iECmNndzWm2GxA8XbE"; # hash = "sha256-A46CMWGvqUFTp3geFFccUM9M7iECmNndzWm2GxA8XbE";
hash = "sha256-sCUipI7HcuTg3sJscoSI0UdIutnxGWSwbgpwWyZuFxk="; hash = "sha256-sCUipI7HcuTg3sJscoSI0UdIutnxGWSwbgpwWyZuFxk=";
}; };
doCheck = false; doCheck = false;
# installCheckPhase = "${prev.python3.interpreter} -m unittest discover -t . -s tests -v"; # installCheckPhase = "${prev.python3.interpreter} -m unittest discover -t . -s tests -v";
}; };
amaranth-boards = pyprev.amaranth-boards.overridePythonAttrs { amaranth-boards = pyprev.amaranth-boards.overridePythonAttrs {
version = "0.1.dev250"; version = "0.1.dev250";
src = prev.pkgs.fetchFromGitHub { src = prev.pkgs.fetchFromGitHub {
owner = "amaranth-lang"; owner = "amaranth-lang";
repo = "amaranth-boards"; repo = "amaranth-boards";
rev = "19b97324ecf9111c5d16377af79f82aad761c476"; rev = "19b97324ecf9111c5d16377af79f82aad761c476";
hash = "sha256-0uvn91i/yuIY75lL5Oxvozdw7Q2Uw83JWo7srgEYEpI="; hash = "sha256-0uvn91i/yuIY75lL5Oxvozdw7Q2Uw83JWo7srgEYEpI=";
}; };
build-system = [pyprev.pdm-backend]; build-system = [ pyprev.pdm-backend ];
dontCheckRuntimeDeps = 1; dontCheckRuntimeDeps = 1;
}; };
}; };
}; };
} }