Nix: Difference between revisions
From wikinotes
(→Usage) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 46: | Line 46: | ||
</blockquote><!-- Documentation --> | </blockquote><!-- Documentation --> | ||
= Tutorials = | |||
<blockquote> | |||
See [[nix tutorials]]. | |||
</blockquote><!-- Tutorials --> | |||
= Locations = | = Locations = | ||
Line 58: | Line 64: | ||
|- | |- | ||
!colspan=2| User Config | !colspan=2| User Config | ||
|- | |||
| <code>~/.config/nix/config.nix</code> || nix config | |||
|- | |- | ||
| <code>~/.config/nixpkgs/config.nix</code> || nixpkgs config (overrides, overlays, etc) | | <code>~/.config/nixpkgs/config.nix</code> || nixpkgs config (overrides, overlays, etc) | ||
Line 75: | Line 83: | ||
| <code>~/.nix-profile</code> || ''active'' profile definition | | <code>~/.nix-profile</code> || ''active'' profile definition | ||
|- | |- | ||
| <code>~/.nix-channels</code> || | | <code>~/.nix-channels</code> || | ||
|- | |- | ||
!colspan=2| Logs | !colspan=2| Logs | ||
Line 91: | Line 99: | ||
</blockquote><!-- overview --> | </blockquote><!-- overview --> | ||
= | = Setup = | ||
<blockquote> | <blockquote> | ||
{| | {| | ||
|- | |- | ||
| [[nix install]] | | [[nix install]] | ||
|- | |- | ||
| [[nix configuration]] | | [[nix configuration]] | ||
Line 107: | Line 109: | ||
| [[nixpkgs configuration]] | | [[nixpkgs configuration]] | ||
|- | |- | ||
|} | |||
</blockquote><!-- Setup --> | |||
= Usage = | |||
<blockquote> | |||
== Package Management == | |||
<blockquote> | |||
{| | |||
| [[nix usage]] | | [[nix usage]] | ||
|- | |||
| [[nix flakes usage]] | |||
|- | |- | ||
|} | |} | ||
</blockquote><!-- Package Management --> | |||
== Project Management == | |||
<blockquote> | |||
{| | {| | ||
| [[nix packages]] | | [[nix packages]] | ||
Line 118: | Line 132: | ||
|- | |- | ||
|} | |} | ||
</blockquote><!-- Project Management --> | |||
== General == | |||
<blockquote> | |||
{| | {| | ||
|- | |- | ||
Line 126: | Line 143: | ||
|- | |- | ||
| [[nix tips and tricks]] | | [[nix tips and tricks]] | ||
|- | |||
|} | |} | ||
</blockquote><!-- General --> | |||
</blockquote><!-- notes --> | </blockquote><!-- notes --> | ||
Line 158: | Line 177: | ||
|- | |- | ||
| [[nix ruby]] | | [[nix ruby]] | ||
|- | |||
| [[nix golang]] | |||
|- | |- | ||
| [[nix java]] | | [[nix java]] |
Latest revision as of 15:03, 18 December 2022
Nix is a package manager that enables composing environments with specific versions of packages.
multiple versions of packages can be installed at once, but only one is enabled at a time.
Nix is divided into a few different components.
- nix is a package manager
- nixpkgs exposes/configures/overrides packages from a nix repo
- nixos (optional) is a linux distro built around the use of nix
The tool nix home-manager is useful for configuring user environments.
Documentation
General nixos docs https://nixos.org/nix/manual/ nixos unstable docs https://nixos.org/manual/nix/unstable/introduction.html nixpkgs docs https://nixos.org/nixpkgs/manual/ nix pills https://nixos.org/nixos/nix-pills/index.html github (nix) https://github.com/NixOS/nix github (nixpkgs) https://github.com/NixOS/nixpkgs homepage https://nixos.org/ wiki https://nixos.wiki/wiki/Main_Page forum https://discourse.nixos.org/ Syntax expressions https://nixos.org/nix/manual/#chap-writing-nix-expressions builtins.*
https://nixos.org/nix/manual/#ssec-builtins nixpkgs.lib.*
https://github.com/NixOS/nixpkgs/blob/master/lib
Tutorials
See nix tutorials.
Locations
Global Config /etc/nix/configuration.nix
nixpkgs config (overrides, overlays, etc) /etc/nix/nix.conf
nix config (see man nix.conf) User Config ~/.config/nix/config.nix
nix config ~/.config/nixpkgs/config.nix
nixpkgs config (overrides, overlays, etc) ~/.config/nixpkgs/overlays.nix
overlays loaded into every nix env ~/.config/nixpkgs/overlays/*.nix
overlays (loaded in every shell? loaded on demand?) ~/.config/nix/nix.conf
nix config (see man nix.conf) Data /nix/store
packages downloaded here /var/nix/profiles/
user profiles/generations ~/.nix-profile
active profile definition ~/.nix-channels
Logs /nix/var/log/nix
logs stdout/stderr of nix builds
Overview
- Nix downloads multiple versions of a package to the nix store (version determined by file-hash)
- Package sources are determined by nix channels
- nix-envs contain a fixed set of packages/versions, and are configured in profiles
Setup
nix install nix configuration nixpkgs configuration
Usage
Package Management
nix usage nix flakes usage Project Management
nix packages nix shells General
nix channels nix troubleshooting nix tips and tricks
Syntax
See https://nixos.wiki/wiki/Nix_Expression_Language
nix files nix datatypes nix variables nix functions nix operators nix conditionals
Language Support
nix libraries nix python nix ruby nix golang nix java