-
Notifications
You must be signed in to change notification settings - Fork 81
[Proposition] Add nix flake for flow-cli installation and development #2277
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,4 +34,9 @@ main | |
| imports | ||
|
|
||
| # Goreleaser .env | ||
| .release-env | ||
| .release-env | ||
|
|
||
| # Nix build artifacts | ||
| result | ||
| result-* | ||
| .direnv/ | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| { | ||
| description = "Flow CLI - Command-line interface for the Flow blockchain"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
| flake-utils.url = "github:numtide/flake-utils"; | ||
| }; | ||
|
|
||
| outputs = { self, nixpkgs, flake-utils }: | ||
| flake-utils.lib.eachDefaultSystem (system: | ||
| let | ||
| pkgs = import nixpkgs { inherit system; }; | ||
|
|
||
| # Version detection: | ||
| # - When building from a git tag (e.g., nix build github:onflow/flow-cli/v2.14.2), | ||
| # the version is extracted from the tag. | ||
| # - For local development builds, version is "dev" (for nix metadata) and semver | ||
| # is empty so build.go sets it to "undefined", matching Makefile behavior and | ||
| # enabling isDevelopment() checks (skips version warnings and crash reporting). | ||
| isRelease = (self ? ref) && (builtins.match "v[0-9]+\..+" self.ref != null); | ||
| version = | ||
| if isRelease | ||
| then builtins.substring 1 (-1) self.ref # Remove 'v' prefix for nix version | ||
| else "dev"; | ||
| # semver is what gets injected into the Go binary via ldflags. | ||
| # Empty string → build.go init() sets it to "undefined" → isDevelopment() == true | ||
| semver = | ||
| if isRelease | ||
| then self.ref # Full tag with 'v' prefix (e.g., "v2.14.2") | ||
| else ""; | ||
|
|
||
| shortRev = self.shortRev or "dev"; | ||
| in | ||
| { | ||
| packages = { | ||
| flow-cli = pkgs.buildGoModule { | ||
| pname = "flow-cli"; | ||
| version = version; | ||
| src = ./.; | ||
|
|
||
| vendorHash = "sha256-EYQfXvHiRftod45Rvi7dUHF+3G5PyDtdM+HmJsE5r4I="; | ||
| proxyVendor = true; | ||
|
|
||
| subPackages = [ "cmd/flow" ]; | ||
|
|
||
| env = { | ||
| CGO_ENABLED = "1"; | ||
| CGO_CFLAGS = "-O2 -D__BLST_PORTABLE__"; | ||
| }; | ||
|
|
||
| ldflags = [ | ||
| "-s" "-w" | ||
| "-X github.com/onflow/flow-cli/build.semver=${semver}" | ||
| "-X github.com/onflow/flow-cli/build.commit=${shortRev}" | ||
| "-X github.com/onflow/flow-cli/internal/accounts.accountToken=lilico:sF60s3wughJBmNh2" | ||
| "-X github.com/onflow/flow-cli/internal/command.MixpanelToken=3fae49de272be1ceb8cf34119f747073" | ||
| ]; | ||
|
|
||
| preCheck = '' | ||
| export SKIP_NETWORK_TESTS=1 | ||
| ''; | ||
|
|
||
| meta = with pkgs.lib; { | ||
| description = "Command-line interface for the Flow blockchain"; | ||
| homepage = "https://developers.flow.com/tools/flow-cli"; | ||
| license = licenses.asl20; | ||
| mainProgram = "flow"; | ||
| }; | ||
| }; | ||
|
|
||
| default = self.packages.${system}.flow-cli; | ||
| }; | ||
|
|
||
| apps = { | ||
| flow-cli = flake-utils.lib.mkApp { | ||
| drv = self.packages.${system}.flow-cli; | ||
| name = "flow"; | ||
| }; | ||
| default = self.apps.${system}.flow-cli; | ||
| }; | ||
|
|
||
| devShells.default = pkgs.mkShell { | ||
| buildInputs = with pkgs; [ | ||
| go | ||
| golangci-lint | ||
| gotools | ||
| gopls | ||
| delve | ||
| gnumake | ||
| git | ||
| ]; | ||
|
|
||
| CGO_ENABLED = 1; | ||
| CGO_CFLAGS = "-O2 -D__BLST_PORTABLE__"; | ||
janezpodhostnik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| } | ||
| ); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.