Welcome to the new FlakeHub docs experience!
FlakeHub CLI

fh: the FlakeHub CLI

FlakeHub (opens in a new tab) has a dedicated CLI called fh (opens in a new tab) that you can use to interact with FlakeHub. To run the CLI:

nix run "https://flakehub.com/f/DeterminateSystems/fh/*.tar.gz"

Installation

The nix run command above builds fh locally on your computer. We will be providing pre-built binaries soon.

NixOS

To make the fh CLI readily available on a NixOS (opens in a new tab) system:

{
  description = "My NixOS config.";
 
  inputs.fh.url = "https://flakehub.com/f/DeterminateSystems/fh/*.tar.gz";
  inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.*.tar.gz";
 
  outputs = { nixpkgs, fh, ... } @ inputs: {
    nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        {
          environment.systemPackages = [ fh.packages.x86_64-linux.default ];
        }
 
        # ... the rest of your modules here ...
      ];
    };
  };
}

Interface

fh enables you to do a variety of things:

CommandWhat it doesExample
addAdds a flake input to a flake.nix filefh add ublue-os/fleek
completionProvides auto-completion scripts for a variety of common shellsfh completion bash
initCreates a new flake.nix file for you using a combination of the contents of your project and your user inputfh init
list flakesLists all public flakes on FlakeHubfh list flakes
list orgsLists all public organizations on FlakeHubfh list orgs
list releasesLists all public releases for a flakefh list releases DeterminateSystems/nuenv
list versionsLists all public releases for a flake that match the provided version requirementfh list versions NixOS/nixpkgs "0.2305.*"
searchLists all flakes that match the provided search queryfh search "home manager"

Add

fh add adds the most current release of the specified flake to your flake.nix and updates the outputs function to accept it. This would add the current release of Nixpkgs (opens in a new tab) to your flake:

fh add nixos/nixpkgs

The resulting flake.nix would look something like this:

{
  description = "My new flake.";
 
  inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.490449.tar.gz";
 
  outputs = { nixpkgs, ... } @ inputs: {
    # Fill in your outputs here
  };
}

Shell completion

You can generate shell completion scripts using the fh completion command:

fh completion <shell>

Here's an example:

fh completion bash

These shells are supported:

Initialize flakes from scratch

fh init generates a new flake.nix (opens in a new tab) file for you using a combination of:

  1. Your responses to interactive questions
  2. The contents of the repository in which you run the command.

To create a flake.nix, navigate to the directory where you want to create it and run fh init (or specify a different directory using the --root option). Respond to the prompts it provides you and at the end fh will write a flake.nix to disk.

fh init has built-in support for these languages:

⚠️

fh init operates on a best-guess basis and is opinionated in its suggestions. It's intended less as a comprehensive flake creation solution and more as a helpful kickstarter.

Search

You can search publicly listed flakes using the fh search command and passing in a search query. Here's an example:

fh search rust
+---------------------------------------------------------------------------------+
| Flake                      FlakeHub URL                                         |
+---------------------------------------------------------------------------------+
| astro/deadnix              https://flakehub.com/flake/astro/deadnix             |
| carlthome/ml-runtimes      https://flakehub.com/flake/carlthome/ml-runtimes     |
| ipetkov/crane              https://flakehub.com/flake/ipetkov/crane             |
| kamadorueda/alejandra      https://flakehub.com/flake/kamadorueda/alejandra     |
| nix-community/fenix        https://flakehub.com/flake/nix-community/fenix       |
| nix-community/lanzaboote   https://flakehub.com/flake/nix-community/lanzaboote  |
| nix-community/nix-init     https://flakehub.com/flake/nix-community/nix-init    |
| nix-community/nixpkgs-fmt  https://flakehub.com/flake/nix-community/nixpkgs-fmt |
| nix-community/patsh        https://flakehub.com/flake/nix-community/patsh       |
| ryanccn/nyoom              https://flakehub.com/flake/ryanccn/nyoom             |
+---------------------------------------------------------------------------------+

fh search supports arbitrary search strings. An example:

fh search "rust nixos"

List

fh enables you to list a variety of FlakeHub resources.

List flakes

fh list flakes
+---------------------------------------------------------------------------------------------------------------+
| Flake                                     FlakeHub URL                                                        |
+---------------------------------------------------------------------------------------------------------------+
| ajaxbits/audiobookshelf                   https://flakehub.com/flake/ajaxbits/audiobookshelf                  |
| ajaxbits/tone                             https://flakehub.com/flake/ajaxbits/tone                            |
| astro/deadnix                             https://flakehub.com/flake/astro/deadnix                            |
| ...                                       ...                                                                 |
+---------------------------------------------------------------------------------------------------------------+

List organizations

fh list orgs
+-------------------------------------------------------------------------+
| Organization            FlakeHub URL                                    |
+-------------------------------------------------------------------------+
| ajaxbits                https://flakehub.com/org/ajaxbits               |
| astro                   https://flakehub.com/org/astro                  |
| ...                     ...                                             |
+-------------------------------------------------------------------------+

List releases

fh list releases provides a list of a flake's releases.

fh list releases nixos/nixpkgs
+------------------------------------------------------------+
| Version                                                    |
+------------------------------------------------------------+
| 0.1.428801+rev-2788904d26dda6cfa1921c5abb7a2466ffe3cb8c    |
| 0.1.429057+rev-42337aad353c5efff4382d7bf99deda491459845    |
| 0.1.429304+rev-27ccd29078f974ddbdd7edc8e38c8c8ae003c877    |
| 0.1.429553+rev-5dc7114b7b256d217fe7752f1614be2514e61bb8    |
| 0.1.429868+rev-a115bb9bd56831941be3776c8a94005867f316a7    |
| ...                                                        |
+------------------------------------------------------------+

List versions

Your can list versions of a flake by passing the flake name and a version requirement to fh list versions:

fh list versions <flake> <version_req>

Here's an example:

fh list versions DeterminateSystems/flake-checker "0.1.*"
+------------------------------------------------------------------------------------------------------+
| Simplified version  FlakeHub URL                                                        Full version |
+------------------------------------------------------------------------------------------------------+
| 0.1.0               https://flakehub.com/flake/DeterminateSystems/flake-checker/0.1.0   0.1.0        |
| 0.1.1               https://flakehub.com/flake/DeterminateSystems/flake-checker/0.1.1   0.1.1        |
| 0.1.2               https://flakehub.com/flake/DeterminateSystems/flake-checker/0.1.2   0.1.2        |
| ...                 ...                                                                 ...          |
+------------------------------------------------------------------------------------------------------+

List by label

You can list flakes by label using the fh list label command:

fh list label <label>

Here's an example:

fh list label python
+-------------------------------------------------------------------------------+
| Flake                     FlakeHub URL                                        |
+-------------------------------------------------------------------------------+
| nix-community/poetry2nix  https://flakehub.com/flake/nix-community/poetry2nix |
+-------------------------------------------------------------------------------+