Flakes — nix.dev documentation (2024)

What is usually referred to as “flakes” is:

  • A policy for managing dependencies between Nix expressions.

  • An experimental feature in Nix, implementing that policy and supporting functionality.

What are flakes?#

Technically, a flake is a file system tree that contains a file named flake.nix in its root directory.

Flakes add the following behavior to Nix:

  1. A flake.nix file enforces a schema, where:

    • Other flakes are referenced as dependencies providing Nix language code or other files.

    • The values produced by the Nix expressions in flake.nix are structured according to pre-defined use cases.

  2. References to other flakes can be specified using a dedicated URL-like syntax.A flake registry allows using symbolic identifiers for further brevity.References can be automatically locked to their current specific version and later updated programmatically.

  3. A new command line interface, implemented as a separate experimental feature, leverages flakes by accepting flake references in order to build, run, or deploy software defined as a flake.

Nix handles flakes differently than regular Nix files in the following ways:

  • The flake.nix file is checked for schema validity.

    In particular, the metadata fields cannot be arbitrary Nix expressions.This is to prevent complex, possibly non-terminating computations while querying the metadata.

  • The entire flake directory is copied to Nix store before evaluation.

    This allows for effective evaluation caching, which is relevant for large expressions such as Nixpkgs, but also requires copying the entire flake directory again on each change.

  • No external variables, parameters, or impure language values are allowed.

    It means full reproducibility of a Nix expression, and, by extension, the resulting build instructions by default, but also prohibits parameterisation of results by consumers.

Why are flakes controversial?#

Flakes were inspired by Shea Levy’s NixCon 2018 talk, formally proposed in RFC 49, and have been in development since 2019.Nix introduced the implementation as its first experimental feature in 2021.

The subject is considered controversial among Nix users and developers in terms of design, implementation quality, and decision making process.In particular:

This led to a situation where the stable interface was only sparsely maintained for multiple years, and repeatedly suffered breakages due to ongoing development.Meanwhile, the new interface was adopted widely enough for evolving its design without negatively affecting users to become very challenging.

As of the 2023 survey, 84% of the respondents rely on experimental features.Nixpkgs as a contrasting example, while featuring a flake.nix for compatibility, does not depend on Nix experimental features in its code base.

Should I use flakes in my project?#

You have to judge for yourself based on your needs.

Flakes emphasize reproducible artifacts and convenience for their consumers, while classic Nix tools center around composable building blocks and customisation options for developers.Both paradigms have their own set of unique concepts and support tooling that have to be learned, with varying ease of use, implementation quality, and support status.At the moment, neither the stable nor the experimental interface is clearly superior to the other in all aspects.

Flakes and the nix command suite bring multiple improvements that are relevant for both software users and package authors:

  • The new command-line interface, together with flakes, makes dealing with existing packages significantly more convenient in many cases.

  • The constraints imposed on flakes strengthen reproducibility by default, and enable some performance improvements when interacting with a large Nix package repository like Nixpkgs.

  • Flake references allow for easier handling of version upgrades for existing packages or project dependencies.

  • The flake schema helps with composing Nix projects from multiple sources in an orderly fashion.

At the same time, flakes have fundamental architectural issues and a number of problems with the implementation, and there is no coordinated effort to resolve them systematically.There are also still many open design questions around the nix command line interface, some of which are currently being worked on.

While flakes reduce complexity in some regards, they also introduce some with additional mechanisms.You will have to learn more about the system to fully understand how it works.

Other than that, and below the surface of the flake schema, Nix and the Nix language work exactly the same in both cases.In principle, the same level of reproducibility can be achieved with or without flakes.In particular, the process of adding software to Nixpkgs or maintaining NixOS modules and configurations is not affected by flakes at all.There is also no evidence that flakes could help solving the scalability challenges of either.

Finally, there are downsides to relying on experimental features in general:

  • Interfaces and behavior of experimental features could still be changed by Nix developers.This may require you to adapt your code at some point in the future, which will be more effort when it has grown in complexity.Currently there is no concrete timeline for stabilising flakes.In contrast, stable features in Nix can be considered stable indefinitely.

  • The Nix maintainer team focuses on fixing bugs and regressions in stable interfaces, supporting well-understood use cases, as well as improving the internal design and overall contributor experience in order to ease future development.Improvements to experimental features have low priority.

  • The Nix documentation team focuses on improving documentation and learning materials for stable features and common principles.When using flakes, you will have to rely more heavily on user-to-user support, third-party documentation, and the source code.

Further reading#

Flakes — nix.dev  documentation (2024)
Top Articles
Social Security History
The Average Savings Account Balance In The U.S. | Bankrate
No Hard Feelings Showtimes Near Metropolitan Fiesta 5 Theatre
Musas Tijuana
Ksat Doppler Radar
Between Friends Comic Strip Today
Fbsm Berkeley
T-Mobile SW 56th Street & SW 137th Ave | Miami, FL
Gopher Hockey Forum
Anonib Altoona Pa
Morbus Castleman - Ursachen, Symptome & Behandlung
Walmart Tire Service Hours
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
Pokewilds Wiki
Jordanbush Only Fans
Skyward New Richmond Wi
Western Gold Gateway
Asoiaf Spacebattles
Iapd Lookup
Strange World Showtimes Near Marcus La Crosse Cinema
Varsity Tutors, a Nerdy Company hiring Remote AP Calculus AB Tutor in United States | LinkedIn
Clarksville.craigslist
Tamilblasters Movie Download Isaimini
C.J. Stroud und Bryce Young: Zwei völlig unterschiedliche Geschichten
Exploring IranProud: A Gateway to Iranian Entertainment
Theater X Orange Heights Florida
Used Travel Trailers Under $5000 Craigslist
Telegram Voyeur
Walgreens Pharmacy | Manage Prescriptions, Transfers, and Refills
Janice Templeton Butt
Arapahoe Youth League Baseball
Lufthansa LH456 (DLH456) from Frankfurt to Los Angeles
Www.citizen-Times.com Obituaries
Coverwood Terriers For Sale
Cbs Scores Mlb
Late Bloomers Summary and Key Lessons | Rich Karlgaard
Notifications & Circulars
Kurlyrose
Roses Gordon Highway
Stony Brook Citrix Login
iPhone reconditionné
Bulk Amateur 51 Girls Statewins Leak – BASL058
Top Dog Boarding in The Hague with Best Prices on PetBacker
Vegan Eggplant Parmesan
What Is Opm1 Treas 310 Deposit
Legend Of Krystal Forums
Bucks County fall festivals and events to keep you busy through the season
Basketball Stars Unblocked Games Premium
Synergy Grand Rapids Public Schools
Ladyva Is She Married
The Emperor's New Groove | Rotten Tomatoes
Pnp Telegram Group
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 6238

Rating: 4.7 / 5 (57 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.