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` file - `nix 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 dependencies - `nix flake show` will show all of the outputs - `defaultPackage.` must be a derivation - flakes are specified with a URL-like syntax: `github:edolstra/dwarffs` or `git+https://github.com/NixOS/patchelf`. The flake registery maps symbolic identifiers to actual locations. `nixpkgs` is equivalent to `github: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.` - `devShell.` - `packages.` - --- - [[Nix Derivation]] 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. - [[Crane]] - [[buildRustPackage]] - [[buildRustCrate]] - [[cargo2nix]] - [[crate2nix]] - [[How can I interrogate a Nix builder]] --- - [Nix Flakes, Part 1: An introduction and tutorial - Tweag](https://www.tweag.io/blog/2020-05-25-flakes/) - [Building Rust WASM projects with Nix | Tom Houle's homepage](https://www.tomhoule.com/2021/building-rust-wasm-with-nix-flakes/)