tuto:nix
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
tuto:nix [2020/03/06 18:54] – [shellHook] root | tuto:nix [2022/06/21 20:15] (Version actuelle) – [nix-shell] root | ||
---|---|---|---|
Ligne 15: | Ligne 15: | ||
* [[https:// | * [[https:// | ||
+ | ===== nix-user-chroot ===== | ||
+ | https:// | ||
+ | |||
+ | Outil qui permet de donner un répertoire qui sera présenter comme point de montage ''/ | ||
+ | < | ||
+ | $ mkdir -m 0755 ~/.nix | ||
+ | $ nix-user-chroot ~/.nix ${SHELL=bash} -l | ||
+ | </ | ||
===== Installation ===== | ===== Installation ===== | ||
< | < | ||
Ligne 36: | Ligne 44: | ||
</ | </ | ||
+ | ==== NIX_PAGER ==== | ||
< | < | ||
export NIX_PAGER= | export NIX_PAGER= | ||
+ | </ | ||
+ | |||
+ | ==== nixpkgs ==== | ||
+ | < | ||
+ | nixpkgs=https:// | ||
+ | nixpkgs=channel: | ||
</ | </ | ||
Ligne 59: | Ligne 74: | ||
$ nix-env -u --dry-run | $ nix-env -u --dry-run | ||
$ nix-env -e hello | $ nix-env -e hello | ||
+ | </ | ||
+ | |||
+ | Force a specific channel (master in this example): | ||
+ | < | ||
+ | $ nix-env -f https:// | ||
</ | </ | ||
Ligne 120: | Ligne 140: | ||
==== nix-shell ==== | ==== nix-shell ==== | ||
* https:// | * https:// | ||
+ | |||
+ | <code haskell shell.nix> | ||
+ | { pkgs ? import < | ||
+ | |||
+ | with pkgs; | ||
+ | |||
+ | mkShell { | ||
+ | buildInputs = [ | ||
+ | elixir_1_10 | ||
+ | nodejs-12_x | ||
+ | ]; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | $ nix-shell | ||
+ | $ nix-shell shell.nix | ||
+ | </ | ||
+ | |||
< | < | ||
$ nix-shell --pure -E ' | $ nix-shell --pure -E ' | ||
Ligne 136: | Ligne 175: | ||
< | < | ||
$ nix-shell '< | $ nix-shell '< | ||
+ | </ | ||
+ | |||
+ | Force a specific channel: | ||
+ | < | ||
+ | $ nix-shell -p hello -I nixpkgs=https:// | ||
</ | </ | ||
Ligne 189: | Ligne 233: | ||
$ nix-channel --add https:// | $ nix-channel --add https:// | ||
$ nix-channel --remove nixpkgs_19_09 | $ nix-channel --remove nixpkgs_19_09 | ||
+ | </ | ||
+ | |||
+ | Master channel: | ||
+ | < | ||
+ | $ nix-channel --add https:// | ||
</ | </ | ||
Ligne 306: | Ligne 355: | ||
path is '/ | path is '/ | ||
02cgs6b1rmh8hmcwm5wpxxg32p3km9c05606pykv49qq1spd6p38 | 02cgs6b1rmh8hmcwm5wpxxg32p3km9c05606pykv49qq1spd6p38 | ||
+ | </ | ||
+ | |||
+ | ==== nix-instantiate ==== | ||
+ | < | ||
+ | $ nix-instantiate --eval -E ' | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | $ nix-instantiate --eval -E ' | ||
+ | " | ||
</ | </ | ||
Ligne 408: | Ligne 468: | ||
Welcome to Nix version 2.3.3. Type :? for help. | Welcome to Nix version 2.3.3. Type :? for help. | ||
- | $ nix-repl> | + | nix-repl> |
" | " | ||
</ | </ | ||
< | < | ||
- | $ nix-repl> | + | $ nix repl |
+ | nix-repl> | ||
nix-repl> | nix-repl> | ||
nix-repl> | nix-repl> | ||
this derivation produced the following outputs: out -> / | this derivation produced the following outputs: out -> / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | nix-repl> | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | === nix edit === | ||
+ | Permet d' | ||
+ | < | ||
+ | $ EDITOR=vim nix edit -f "< | ||
+ | </ | ||
+ | |||
+ | On install ensuite le paquet: | ||
+ | < | ||
+ | $ nix-env -i samba | ||
</ | </ | ||
Ligne 497: | Ligne 574: | ||
</ | </ | ||
- | ==== Chemains | + | ==== Chemins |
< | < | ||
$ nix eval ' | $ nix eval ' | ||
Ligne 601: | Ligne 678: | ||
==== Override ==== | ==== Override ==== | ||
< | < | ||
- | $ nix-repl | + | $ nix repl |
nix-repl> | nix-repl> | ||
Added 4360 variables. | Added 4360 variables. | ||
Ligne 731: | Ligne 808: | ||
| | ||
+ | </ | ||
+ | |||
+ | ==== builder ==== | ||
+ | |||
+ | < | ||
+ | { stdenv, fetchurl, openmpi }: | ||
+ | |||
+ | stdenv.mkDerivation rec { | ||
+ | name = " | ||
+ | src = fetchurl { | ||
+ | url = " | ||
+ | | ||
+ | }; | ||
+ | |||
+ | buildInputs = [ openmpi ]; | ||
+ | |||
+ | builder = builtins.toFile " | ||
+ | " | ||
+ | source $stdenv/ | ||
+ | mpicc -w -o oned.exe $src | ||
+ | mkdir $out | ||
+ | mkdir $out/bin | ||
+ | cp oned.exe $out/bin | ||
+ | "; | ||
+ | |||
+ | meta = { | ||
+ | description = "JDEV 2017 Nix tutoriel"; | ||
+ | license | ||
+ | platforms | ||
+ | }; | ||
+ | } | ||
</ | </ | ||
Ligne 843: | Ligne 951: | ||
firefox.enable = true; | firefox.enable = true; | ||
- | .git = { | + | |
- | enable = true; | + | enable = true; |
- | userName = " | + | userName = " |
- | userEmail = " | + | userEmail = " |
- | + | ||
- | ignores = [ | + | |
- | " | + | |
- | " | + | |
- | ]; | + | |
+ | ignores = [ | ||
+ | " | ||
+ | " | ||
+ | ]; | ||
+ | }; | ||
+ | | ||
bash = { | bash = { | ||
enable = true; | enable = true; |
tuto/nix.1583520857.txt.gz · Dernière modification : 2020/03/06 18:54 de root