|
| 1 | +{ |
| 2 | + description = "Flow CLI - Command-line interface for the Flow blockchain"; |
| 3 | + |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | + flake-utils.url = "github:numtide/flake-utils"; |
| 7 | + }; |
| 8 | + |
| 9 | + outputs = { self, nixpkgs, flake-utils }: |
| 10 | + flake-utils.lib.eachDefaultSystem (system: |
| 11 | + let |
| 12 | + pkgs = import nixpkgs { inherit system; }; |
| 13 | + |
| 14 | + # Version detection: |
| 15 | + # - When building from a git tag (e.g., nix build github:onflow/flow-cli/v2.14.2), |
| 16 | + # the version is automatically extracted from the tag: "2.14.2" |
| 17 | + # - For local development builds, version is "dev" |
| 18 | + # This eliminates the need for a separate VERSION file and keeps version |
| 19 | + # management in sync with git tags used for releases. |
| 20 | + version = |
| 21 | + if (self ? ref) && (builtins.match "v[0-9]+\..+" self.ref != null) |
| 22 | + then builtins.substring 1 (-1) self.ref # Remove 'v' prefix from version tags |
| 23 | + else "dev"; |
| 24 | + |
| 25 | + shortRev = self.shortRev or "dev"; |
| 26 | + in |
| 27 | + { |
| 28 | + packages = { |
| 29 | + flow-cli = pkgs.buildGoModule { |
| 30 | + pname = "flow-cli"; |
| 31 | + version = version; |
| 32 | + src = ./.; |
| 33 | + |
| 34 | + vendorHash = "sha256-EYQfXvHiRftod45Rvi7dUHF+3G5PyDtdM+HmJsE5r4I="; |
| 35 | + proxyVendor = true; |
| 36 | + |
| 37 | + subPackages = [ "cmd/flow" ]; |
| 38 | + |
| 39 | + env = { |
| 40 | + CGO_ENABLED = "1"; |
| 41 | + CGO_CFLAGS = "-O2 -D__BLST_PORTABLE__"; |
| 42 | + }; |
| 43 | + |
| 44 | + ldflags = [ |
| 45 | + "-s" "-w" |
| 46 | + "-X github.com/onflow/flow-cli/build.semver=v${version}" |
| 47 | + "-X github.com/onflow/flow-cli/build.commit=${shortRev}" |
| 48 | + "-X github.com/onflow/flow-cli/internal/accounts.accountToken=lilico:sF60s3wughJBmNh2" |
| 49 | + "-X github.com/onflow/flow-cli/internal/command.MixpanelToken=3fae49de272be1ceb8cf34119f747073" |
| 50 | + ]; |
| 51 | + |
| 52 | + preCheck = '' |
| 53 | + export SKIP_NETWORK_TESTS=1 |
| 54 | + ''; |
| 55 | + |
| 56 | + meta = with pkgs.lib; { |
| 57 | + description = "Command-line interface for the Flow blockchain"; |
| 58 | + homepage = "https://developers.flow.com/tools/flow-cli"; |
| 59 | + license = licenses.asl20; |
| 60 | + mainProgram = "flow"; |
| 61 | + }; |
| 62 | + }; |
| 63 | + |
| 64 | + default = self.packages.${system}.flow-cli; |
| 65 | + }; |
| 66 | + |
| 67 | + apps = { |
| 68 | + flow-cli = flake-utils.lib.mkApp { |
| 69 | + drv = self.packages.${system}.flow-cli; |
| 70 | + name = "flow"; |
| 71 | + }; |
| 72 | + default = self.apps.${system}.flow-cli; |
| 73 | + }; |
| 74 | + |
| 75 | + devShells.default = pkgs.mkShell { |
| 76 | + buildInputs = with pkgs; [ |
| 77 | + go |
| 78 | + golangci-lint |
| 79 | + gotools |
| 80 | + gopls |
| 81 | + delve |
| 82 | + gnumake |
| 83 | + git |
| 84 | + ]; |
| 85 | + |
| 86 | + CGO_ENABLED = 1; |
| 87 | + CGO_CFLAGS = "-O2 -D__BLST_PORTABLE__"; |
| 88 | + }; |
| 89 | + } |
| 90 | + ); |
| 91 | +} |
0 commit comments