The official CLI for FlakeHub: search for flakes, and add new inputs to your Nix flake.

Overview

fh, the official FlakeHub CLI

FlakeHub

fh is a scrappy CLI for searching FlakeHub and adding new inputs to your Nix flakes.

Usage

Using fh from FlakeHub:

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

Note: This builds fh locally on your computer. Pre-built binaries aren't yet available.

Installation

NixOS

To make the fh CLI readily available on a NixOS 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 ...
      ];
    };
  };
}

Demo

Initialize a new flake.nix from scratch

fh init generates a new flake.nix 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 the following languages:

Note: 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.

Add a flake published to FlakeHub to your flake.nix

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 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
  };
}

Searching published flakes

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"

Listing 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    |
| ...                                                        |
+------------------------------------------------------------+

Listing flakes, organizations, and versions

fh list flakes, fh list orgs, and fh list versions enumerate flakes, organizations, and flake versions on FlakeHub, respectively.

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 orgs

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

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 comand:

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 |
+-------------------------------------------------------------------------------+

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:

A note on automation

Piping fh list commands to another program emits CSV instead of the stylized table.

You can apply the --json flag to each list command to produce JSON output.

License

Apache 2.0

Support

For support, email [email protected] or join our Discord.

Comments
  • `fh add` is not respecting existing `inputs` structure

    `fh add` is not respecting existing `inputs` structure

    I ran fh add srid/haskell-flake on https://github.com/srid/nixci and this was the result. Note that it has not added haskell-flake under the existing inputs attrset; rather created a flat one at top.

    diff --git a/flake.nix b/flake.nix
    index 732d5c3..771f181 100644
    --- a/flake.nix
    +++ b/flake.nix
    @@ -1,4 +1,5 @@
     {
    +  inputs.haskell-flake.url = "https://flakehub.com/f/srid/haskell-flake/0.4.0.tar.gz";
       inputs = {
         nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
         flake-parts.url = "github:hercules-ci/flake-parts";
    
    opened by srid 6
  • `fh init` doesn't detect JavaScript project

    `fh init` doesn't detect JavaScript project

    Running fh init in a JS project doesn't produce any prompts or add any node/yarn packages.

    Is this a result of a typo here?

    https://github.com/DeterminateSystems/fh/blob/c5643ff58fcebb9d0afdb509f30fb774092ff1c8/src/cli/cmd/init/handlers/javascript.rs#L11

    Presumably, package.jspn -> package.json?

    opened by kpine 2
  • List flake versions matching a constraint

    List flake versions matching a constraint

    Examples:

    fh list versions nixos/nixpkgs "0.2305.*"
    fh list versions DeterminateSystems/nuenv "*"
    fh list versions eza-community/eza "0.10"
    

    Note that this requires a backend change (currently in review).

    image
    opened by lucperkins 1
  • UI nits

    UI nits

    • Create a flake.nix if it doesn't exist already
    • Handle an empty flake by using a template
    • If the flake is empty, like it has just {} (or semantically equivalent), use a template
    opened by grahamc 1
  • Additional inputs

    Additional inputs

    Extends convert to support more cases.

    URI-types become strings:

         fenix = {
    -      url = github:nix-community/fenix;
    +      url = "https://flakehub.com/f/nix-community/fenix/0.1.1618.tar.gz";
           inputs.nixpkgs.follows = "nixpkgs";
         };
    

    and IndentedStrings, such as they are, are converted too:

    -     flake-utils.url = ''github:numtide/flake-utils'';
    +     flake-utils.url = ''https://flakehub.com/f/numtide/flake-utils/0.1.87.tar.gz'';
    

    and nixpkgs/release-mm.yy are supported -- migrated to releases now.

    Also, while running fh across every determinatesystems project, I found another issue. When a flake.nix looks like this:

    {
      inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    
      inputs.rust-overlay.url = "github:oxalica/rust-overlay";
      inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
    

    rust-overlay's input URL appears to be replaced with "nixpkgs", causing the result to be:

    {
      inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.532072.tar.gz";
    
      inputs.rust-overlay.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.532072.tar.gz";
      inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
    

    I fixed this as well by not considering inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; to be an input line.

    opened by grahamc 0
  • Enable listing flakes by label

    Enable listing flakes by label

    I'm marking this as a draft because it depends on backend changes, namely returning project/org for the flake instead of name/org. I could've used Serde aliasing for that but I'd prefer to streamline the backend instead.

    opened by lucperkins 0
Releases(v0.1.6)
  • v0.1.6(Oct 5, 2023)

    What's Changed

    • Add fh init docs to README by @lucperkins in https://github.com/DeterminateSystems/fh/pull/35
    • Add badge to README by @lucperkins in https://github.com/DeterminateSystems/fh/pull/36
    • Reorder 23.05 below latest stable, and note latest is the current stable by @grahamc in https://github.com/DeterminateSystems/fh/pull/38
    • Add version flag by @lucperkins in https://github.com/DeterminateSystems/fh/pull/37
    • jspn -> json by @grahamc in https://github.com/DeterminateSystems/fh/pull/41
    • Enable listing flakes by label by @lucperkins in https://github.com/DeterminateSystems/fh/pull/42
    • Sort systems by @grahamc in https://github.com/DeterminateSystems/fh/pull/39
    • Add flake schemas to generated flake.nix files by @lucperkins in https://github.com/DeterminateSystems/fh/pull/43
    • Add prompt for Deno projects by @lucperkins in https://github.com/DeterminateSystems/fh/pull/44
    • Add Elm support by @lucperkins in https://github.com/DeterminateSystems/fh/pull/45
    • Remove api. from FlakeHub URLs and run flake update by @lucperkins in https://github.com/DeterminateSystems/fh/pull/47
    • Add Bazel support by @lucperkins in https://github.com/DeterminateSystems/fh/pull/48
    • Improve the UX around fh init by @lucperkins in https://github.com/DeterminateSystems/fh/pull/49
    • Patch version bump to 0.1.6 by @lucperkins in https://github.com/DeterminateSystems/fh/pull/50

    Full Changelog: https://github.com/DeterminateSystems/fh/compare/v0.1.5...v0.1.6

    Source code(tar.gz)
    Source code(zip)
    fh-X64-Linux(13.92 MB)
    fh-X64-macOS(11.65 MB)
  • v0.1.5(Sep 19, 2023)

    What's Changed

    • fix(nix): correct shell completion command name by @ryanccn in https://github.com/DeterminateSystems/fh/pull/32
    • Polish up README by @lucperkins in https://github.com/DeterminateSystems/fh/pull/30
    • Add an fh init command by @lucperkins in https://github.com/DeterminateSystems/fh/pull/16
    • Add hooks for error reporting by @lucperkins in https://github.com/DeterminateSystems/fh/pull/33
    • Bump to version 0.1.5 by @lucperkins in https://github.com/DeterminateSystems/fh/pull/34

    Full Changelog: https://github.com/DeterminateSystems/fh/compare/v0.1.4...v0.1.5

    Source code(tar.gz)
    Source code(zip)
    fh-X64-Linux(13.92 MB)
    fh-X64-macOS(11.61 MB)
  • v0.1.4(Sep 15, 2023)

    What's Changed

    • Add docstring for flake option by @lucperkins in https://github.com/DeterminateSystems/fh/pull/28
    • feat: add shell completions by @ryanccn in https://github.com/DeterminateSystems/fh/pull/26
    • fh add: allow specifying where new inputs should go by @cole-h in https://github.com/DeterminateSystems/fh/pull/25
    • List flake versions matching a constraint by @lucperkins in https://github.com/DeterminateSystems/fh/pull/27
    • Enable JSON output for lists by @lucperkins in https://github.com/DeterminateSystems/fh/pull/29
    • Bump version to 0.1.4 by @lucperkins in https://github.com/DeterminateSystems/fh/pull/31

    New Contributors

    • @ryanccn made their first contribution in https://github.com/DeterminateSystems/fh/pull/26

    Full Changelog: https://github.com/DeterminateSystems/fh/compare/v0.1.3...v0.1.4

    Source code(tar.gz)
    Source code(zip)
    fh-X64-Linux(12.60 MB)
    fh-X64-macOS(10.46 MB)
  • v0.1.3(Sep 4, 2023)

  • v0.1.2(Sep 1, 2023)

    What's Changed

    • fh add: test some stuff by @cole-h in https://github.com/DeterminateSystems/fh/pull/17
    • Don't duplicate input names in outputs by @cole-h in https://github.com/DeterminateSystems/fh/pull/18
    • fh add: try to match existing inputs styles by @cole-h in https://github.com/DeterminateSystems/fh/pull/19
    • Setup tracing by @cole-h in https://github.com/DeterminateSystems/fh/pull/20
    • Release v0.1.2 by @cole-h in https://github.com/DeterminateSystems/fh/pull/21

    Full Changelog: https://github.com/DeterminateSystems/fh/compare/v0.1.1...v0.1.2

    Source code(tar.gz)
    Source code(zip)
    fh-X64-Linux(12.29 MB)
    fh-X64-macOS(10.23 MB)
Owner
Determinate Systems
The best software development toolkit for Nix and Flakes ❄️
Determinate Systems
A `nix` and `nix-shell` wrapper for shells other than `bash`

nix-your-shell A nix and nix-shell wrapper for shells other than bash. nix develop and nix-shell use bash as the default shell, so nix-your-shell prin

Mercury 15 Apr 10, 2023
Progress In Nix - Pacman inspired frontend for Nix

Progress In Nix Pinix is a Pacman inspired frontend for Nix. It wraps a regular Nix command and replaces the output with a more modern and informative

Rémi Dupré 23 Mar 9, 2024
rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and much more.

rpsc rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and mu

null 3 Dec 15, 2022
Add CLI & form interface to your program

Add CLI & form interface to your program

null 292 Nov 4, 2022
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
Run if inputs have changed, otherwise use cache

Boost Why Boost? Our planet is burning, and everywhere I look I see CI pipelines repeating work that has already been done. Tools such as TurboRepo, N

Stuart Harris 6 Jul 28, 2022
Pure Rust Fault Proof Program that runs the rollup state-transition to verify an L2 output from L1 inputs.

palmtop palmtop is a fault proof program that runs the rollup state transition to verify an L2 output from L1 inputs. The verifiable L2 output can the

Anton Systems 5 Sep 26, 2023
A simple CLI utility to add rounded borders, padding, and shadows to images.

shadower a simple command-line utility to add rounded corners and shadows to images Installation From AUR paru -S shadower-git From source cargo build

Michał 5 Mar 16, 2023
A CLI tool you can pipe code and then ask for changes, add documentation, etc, using the OpenAI API.

AiBro This is your own little coding bro, immersed in the world of AI, crypto, and all other types of over hyped tech trends. You can pipe it code and

Josh Bainbridge 5 Sep 5, 2023
Shell Of A New Machine: Quickly configure new environments

Shell Of A New Machine soanm is a dead-simple tool for easily configuring new UNIX machines, with almost zero prerequisites on the target machine. All

Ben Weinstein-Raun 41 Dec 22, 2022
Simple CLI to (add, delete, update, create) i18n translation file 🔤 🦀

, Inrs Simple CLI to (add, delete, update, create) i18n translation file Copyright (C) 2020-2022 TheAwiteb https://github.com/TheAwiteb/inrs This pr

TheAwiteb 4 Oct 4, 2022
SvelteUI Official CLI written in Rust

SvelteUI Official CLI The cli will be written in Rust ?? . This CLI as of now (04/30/22) will be used for scaffolding new projects, and creating boile

SvelteUI 3 Sep 13, 2022
Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed.

nixseparatedebuginfod Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed

Guillaume Girol 16 Mar 6, 2023
This tool will profile official instances of OpenSUSE mirrorcache to determine the fastest repositories for your system

Mirror Magic tool to Magically make OpenSUSE Mirrors Magic-er This tool will profile official instances of OpenSUSE mirrorcache to determine the faste

Firstyear 30 Dec 22, 2022
SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

Gabriel Michaliszen 4 May 9, 2023
A simple gtk4/libadwaita software center to easily install and manage nix packages

Nix Software Center A graphical app store for Nix built with libadwaita, GTK4, and Relm4. Heavily inspired by GNOME Software. Features Install package

Victor Fuentes 169 Dec 30, 2022
Add path effects to open glyphs in a UFO file

ufostroker Add path effects to open contours in a UFO file Given a glyph with open contours: You can apply a noodle effect: ufostroker -i Open.ufo -o

Simon Cozens 5 Jun 28, 2021
Generate commands that add node_modules/.bin to PATH

npx-bin-helper Generate commands that add node_modules/.bin to PATH. Supports Linux, MacOS and Windows. Installation cargo install npx-bin-helper Usag

Yumeoto Zorin 2 Nov 11, 2022
This is a placeholder repository for Ludum Dare 52. We'll add more soon!

Ludum Dare 52 This is a placeholder repository for Ludum Dare 52. How to play TBD Developing Only Rust (edition 2021) is required to develop and build

Matan Lurey 4 Jan 9, 2023