Nix provides flakes
as a way to expose packages, OS configuration and so on using version-pinned dependencies[1].
A flake.nix
file has to define at least an outputs
element[2]. inputs
element is used to inject dependencies. The description
field is optional:
{
inputs = <<inputs>>;
outputs = <<outputs>>;
}
inputs
is an attribute set (like a hashmap or dictionary in other languages). We are building a NixOS configuration here, so we take the nixpkgs
repository as an input to access its wast package repository and configuration system:
{
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
<<flake-inputs>>
}
outputs
is a function accepting the evaluated inputs
as its argument, and returning another attribute set.
{ self, ... }@inputs: {
<<flake-outputs>>
}
References
[1]
“Flakes - NixOS Wiki,” Nixos.wiki. Accessed: Aug. 17, 2024. [Online]. Available: https://nixos.wiki/wiki/flakes
[2]
A. Wenger, “Making a dev shell with nix flakes,” Fasterthanli.me. Accessed: Aug. 17, 2024. [Online]. Available: https://fasterthanli.me/series/building-a-rust-service-with-nix/part-10