Some Nix flakes things that I need on a recurring basis.

Inputs

Use nixpkgs from another input

  inputs = {
    tgi-nix.url = "github:danieldk/tgi-nix";
    nixpkgs.follows = "tgi-nix/nixpkgs";
    poetry2nix = {
      url = "github:nix-community/poetry2nix";
      inputs.nixpkgs.follows = "tgi-nix/nixpkgs";
    };
  };

Use a local flake as an input

  inputs = {
    tgi-nix.url = "path:/absolute/path/to/tgi-nix";
  };

Update only one input

# Replace crate2nix by the input to update.
nix flake lock --update-input crate2nix

Binary cache

Cache misses after recent upload

The following sequence can lead to cache misses:

  • Machine 1: build, cancel build
  • Machine 2: push to cache
  • Machine 1: build again, cache miss

See: https://nix.dev/guides/troubleshooting.html#how-to-force-nix-to-re-check-if-something-exists-in-the-binary-cache

Add --narinfo-cache-negative-ttl:

nix build .#foo --narinfo-cache-negative-ttl 0