Add Nix flake for installation without nixpkgs - #1733
Draft
stig wants to merge 1 commit into
Draft
Conversation
Lets folks install directly from the repo without waiting for a version
to land in nixpkgs:
nix profile install github:CircleCI-Public/circleci-cli
Or to try it without installing:
nix run github:CircleCI-Public/circleci-cli -- version
The flake builds the `cmd/circleci` subpackage, stamps the short Git
revision as the version, installs bash/fish/zsh completions, and also
exports a dev shell (`nix develop`) with `go` and `go-task`.
Also adds a `nix-build` CI job that installs Nix and runs `nix build`
on every branch, so flake regressions are caught before merge.
The `vendorHash` must be updated whenever `go.mod`/`go.sum` change.
The new hash is printed in the error output of `nix build`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
flake.nixand a pinnedflake.lockso Nix users can install directly from the repo without waiting for a release to land in nixpkgs.The build uses
buildGoModule, stamps the short Git rev as the version string, and installs bash/fish/zsh completions.Trade-off to discuss:
vendorHashbuildGoModulerequires avendorHash— a hash of all downloaded Go module sources. It must be updated whenevergo.modorgo.sumchange. The process is:vendorHashto any wrong value (or leave it as-is after ago.modbump)nix build— it fails with the correct hash in the error outputgot:hash intoflake.nixThis is a one-liner change, but it is an extra manual step on every dependency update.
Is that acceptable? The alternative explored was
gomod2nix, which generates a committed lockfile (gomod2nix.toml) instead of a single hash. The maintenance burden is identical (run a tool aftergo mod tidy), but it doesn't work here becauseclikitis a local Go submodule referenced via areplacedirective —gomod2nixonly handles onego.modat a time and can't see the submodule's packages at build time.So
vendorHashis the practical choice for this repo as it stands.