I love obscure software

19/10/2026

Acknowledgments

Finding good software that fits your use cases is becoming increasingly easier, albeit with the risks of being ethically terrible.

Some platforms that do an amazing job with discoverability whilst being decentralised:

Nix workflows on non-Nix systems

In all my projects I use Nix, and define my Git hooks using Cachix’s git-hooks.nix – this has worked fine, till today. Nebu is meant to be a project that’s worked on by multiple people, thus, I can’t expect all of them to use Nix.

git-hooks.nix uses pre-commit which sounds really good in practice but in my experience it’s messy, even more so if you try getting it to work on non-Nix systems.

Nixhooks saves the day

Whilst searching for solutions to this apparently niche issue, I stumbled upon a Discourse post that talked about a lighter alternative to git-hooks.nix: nixhooks

Despite being relatively new, it has quite the amount of features, and speed isn’t any inferior, especially compared to pre-commit (it is more or less on par with prek, being faster when parallel.)

What’s different

So then, how does nixhooks solve my issue, you might ask?

nixhooks provides a portable option which, when set to true, generates hooks that will execute the binary on your system if they aren’t in the Nix store.

Here’s an example:

hooks.nix
{pkgs, system, nixhooks, ... }: let
  inherit (nixhooks.lib.${system}) presets mkHooks;
  inherit (pkgs) lib;
in mkHooks {
  inherit (presets) statix;
 
  nixfmt = {
    entry = lib.getExe pkgs.nixfmt;
    args = [ "--check" ];
    files = "\\.nix$";
    serial = false;
  };
 
  settings.portable = {
    enable = true;
    dir = ".github/hooks";
  };
}
flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixhooks.url = "git+https://tangled.org/poacher.dev/nixhooks";
  };
 
  outputs =
    inputs@{self, nixpkgs, nixhooks}: let
      hooks = import ./hooks.nix inputs;
    in {
      devShells.x86_64-linux.default = hooks.wrapShell (pkgs.mkShell {});
 
      packages.x86_64-linux = hooks.packages;
      apps.x86_64-linux = hooks.apps;
    };
}

As it is now, it’s pretty much on par with what git-hooks.nix does, with a much neater syntax and commands you can run to generate your hooks:

~/P/w/workspace main $ nix flake show
git+file:///Users/drainpixie/workspace
└──apps
    └───x86_64-linux
        ├───check-portable-hooks omitted (use '--all-systems' to show)
        ├───gen-portable-hooks omitted (use '--all-systems' to show)
        ├───install-hooks: app: no description
        ├───pre-commit-hook: app: no description
        ├───pre-push-hook: app: no description
        └───run-hooks: app: no description
 
...

Now, if we run nix run ".#gen-portable-hooks", our .github/hooks folder will be populated; all that’s left to do is to tell Git about it:

$ git config core.hooksPath .github/hooks

And that’s it! as simple as that. As long as a non-Nix user has the necessary tools installed, the hooks will run as they would on a Nix system.

Some more goodies

As an extra, nixhooks can also generate workflow files compatible with both Tangled and Github Actions:

mkHooks {
  # ...
 
 settings = {
   # ...
 
  tangled = {
    enable = true;
    attr = "run-hooks";
    flake = true;
    engine = "microvm";
    when = [
      {
        event = ["push" "pull_request"];
        branch = ["main"];
      }
    ];
  };
 
  githubActions = {
    enable = true;
    attr = "run-hooks";
    flake = true;
    runsOn = "ubuntu-latest";
    cache = true;
    on = {
      push.branches = [ "main" ];
      pull_request.branches = [ "main" ];
    };
  };
 };
};
 

And now you’ll get these too:

~/P/w/workspace main $ nix flake show
git+file:///Users/drainpixie/workspace
└──apps
    └───x86_64-linux
        ├───gen-github-actions-workflow omitted (use '--all-systems' to show)
        └───gen-tangled-pipeline omitted (use '--all-systems' to show)
 
...

Ex tenebris lux

A Latin phrase meaning “out of darkness, light”

This post is meant to bring some light to a library that would othewise remain sadly pretty unknown, and I hope more people start doing the same.

Huge props to Poacher for being immensely helpful whilst trying out nixhooks