A CLI tool for automatically pinning/updating Nix flake inputs to their latest GitHub commits.
🚧 Status: In Development
This tool is currently under development and not yet functional.
flake-pin takes a flake input name and updates it to the latest commit from GitHub:
- Reads your
flake.lockto find the current state of the input - Fetches the latest commit hash from the GitHub API
- Updates your
flake.nixto pin the input to the latest commit (first 7 characters) - Adds or updates a comment with the commit date (UTC) in ISO-8601 format
Although packages can be pinned individually by using the flake lock API, explicit pinning in the flake file:
- pins are prominently visible near the top of the flake file, and
- enables use of
flake updatewith granular control of what is pinned.
- 🛟 Type-safe parsing and modification of Nix files
- 🚀 Uses GitHub API for reliable commit information
- 📝 Automatic date comments
emacs-overlay.url = "github:nix-community/emacs-overlay";flake-pin --input emacs-overlay /path/to/your/flakeemacs-overlay.url = "github:nix-community/emacs-overlay/8dc6642"; # 2025-06-18Add to your flake inputs, or run directly.
nix run github:what-the-functor/flake-pin -- --input emacs-overlay /path/to/flakegit clone https://github.com/what-the-functor/flake-pin
pushd flake-pin
cabal installflake-pin --input <input-name> <flake-path>input-name: The name of the flake input to update (e.g., "nixpkgs", "emacs-overlay")flake-path: Path to the directory containing theflake.nixfile
git clone https://github.com/what-the-functor/flake-pin
pushd flake-pin
nix develop
cabal build
cabal testRequirements:
- GHC 9 (tested with 9.8.4)
- Cabal
- Fourmolu
cabal build
cabal testThis project uses TDD with property-based testing. Pull requests should include tests for new functionality. Format with Fourmolu
MIT