Skip to content

[Proposition] Add nix flake for flow-cli installation and development#2277

Open
janezpodhostnik wants to merge 1 commit intomasterfrom
janez/nix-flake
Open

[Proposition] Add nix flake for flow-cli installation and development#2277
janezpodhostnik wants to merge 1 commit intomasterfrom
janez/nix-flake

Conversation

@janezpodhostnik
Copy link
Contributor

@janezpodhostnik janezpodhostnik commented Feb 10, 2026

Description

I have been using this flake locally to install flow-cli on NixOs and on NixDarvin. I think it might be nice to add it for anyone else trying to use the flow-cli in a nix environment.

I will also update the install documentation to include Nix.

Eventually I would like to add this to https://github.com/NixOS/nixpkgs. so its even easier to use.

The nix instructions (that I will put in the docs) would be:

Installing Flow CLI with Nix

The Flow CLI can be installed on NixOS and systems with Nix package manager using Nix flakes.

Prerequisites

Ensure you have Nix installed with flakes enabled. Add to /etc/nix/nix.conf or ~/.config/nix/nix.conf:

experimental-features = nix-command flakes

Installation Methods

1. Try Without Installing

Run the latest version directly:

nix run github:onflow/flow-cli

2. Install to User Profile

Install persistently:

nix profile install github:onflow/flow-cli

3. Use in NixOS Configuration

Add to your configuration.nix:

{
  inputs.flow-cli.url = "github:onflow/flow-cli";

  outputs = { self, nixpkgs, flow-cli, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      modules = [
        {
          environment.systemPackages = [
            flow-cli.packages.x86_64-linux.default
          ];
        }
      ];
    };
  };
}

4. Use in Home Manager

Add to your flake inputs and home configuration:

{
  inputs.flow-cli.url = "github:onflow/flow-cli";

  outputs = { self, nixpkgs, home-manager, flow-cli, ... }: {
    homeConfigurations.myuser = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      modules = [
        {
          home.packages = [
            flow-cli.packages.x86_64-linux.default
          ];
        }
      ];
    };
  };
}

5. Development Shell

Enter a development environment with Flow CLI and Go tooling:

nix develop github:onflow/flow-cli

Or for local development:

cd flow-cli
nix develop

Installing Specific Versions

Install a specific version using git tags:

nix profile install github:onflow/flow-cli/v2.14.2

The flake automatically extracts the version from the git tag when building from a tagged ref.

Upgrading

Update to the latest version:

nix profile upgrade flow-cli

Uninstalling

Remove from profile:

nix profile remove flow-cli

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@chasefleming
Copy link
Member

I’m not very familiar with Nix. What are the benefits compared to the additional maintenance this would introduce?

Base automatically changed from janez/cleanup to master February 17, 2026 13:59
@janezpodhostnik
Copy link
Contributor Author

This adds a very convenient way to try/install flow-cli on nixos (or nix-darwin for that matter).

for instance you can just do nix shell github:onflow/flow-cli and it will drop you into a shell where flow-cli is installed and ready to use.

There won't be any additional overhead for any other installation or any parts of the code. The flake.nix (and the lock) might need some adjusting from time to time for continued support of nix installation. I can do that for now, as I will be using it, and if someone complains down the line, they can update it or you can remove it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds Nix flake support for installing and developing the Flow CLI on NixOS and systems with the Nix package manager. This provides an alternative installation and development method that complements the existing installation scripts and build tools (Makefile, goreleaser).

Changes:

  • Added flake.nix with package definition, development shell, and version detection from git tags
  • Added flake.lock to pin Nix dependencies
  • Updated CONTRIBUTING.md with Nix-specific development instructions
  • Updated .gitignore to exclude Nix build artifacts

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.

File Description
flake.nix Defines Nix package build for flow-cli using buildGoModule, development shell with Go tooling, and apps configuration
flake.lock Locks Nix flake dependencies (nixpkgs and flake-utils)
CONTRIBUTING.md Adds "Getting Started with Nix" section with instructions for nix develop and nix build
.gitignore Adds Nix-specific artifacts (result, result-*, .direnv/) to gitignore

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


env = {
CGO_ENABLED = "1";
CGO_CFLAGS = "-O2 -D__BLST_PORTABLE__";
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The CGO_CFLAGS setting is inconsistent with the rest of the codebase. In .goreleaser.yaml (line 18) and Makefile (lines 22, 42), CGO_CFLAGS includes "-std=gnu11" flag, but it's missing in the flake configuration. This could lead to different build behavior when building via Nix compared to other build methods. Add "-std=gnu11" to the CGO_CFLAGS value to maintain consistency.

Copilot uses AI. Check for mistakes.
];

CGO_ENABLED = 1;
CGO_CFLAGS = "-O2 -D__BLST_PORTABLE__";
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The CGO_CFLAGS environment variable in the development shell is inconsistent with the production build settings. Similar to the package build configuration, this should include "-std=gnu11" to match the flags used in .goreleaser.yaml (line 18) and Makefile (lines 22, 42). This ensures that local development builds behave identically to production builds.

Copilot uses AI. Check for mistakes.

ldflags = [
"-s" "-w"
"-X github.com/onflow/flow-cli/build.semver=v${version}"
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

When building locally without a git tag, the version becomes "dev" and the ldflags inject "vdev" as the semver. This is inconsistent with the Makefile behavior (line 46), where an empty VERSION variable results in an empty semver value, which then gets set to "undefined" by build/build.go. Consider using just "dev" without the "v" prefix for consistency, or better yet, use an empty string so it becomes "undefined" to match the existing development build behavior that triggers isDevelopment() checks.

Copilot uses AI. Check for mistakes.
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.

2 participants

Comments