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

Add Nix flake #1970

Merged
merged 1 commit into from
Mar 5, 2025
Merged

Conversation

aidenfoxivey
Copy link
Contributor

@praveksharma @SWilson4 As I mentioned earlier, I wrote a little nix flake that should be able to run the environment without anything other than Nix installed on the machine - in addition to being declarative.

I'm happy to add or remove packages to the flake - I mostly followed the requirements for the QuickStart, but potentially missed something.

@baentsch
Copy link
Member

Thanks for the proposal @aidenfoxivey ! Quick initial question (not knowing anything about nix): Does this have to reside in the top level project directory?

@aidenfoxivey
Copy link
Contributor Author

Hi @baentsch!

In every project I've worked on, flake.nix and flake.lock do reside in the top level. That said, I was curious about the question, so I looked it up.

According to this reference (https://nixos.wiki/wiki/Flakes), flake.nix does have to be in the top-level.

My main goal with this is to have a declarative way to build liboqs to aid debugging and avoid having to use containers.

@aidenfoxivey aidenfoxivey marked this pull request as ready for review October 31, 2024 20:16
@SWilson4
Copy link
Member

SWilson4 commented Nov 5, 2024

Thanks for the submission @aidenfoxivey!

I personally don't know anything about Nix, but I think two non–Nix-related issues would need to be resolved before this lands:

  1. The flake should be tested in CI somehow.
  2. There should be some sort of maintenance commitment to ensure the flake stays up to date—would you be willing to take this on?

@aidenfoxivey
Copy link
Contributor Author

  1. The flake should be tested in CI somehow.
    Sounds good! I'll write up a little testing setup sometime this week.
  1. There should be some sort of maintenance commitment to ensure the flake stays up to date—would you be willing to take this on?
    Absolutely! I'm happy to be the designated flake maintainer.

@praveksharma praveksharma self-requested a review November 5, 2024 17:13
Copy link
Member

@praveksharma praveksharma left a comment

Choose a reason for hiding this comment

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

The flake itself looks good to me, thank you @aidenfoxivey!

Could you also update the quickstart section of README.md to include instruction on how to use the flake?

Do you know if there's some way of parameterising the flake to spin up different dev envs, say with clang instead of gcc?

@aidenfoxivey
Copy link
Contributor Author

aidenfoxivey commented Nov 5, 2024

Could you also update the quickstart section of README.md to include instruction on how to use the flake?

I'll remove the instructions from the flake and put them in the quickstart along with other information.

Do you know if there's some way of parameterising the flake to spin up different dev envs, say with clang instead of gcc?

I'll take a look!

@aidenfoxivey
Copy link
Contributor Author

I think it's maybe better to version the flake starting from 0.0.1, but alternative perspectives are certainly appreciated.

@aidenfoxivey
Copy link
Contributor Author

Not sure what I did to boggle the code formatting lol. Maybe something in how I did the README was an issue?

@aidenfoxivey
Copy link
Contributor Author

@baentsch I'll look into generating it by default

@aidenfoxivey
Copy link
Contributor Author

Turns out the version tag is completely unnecessary, since it can be referred to by its git hash anyways. I'll wait for additional comments and then clean up the git history once I've sorted out any requests.

@aidenfoxivey aidenfoxivey force-pushed the add-nix-flake branch 4 times, most recently from 729315f to 05edb28 Compare November 7, 2024 23:57
@aidenfoxivey aidenfoxivey requested a review from cothan November 7, 2024 23:58
Copy link
Member

@cothan cothan left a comment

Choose a reason for hiding this comment

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

LTGM! Thanks for the contribution. Please make sure the all the tests are passed before you merge.

@aidenfoxivey aidenfoxivey requested a review from SWilson4 November 8, 2024 00:20
Copy link
Member

@praveksharma praveksharma left a comment

Choose a reason for hiding this comment

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

This looks good, thank for you working on this @aidenfoxivey!

@baentsch
Copy link
Member

baentsch commented Nov 8, 2024

LTGM! Thanks for the contribution. Please make sure the all the tests are passed before you merge.

Hmm -- this statement made me curious: What tests are there (to be) passed? I didn't find any (just searching for changes to .github/workflows). Wouldn't that/having such be prudent, @cothan @praveksharma ?

@cothan
Copy link
Member

cothan commented Nov 8, 2024

Hi @baentsch , I approve the PR while there are 6 tests (unrelated to the PR) are still running, since this PR doesn't add anything to Github flow, thus I expect them all to pass, and they did (I didn't aware at the time that each PR needs 2 approval). So I comment to make sure this PR will be merged in a green state.

@praveksharma
Copy link
Member

I agree that having testing for the flake would be desirable @baentsch but I'm also uncertain what is the best way to go about it. I believe the current build targets are limited in that they don't allow the user to pass CMake options via the nix CLI; is that correct @aidenfoxivey?

Since the project doesn't plan on moving away from CMake, at this stage it might make more sense to focus on developer quality of life improvement via nix develop. This would be easy to test via a weekly CI job -- on a ubuntu:latest image with just nix that must pass some cmake build tests.

Alternatively, if there is some way of transparently exposing CMake options to nix that would also be suitable. Instead of a maintainer having to ensure compatibility with CONFIGURE.md that would be handled natively by nix.

@aidenfoxivey
Copy link
Contributor Author

@praveksharma Just to be clear, you want changes on the README, right?

@praveksharma
Copy link
Member

@praveksharma Just to be clear, you want changes on the README, right?

Yes, listing the relevant nix alternatives to the apt commands under Quick Start > Linux and Mac > 1. Install dependencies is what I had in mind.

@baentsch
Copy link
Member

As part of my year-end review of stalled things, can I ask what the idea is with this PR:

  • Add CI testing as per @SWilson4 's suggestion?
  • Add a small(er) README section as per @praveksharma 's suggestion (also addressing my concerns)
  • Drop PR without merge

Which of these options would you like to pursue, @aidenfoxivey ? One, all, none, something else?

@aidenfoxivey
Copy link
Contributor Author

As part of my year-end review of stalled things, can I ask what the idea is with this PR:

  • Add CI testing as per @SWilson4 's suggestion?
  • Add a small(er) README section as per @praveksharma 's suggestion (also addressing my concerns)
  • Drop PR without merge

Which of these options would you like to pursue, @aidenfoxivey ? One, all, none, something else?

Ah whoops! I've got to admit liboqs slipped by mind a little bit during the latter half of the term. I'm going to sort out the README section tonight.

Thinking about testing, I think I wrote a solution but never pushed it.

I'll look to wrap this up in the next few days.

@aidenfoxivey aidenfoxivey force-pushed the add-nix-flake branch 2 times, most recently from d480dac to de5beca Compare December 23, 2024 01:25
@aidenfoxivey
Copy link
Contributor Author

So I think there are a few things to think about:

  • is the Nix flake formatted? (this doesn't seem that important to me)
  • is it valid nix?
  • does the build it produces work?

Are all of these in scope for what tests should do?

@dstebila
Copy link
Member

dstebila commented Jan 7, 2025

So I think there are a few things to think about:

* is the Nix flake formatted? (this doesn't seem _that_ important to me)

* is it valid nix?

* does the build it produces work?

Are all of these in scope for what tests should do?

@baentsch Is this what you had in mind when it came to testing?

@baentsch
Copy link
Member

baentsch commented Jan 8, 2025

So I think there are a few things to think about:

* is the Nix flake formatted? (this doesn't seem _that_ important to me)

* is it valid nix?

* does the build it produces work?

Are all of these in scope for what tests should do?

@baentsch Is this what you had in mind when it came to testing?

It's a start - with item 3 being the most relevant imo.

@aidenfoxivey
Copy link
Contributor Author

Okay, that functionality should be added now. Had to implement a small fix to prevent it from trying to rewrite a copy of the CMake file internally.

@dstebila
Copy link
Member

Hi @aidenfoxivey, do you think you will be able to address the point above from security scanner? Is there anything else to be done before merging this?

@aidenfoxivey
Copy link
Contributor Author

Hi @aidenfoxivey, do you think you will be able to address the point above from security scanner? Is there anything else to be done before merging this?

I've just pinned them to the latest version I could find. I'm running it locally on my Mac to give it a check.

CleanShot 2025-02-25 at 18 19 59@2x

@aidenfoxivey
Copy link
Contributor Author

Woohoo!

[Nix Flake Check/tests]   ✅  Success - Main ${GITHUB_ACTION_PATH}/install-nix.sh
[Nix Flake Check/tests]   ⚙  ::set-env:: TMPDIR=/tmp
[Nix Flake Check/tests]   ⚙  ::add-path:: /nix/var/nix/profiles/default/bin
[Nix Flake Check/tests]   ⚙  ::add-path:: /root/.nix-profile/bin
[Nix Flake Check/tests]   ✅  Success - Main cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72
[Nix Flake Check/tests]   ⚙  ::set-env:: TMPDIR=/tmp
[Nix Flake Check/tests]   ⚙  ::add-path:: /nix/var/nix/profiles/default/bin
[Nix Flake Check/tests]   ⚙  ::add-path:: /root/.nix-profile/bin
[Nix Flake Check/tests] ⭐ Run Main nix build
[Nix Flake Check/tests]   🐳  docker exec cmd=[bash -e /var/run/act/workflow/2] user= workdir=
warning: Git tree '/Users/aidenfoxivey/src/liboqs' is dirty
[Nix Flake Check/tests]   ✅  Success - Main nix build
[Nix Flake Check/tests] ⭐ Run Main nix flake check
[Nix Flake Check/tests]   🐳  docker exec cmd=[bash -e /var/run/act/workflow/3] user= workdir=
warning: Git tree '/Users/aidenfoxivey/src/liboqs' is dirty
warning: The check omitted these incompatible systems: aarch64-darwin, x86_64-darwin, x86_64-linux
| Use '--all-systems' to check all.
[Nix Flake Check/tests]   ✅  Success - Main nix flake check
[Nix Flake Check/tests] ⭐ Run Post cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72
[Nix Flake Check/tests]   🐳  docker cp src=/Users/aidenfoxivey/.cache/act/cachix-install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72/ dst=/var/run/act/actions/cachix-install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72/
[Nix Flake Check/tests]   ✅  Success - Post cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72
[Nix Flake Check/tests] ⭐ Run Complete job
[Nix Flake Check/tests] Cleaning up container for job tests
[Nix Flake Check/tests]   ✅  Success - Complete job
[Nix Flake Check/tests] 🏁  Job succeeded

@dstebila
Copy link
Member

Thanks @aidenfoxivey!

@baentsch you've got a review requesting changes; does this clear your concerns? If so then please clear that in your review and then we can merge.

@baentsch baentsch dismissed their stale review February 26, 2025 16:51

Dismissal requested. Still thinking testing would be appropriate, though.

@baentsch
Copy link
Member

Thanks @aidenfoxivey!

@baentsch you've got a review requesting changes; does this clear your concerns? If so then please clear that in your review and then we can merge.

Not really -- but this is not worth fussing over.

@aidenfoxivey
Copy link
Contributor Author

Should be moved into basic.yml now. That's the correct location right?

@aidenfoxivey
Copy link
Contributor Author

aidenfoxivey commented Feb 26, 2025

CleanShot 2025-02-26 at 13 21 57@2x
I suspect that basic.yml isn't running for me due to not having committer access to open-quantum-safe. This is from my local fork running it. I'm thinking that perhaps the container I've chosen doesn't have sudo. This could prove an issue. I just used the default Ubuntu image beforehand - would that be fine to use instead?

@baentsch I'm happy to make changes in this PR or a follow up to make this more robust. I apologize for the delays in the middle of this.

(I'll be back at this after 5pm EST today to review comments and/or fix up the CI issues.)

@SWilson4
Copy link
Member

SWilson4 commented Feb 26, 2025

I suspect that basic.yml isn't running for me due to not having committer access to open-quantum-safe. This is from my local fork running it. I'm thinking that perhaps the container I've chosen doesn't have sudo. This could prove an issue. I just used the default Ubuntu image beforehand - would that be fine to use instead?

I don't believe we install sudo in our containers—everything in CI runs as root anyhow. If the ubuntu-latest runner has the necessary dependencies to build the flake, that's fine (even preferable—it saves the time of downloading our image).

Looks like you'll have to rebase to get CI to run.

@aidenfoxivey aidenfoxivey force-pushed the add-nix-flake branch 2 times, most recently from b63a870 to cfc4e30 Compare February 26, 2025 23:48
@aidenfoxivey
Copy link
Contributor Author

Seems the Nix tests are working - happy to squash and force push when it's all passed.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: Aiden Fox Ivey <[email protected]>
Copy link
Member

@SWilson4 SWilson4 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @aidenfoxivey!

@dstebila dstebila merged commit d4eb7a6 into open-quantum-safe:main Mar 5, 2025
79 checks passed
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

6 participants