Skip to content

Commit

Permalink
use poetry2nix for Python dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Jan 4, 2024
1 parent c3a935c commit 5578999
Show file tree
Hide file tree
Showing 13 changed files with 561 additions and 242 deletions.
20 changes: 0 additions & 20 deletions dependencies/edalize.nix

This file was deleted.

36 changes: 0 additions & 36 deletions dependencies/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions dependencies/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,18 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
lowrisc_fusesoc_src = {
url = "github:lowRISC/fusesoc?ref=ot-0.2";
flake = false;
};
lowrisc_edalize_src = {
url = "github:lowRISC/edalize?ref=ot-0.2";
flake = false;
};
};

outputs = {
self,
nixpkgs,
lowrisc_fusesoc_src,
lowrisc_edalize_src,
}: let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config = {allowUnfree = true;};
};

lowRISC_python_overrides = pfinal: pprev: {
fusesoc = pprev.fusesoc.overridePythonAttrs (oldAttrs: {
version = "0.3.3.dev";
src = lowrisc_fusesoc_src;
});
edalize = pprev.edalize.overridePythonAttrs (oldAttrs: {
version = "0.3.3.dev";
src = lowrisc_edalize_src;
});
};

lowRISC_spike_override = final: prev: {
riscv-isa-sim = prev.riscv-isa-sim.overrideAttrs (oldAttrs: rec {
version = "ibex-cosim-v0.3";
Expand Down Expand Up @@ -103,9 +82,5 @@
inherit vivado;
})
];
overlay_python = pkgs.lib.composeManyExtensions [
(import ./python-overlay.nix)
lowRISC_python_overrides
];
};
}
23 changes: 0 additions & 23 deletions dependencies/fusesoc.nix

This file was deleted.

16 changes: 0 additions & 16 deletions dependencies/ipyxact.nix

This file was deleted.

20 changes: 0 additions & 20 deletions dependencies/okonomiyaki.nix

This file was deleted.

8 changes: 0 additions & 8 deletions dependencies/python-overlay.nix

This file was deleted.

19 changes: 0 additions & 19 deletions dependencies/simplesat.nix

This file was deleted.

14 changes: 0 additions & 14 deletions dependencies/zipfile2.nix

This file was deleted.

42 changes: 5 additions & 37 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 15 additions & 24 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

nixpkgs.follows = "lowrisc-nix/nixpkgs";
flake-utils.follows = "lowrisc-nix/flake-utils";
poetry2nix.follows = "lowrisc-nix/poetry2nix";

deps = {
url = "path:./dependencies";
Expand All @@ -29,20 +30,20 @@
# Add extra packages we might need
# Currently this contains spike
deps.overlay_pkgs
# Add all the python packages we need that aren't in nixpkgs
# (See the ./dependencies folder for more info)
(final: prev: {
python3 = prev.python3.override {
packageOverrides = deps.overlay_python;
};
})
];
};

pythonEnv = pkgs.python3.withPackages (
ps:
with ps; [pip fusesoc edalize pyyaml Mako]
);
pythonEnv = let
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix {inherit pkgs;};
poetryOverrides = lowrisc-nix.lib.poetryOverrides {inherit pkgs;};
in
poetry2nix.mkPoetryEnv {
projectDir = ./.;
overrides = [
poetryOverrides
poetry2nix.defaultPoetryOverrides
];
};

# This is the final list of dependencies we need to build the project.
project_deps =
Expand Down Expand Up @@ -71,6 +72,9 @@
libelf
zlib
# vivado

# Poetry tool not required, add for convience in case update is needed
poetry
]);
in {
devShells.default = pkgs.mkShell {
Expand All @@ -80,19 +84,6 @@
# FIXME This works on Ubuntu, may not on other distros. FIXME
export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive
# HACK fixup some paths to use our sandboxed python environment
# Currently, fusesoc tries to invoke the program 'python3' from the
# PATH, which when running under a nix python environment, resolves
# to the raw python binary, not wrapped and not including the
# environment's packages. Hence, the first time an import is evaluated
# we will error out.
sed -i -- \
's|interpreter:.*|interpreter: ${pythonEnv}/bin/python3|g' \
vendor/lowrisc_ibex/vendor/lowrisc_ip/dv/tools/ralgen/ralgen.core
sed -i -- \
's|interpreter:.*|interpreter: ${pythonEnv}/bin/python3|g' \
vendor/lowrisc_ibex/vendor/lowrisc_ip/ip/prim/primgen.core
export PS1='labenv(HiPEAC) (ibex-demo-system) \$ '
echo
Expand Down
Loading

0 comments on commit 5578999

Please sign in to comment.