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 packaging #31

Closed
wants to merge 2 commits into from
Closed

Add Nix packaging #31

wants to merge 2 commits into from

Conversation

ehmry
Copy link
Contributor

@ehmry ehmry commented Apr 15, 2023

Add some metadata for building a Nix package.

After merging the package can be built deterministically with nix build github:katzenpost/katzen (if flake mode is locally enabled, not yet the default for Nix).

To test the build run nix build github:ehmry/katzen/flake -L.

Co-authored-by: dvn <git@dvn.me>
Some crypto libraries missing for 32-bit x86.
@ehmry
Copy link
Contributor Author

ehmry commented Apr 15, 2023


vendorHash = "sha256-4/AteWLY9biTspcXcyzK1gNwzkQfFoNq89yJheswf4s=";
# This hash is may drift from the actual vendoring and break the build,
# see https://nixos.org/manual/nixpkgs/unstable/#ssec-language-go.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what this comment means exactly; is this not the hash of the deps as they exist in your branch? Anyway, I made a new PR #38 on top of this and naturally had to change this hash (as I merged main, which changed lots in go.mod). If I understand correctly we'll need to change this whenever we change go.mod in the future... while the non-golang nix build deps are pinned via flake.lock. (Right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

I'm not familiar enough with Go modules and vendoring to explain exactly what this is, but Nix is fetching all the vendored dependencies and then verifying that it is doing this deterministically by comparing the result of the fetch against a hash. To get the current hash this would be set to null or lib.fakeHash, run the build, and extract the generated hash from the build failure. This gets tricky because if the hash of the output of the fetch is know, it can be cached indefinitely, so if it gets out of sync a machine that built the previous deps would use the old deps, and on a machine where the cached deps aren't present it would try to re-fetch but fail because the hash is different.

https://nixos.org/manual/nixpkgs/unstable/#ssec-language-go

@leif
Copy link
Member

leif commented Jun 17, 2023

@ehmry thanks for packaging Katzen! If you get a chance to have a look at what I did with this in CI in #38 let me know if you have any feedback.

@ehmry
Copy link
Contributor Author

ehmry commented Jul 6, 2023

Superseded by #38

@ehmry ehmry closed this Jul 6, 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