Nix Expression Language 38 15.1 Values
Total Page:16
File Type:pdf, Size:1020Kb
Nix Package Manager Guide i Nix Package Manager Guide Version 1.11.15 Nix Package Manager Guide ii Copyright © 2004-2014 Eelco Dolstra Nix Package Manager Guide iii COLLABORATORS TITLE : Nix Package Manager Guide ACTION NAME DATE SIGNATURE WRITTEN BY Eelco Dolstra November 2014 REVISION HISTORY NUMBER DATE DESCRIPTION NAME Nix Package Manager Guide iv Contents I Introduction 1 1 About Nix 2 1.1 Multiple versions . .2 1.2 Complete dependencies . .2 1.3 Multi-user support . .2 1.4 Atomic upgrades and rollbacks . .3 1.5 Garbage collection . .3 1.6 Functional package language . .3 1.7 Transparent source/binary deployment . .3 1.8 Nix Packages collection . .4 1.9 Managing build environments . .4 1.10 Portability . .4 1.11 NixOS . .4 1.12 License . .4 2 Quick Start 5 II Installation 7 3 Supported Platforms 9 4 Installing a Binary Distribution 10 5 Installing Nix from Source 11 5.1 Prerequisites . 11 5.2 Obtaining a Source Distribution . 11 5.3 Building Nix from Source . 12 Nix Package Manager Guide v 6 Security 13 6.1 Single-User Mode . 13 6.2 Multi-User Mode . 13 6.2.1 Setting up the build users . 13 6.2.2 Running the daemon . 14 6.2.3 Restricting access . 14 7 Environment Variables 15 III Package Management 16 8 Basic Package Management 18 9 Profiles 21 10 Garbage Collection 23 10.1 Garbage Collector Roots . 24 11 Channels 25 12 One-Click Installation 26 13 Sharing Packages Between Machines 27 13.1 Serving a Nix store via HTTP . 27 13.2 Copying Closures Via SSH . 28 13.3 Serving a Nix store via SSH . 28 IV Writing Nix Expressions 30 14 A Simple Nix Expression 32 14.1 Expression Syntax . 32 14.2 Build Script . 33 14.3 Arguments and Variables . 34 14.4 Building and Testing . 35 14.4.1 Debugging Build Failures . 36 14.5 Generic Builder Syntax . 36 15 Nix Expression Language 38 15.1 Values . 38 15.1.1 Simple Values . 38 15.1.2 Lists . 39 15.1.3 Sets . 40 Nix Package Manager Guide vi 15.2 Language Constructs . 40 15.2.1 Recursive sets . 40 15.2.2 Let-expressions . 41 15.2.3 Inheriting attributes . 41 15.2.4 Functions . 42 15.2.5 Conditionals . 43 15.2.6 Assertions . 43 15.2.7 With-expressions . 44 15.2.8 Comments . 44 15.3 Operators . 44 15.4 Derivations . 45 15.4.1 Advanced Attributes . 46 15.5 Built-in Functions . 48 V Advanced Topics 56 16 Distributed Builds 57 VI Command Reference 59 17 Common Options 61 18 Common Environment Variables 64 19 Main Commands 66 19.1 nix-env . 66 19.2 nix-build . 76 19.3 nix-shell . 78 19.4 nix-store . 81 20 Utilities 93 20.1 nix-channel . 93 20.2 nix-collect-garbage . 94 20.3 nix-copy-closure . 95 20.4 nix-daemon . 96 20.5 nix-hash . 96 20.6 nix-install-package . 98 20.7 nix-instantiate . 99 20.8 nix-prefetch-url . 101 20.9 nix-pull . 102 20.10nix-push . 102 Nix Package Manager Guide vii 21 Files 106 21.1 nix.conf . 106 VII Troubleshooting 110 .1 Collisions in nix-env ................................................. 111 .2 “Too many links” Error in the Nix store . 111 VIII Glossary 112 IX Hacking 115 X Nix Release Notes 117 .3 Release 1.11.10 (2017-06-12).