Nix
Reproducible (declarative) builds and deployments.
Create Small Docker Images
- Building and running Docker images: nix.dev Tutorials
Create nix image definition:
cat << 'EOF' > hello.nix
{ pkgs ? import <nixpkgs> { }
, pkgsLinux ? import <nixpkgs> { system = "x86_64-linux"; }
}:
pkgs.dockerTools.buildImage {
name = "hello-docker";
config = {
Cmd = [ "${pkgsLinux.hello}/bin/hello" ];
};
}
EOF
Generate Docker image:
nix-build hello.nix # Outputs image to "result" file
Load Docker image:
docker load < result
Run in Docker:
docker run -t hello-docker:<SHA-1>
References
- NixOS/nix: GitHub Repo
- NixOS/nix: Official Website
- Zero to Nix: An unofficial, opinionated, gentle introduction to Nix.
- Awsome-nix: A curated list of the best resources in the Nix community.