1.9 KiB
1.9 KiB
3 part tutorial by Eelco Dolstra
- solves the problem where build inputs are dependent on environment variables, the nix channels, and so forth. These are inconsistent across systems.
- no standard way to compose nix projects
- packages can provide their own
flake.nix
filenix shell github:edolstra/dwarffs --command dwarffs --version
- flakes must declare dependencies, and dependencies must be locked to specific versions
nix flake metadata
will show the flake's dependenciesnix flake show
will show all of the outputsdefaultPackage.<system>
must be a derivation- flakes are specified with a URL-like syntax:
github:edolstra/dwarffs
orgit+https://github.com/NixOS/patchelf
. The flake registery maps symbolic identifiers to actual locations.nixpkgs
is equivalent togithub:NixOS/nixpkgs
. - Registry can be locally overridden:
nix registry add nixpkgs ~/my-nixpkgs
Flake structure:
- description -- string
- inputs -- dictionary which declares all inputs
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-20.03";
- outputs -- function which takes all of the inputs and produces a result
- `outputs = { self, nixpkgs }: { }``
defaultPackage.<system>
devShell.<system>
packages.<system>
All of the so-called "trivial" builders are built on the assumption that a project will be built separately, and that every project lives at the root of the repo. This actually can't work in my case because I do use monorepos and put many crates into a project, and don't necessarily publish all of them to crates.io.