9.8 Real life flakes: how experienced users structure them
Lesson 66 of 68 · 11:17
Video chapters
-
0:00 Real-World Flake Examples
-
1:14 Exploring the GCAN Flake
-
3:30 Packages, Overlays, and Dev Shells
-
7:10 Treefmt and Flake Checks
-
9:50 Flake Design Advice and Wrap-Up
Transcript
Real-World Flake Examples
0:00 All right, let's look at some real life example flakes. I want to show you how bigger examples look like, what you can expect from a flake, how to use it and stuff like that. Because the examples that we just went through were relatively small or hypothetic or whatever. I just want to give you some insight into how experienced users would use a flake. In general, there's one nice example. We're not opening this in depth now, but what's a little bit funny about this is that from user tazjin there's this project called Nixery.
0:34 It's very nice because tazjin once worked at Google and they implemented Nixery. Nixery is like a Docker registry, but you don't download Docker images that are pre-built from there. What you do is you define in the name of the Docker image what Nix packages you would like to have and would on the fly create a new Docker image for you containing just those Nix packages. Very nice and interesting project. However, they are not a fan of flake. So I just took this and flakified it for training classes to show how a flakified build would look like.
1:09 And that is another real life like example where you can see how a non flake user would build that and how a flake user would build it on top.
The full transcript comes with the lesson.
About this lesson
How do experienced Nix users actually structure their flakes? This lesson reads real repositories: tazjin's Nixery with a flakified build layered on top, and a Rust CLI built with naersk, direnv, treefmt and a full checks setup. You see the overlay-centric layout that keeps a flake composable instead of locking its users in.
In this video
use flakein.envrc: a dev shell that loads itself the moment you enter the folder- Why keeping
callPackagecalls out offlake.nixleaves users free to bring their own nixpkgs - A
formatterblock that drives nixfmt, statix, rustfmt, taplo, prettier and shellcheck from onenix fmt - Clippy and cargo tests wired into
checks, so CI is exactly one command - The habits that make a flake pleasant to inherit, and the ones that make consultants sigh
After this lesson
You can tell a well-structured flake from a tangled one at a glance, and you have a concrete model to copy for your own projects.
Builds on: Flake outputs in depth: packages, apps, checks and more (9.6)
Links:
- Flakified Nixery fork walked through in the video: https://github.com/tfc/nixery
- The original Nixery project: https://github.com/tazjin/nixery
- Rust example project: https://github.com/applicative-systems/gcan
- Rust build framework used there: https://github.com/nix-community/naersk