Hey everyone,
After last week’s launch of FlakeHub, one of the most frequent requests was for a CLI. Today, we’re publishing the first release of fh
, the FlakeHub CLI.
Today’s release is a scrappy one, but it solves a few tasks:
- Searching for existing flakes, including listing all the flakes and organizations.
- Adding flakes to your flake.nix
- Listing all the revisions of a published flake.
Here’s our announcement blog post: `fh`: the CLI for FlakeHub
Here’s our project on FlakeHub: FlakeHub
Adding flakes
To add a flake to your project, use fh add nixos/nixpkgs
. You can even start with an empty file, and fh
will bootstrap one for you:
$ fh add nixos/nixpkgs
$ cat flake.nix
{
description = "My new flake.";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.490449.tar.gz";
outputs = { nixpkgs, ... } @ inputs: {};
}
I really like that it updates the outputs
function to accept your new input:
$ fh add nix-community/nix-melt
$ cat flake.nix
{
description = "My new flake.";
inputs.nix-melt.url = "https://flakehub.com/f/nix-community/nix-melt/0.1.8.tar.gz";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.490449.tar.gz";
outputs = { nixpkgs, nix-melt, ... } @ inputs: {};
}
If the project you’re interested in isn’t published to FlakeHub yet, you can add that too:
$ fh add github:nix-community/naersk
$ cat flake.nix
{
description = "My new flake.";
inputs.naersk.url = "github:nix-community/naersk";
inputs.nix-melt.url = "https://flakehub.com/f/nix-community/nix-melt/0.1.8.tar.gz";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.490449.tar.gz";
outputs = { nixpkgs, nix-melt, naersk, ... } @ inputs: {};
}
Listing releases
A lot of people used a service I used to maintain, channels.nix.gsc.io, to see all the releases of NixOS channels over time. FlakeHub has archived every release of nixos-23.05, and approximately the last nine months of nixos-unstable.
Bisecting nixpkgs
You can list the releases of the NixOS/nixpkgs flake, and use this to help bisect:
$ fh list releases nixos/nixpkgs
+------------------------------------------------------------+
| Version |
+------------------------------------------------------------+
| 0.1.428801+rev-2788904d26dda6cfa1921c5abb7a2466ffe3cb8c |
| 0.1.429057+rev-42337aad353c5efff4382d7bf99deda491459845 |
| 0.1.429304+rev-27ccd29078f974ddbdd7edc8e38c8c8ae003c877 |
...
| 0.2305.490435+rev-c540061ac8d72d6e6d99345bd2d590c82b2f58c1 |
| 0.2305.490449+rev-2ab91c8d65c00fd22a441c69bbf1bc9b420d5ea1 |
+------------------------------------------------------------+
Versions 0.1.x refer to nixos-unstable
, and 0.2305 refer to nixos-23.05
.
We can pipe this output to grep
to only get 23.05 releases, and cut
to get only the revisions for git bisect
:
$ fh list releases nixos/nixpkgs | grep 2305 | cut -d- -f2
453bb832f715dd6e51004c72dbd59b1556d554e1
c7ff1b9b95620ce8728c0d7bd501c458e6da9e04
aaef163eac75c2ac7f882c1fae4e0c08aa18d186
572d26930456132e7f2035340e3d88b36a5e9b6e
They’re ordered by semver, so the oldest releases are at the top, and the newest releases are at the end.
Anyway, this is a first step for fh, but in the future it’ll support pushing from your local machine, or from other CI / forges like GitLab. FlakeHub is the largest collection of flakes, backed by the power of search. People have been asking for something like fh add
for ages, and I’m really glad we could make that work nicely.
I hope you like it!