Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moss: refactor build script add ability to configure backends #3

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

jleightcap
Copy link
Contributor

(In response to ngi-nix/ngipkgs#7 (comment))

We started by refactoring the builder = ... attribute of the nextpnr-xilinx-chipdb derivation. This builder script had the neccessary build logic for interacting with the prjxray-db, but had some glue logic for interacting with the external dependencies.

We refactored this to be inline shell script in the derivation definition, porting over the build logic.
We left a note about future work splitting out the installPhase.

We took a look at your comment,

Also, I would like to call the builder with different arguments to create different flakes with the different FPGA families (artiz7, kintex7, spartan7 zynq7). What would be the best way to go about it?
I also would like to make those optional. How would I want to do that?

Our thought was to have a 'base' derivation for nextpnr-xilinx-chipdb, then configure the backend based on overrides. Ideally, the building process looks like

nix build .#nextpnr-xilinx-chipdb.zynq7 # only includes zynq7
# ...

Let us know if that's along the lines you were thinking @hansfbaier!

@jleightcap jleightcap force-pushed the moss/backends branch 2 times, most recently from 3df1ab0 to 06c0496 Compare September 6, 2023 01:48
@hansfbaier
Copy link
Contributor

@jleightcap I tried it, but since the overrides are commented out, it only seems to build the default zynq7, no matter what backent I try to build.

@hansfbaier
Copy link
Contributor

I tried this:
image
But still the same result.

@jleightcap
Copy link
Contributor Author

We ended a working session trying to understand why overrideAttrs fails to override the backend key inside the base _nextpnr-xilinx-chipdb derivation -- like you mention the "default" value of "zynq7" is passed regardless. Overriding within an overlay was not something we were familiar with, we'll pick it back up at an upcoming mob 🙂

jleightcap and others added 3 commits September 6, 2023 18:44
Co-authored-by: Jason Odoom <jasonodoom@gmail.com>
Co-authored-by: Anish Lakhwara <anish+git@lakhwara.com>
Co-authored-by: Dominic Mills <dominic.millz27@gmail.com>
Co-authored-by: Albert Chae <albertchae@users.noreply.github.com>
Co-authored-by: Jack Leightcap <jack@leightcap.com>
Signed-off-by: Jack Leightcap <jack@leightcap.com>
Co-authored-by: Jason Odoom <jasonodoom@gmail.com>
Co-authored-by: Anish Lakhwara <anish+git@lakhwara.com>
Co-authored-by: Dominic Mills <dominic.millz27@gmail.com>
Co-authored-by: Albert Chae <albertchae@users.noreply.github.com>
Co-authored-by: Jack Leightcap <jack@leightcap.com>
Signed-off-by: Jack Leightcap <jack@leightcap.com>
Co-authored-by: Jason Odoom <jasonodoom@gmail.com>
Co-authored-by: Anish Lakhwara <anish+git@lakhwara.com>
Co-authored-by: Dominic Mills <dominic.millz27@gmail.com>
Co-authored-by: Albert Chae <albertchae@users.noreply.github.com>
Co-authored-by: Jack Leightcap <jack@leightcap.com>
Signed-off-by: Jack Leightcap <jack@leightcap.com>
@jleightcap
Copy link
Contributor Author

jleightcap commented Sep 6, 2023

We got the backend selection working in 5e94912 using callPackage. This pattern has a 'meta-package' for the chip-db, that takes a backend argument. This was the cleanest solution we came up with, let us know if it makes sense.

Waiting for the DB to build to verify the outputs, but the buildPhase is a straight-foward adaption of the existing builder script.

@jleightcap jleightcap marked this pull request as ready for review September 6, 2023 22:53
buildInputs = [ prjxray nextpnr-xilinx pypy3 coreutils findutils gnused gnugrep ];

builder = ./chipdb-builder.sh;
nextpnr-xilinx-chipdb = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invocations:

$ nix build .#nextpnr-xilinx-chipdb.kintex7
# builds with only one backend, etc.

@hansfbaier hansfbaier merged commit df01c1f into openXC7:main Sep 8, 2023
@hansfbaier
Copy link
Contributor

@jleightcap That works, many thanks!

@hansfbaier
Copy link
Contributor

hansfbaier commented Sep 8, 2023

@jleightcap That leaves the question, how can I query the path to the chipdb output for a specific backend?
I did it like this:
nix eval --raw '.#packages.x86_64-linux.nextpnr-xilinx-chipdb.spartan7.outPath'
Is there a more elegant method?
Actually I think the chipdb files might not be architecture specific (except endianness maybe)

@jleightcap jleightcap deleted the moss/backends branch September 10, 2023 19:54
@jleightcap
Copy link
Contributor Author

jleightcap commented Sep 10, 2023

Slightly more elegant, maybe, is:

$ nix eval --raw ".#nextpn-xilinx-chipdb.spartan7.outPath"

Like you said, this includes the implicit architecture prefix of the host (packages.x86_64-linux.).

Unless you mean how to query the output path prior to building the package? As far as I know that hash embedded in the path is derived from the output and so can't be computed without fully evaluating the package.

Let me know if that makes sense!

@hansfbaier
Copy link
Contributor

@jleightcap That is perfect, thanks!

@albertchae albertchae mentioned this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants