Flakes: Difference between revisions
Add a tip to avoid putting everything into the flake.nix for compatibility |
m grammar fix |
||
| (One intermediate revision by one other user not shown) | |||
| Line 5: | Line 5: | ||
<translate> | <translate> | ||
<!--T:182--> | <!--T:182--> | ||
'''Nix flakes''' are an [https://nix.dev/manual/nix/stable/development/experimental-features experimental feature] first introduced in the 2.4 [[Nix]] release,{{Cite manual|nix|development/experimental-features|number=13.8|title=Experimental Features|subsection=xp-feature-flakes|subtitle=flakes}}{{Cite manual|nix|release-notes/rl-2.4|number=14.27|title=Release 2.4 (2021-11-01)}} aiming to address a number of areas of improvement for the Nix ecosystem: they provide a uniform structure for Nix projects, allow for pinning specific versions of each | '''Nix flakes''' are an [https://nix.dev/manual/nix/stable/development/experimental-features experimental feature] first introduced in the 2.4 [[Nix]] release,{{Cite manual|nix|development/experimental-features|number=13.8|title=Experimental Features|subsection=xp-feature-flakes|subtitle=flakes}}{{Cite manual|nix|release-notes/rl-2.4|number=14.27|title=Release 2.4 (2021-11-01)}} aiming to address a number of areas of improvement for the Nix ecosystem: they provide a uniform structure for Nix projects, allow for pinning specific versions of each dependency, and sharing these dependencies via lock files, and overall make it more convenient to write reproducible Nix expressions. | ||
<!--T:183--> | <!--T:183--> | ||
| Line 72: | Line 72: | ||
<syntaxhighlight lang="shell"> | <syntaxhighlight lang="shell"> | ||
--experimental-features 'nix-command flakes' | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 85: | Line 85: | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
nix.settings.experimental-features = [ "nix-command" "flakes" ]; | |||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 96: | Line 96: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
nix.settings.experimental-features = [ "nix-command" "flakes" ]; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 290: | Line 290: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
inputs.self.submodules = true; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 491: | Line 491: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang=console> | ||
nix build github:nixos/nixpkgs?ref=pull/<PR_NUMBER>/head#<PACKAGE> | $ nix build github:nixos/nixpkgs?ref=pull/<PR_NUMBER>/head#<PACKAGE> | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 503: | Line 503: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang=console> | ||
git fetch upstream pull/<PR_NUMBER>/head && git checkout FETCH_HEAD && nix build .#PACKAGE | $ git fetch upstream pull/<PR_NUMBER>/head && git checkout FETCH_HEAD && nix build .#PACKAGE | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 517: | Line 517: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang=console> | ||
git add --intent-to-add extra/flake.nix | $ git add --intent-to-add extra/flake.nix | ||
git update-index --skip-worktree --assume-unchanged extra/flake.nix | $ git update-index --skip-worktree --assume-unchanged extra/flake.nix | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 532: | Line 532: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang=console> | ||
cd ~/libdep-src-checkout/ | $ cd ~/libdep-src-checkout/ | ||
nix develop # Or `nix-shell` if applicable. | $ nix develop # Or `nix-shell` if applicable. | ||
export prefix="./install" # configure nix to install it here | $ export prefix="./install" # configure nix to install it here | ||
buildPhase # build it like nix does | $ buildPhase # build it like nix does | ||
installPhase # install it like nix does | $ installPhase # install it like nix does | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 545: | Line 545: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang=console> | ||
cd ~/consumexe-src-checkout/ | $ cd ~/consumexe-src-checkout/ | ||
nix develop --redirect libdep ~/libdep-src-checkout/install | $ nix develop --redirect libdep ~/libdep-src-checkout/install | ||
echo $buildInputs | tr " " "\n" | grep libdep | $ echo $buildInputs | tr " " "\n" | grep libdep | ||
# Output should show ~/libdep-src-checkout/ so you know it worked | $ # Output should show ~/libdep-src-checkout/ so you know it worked | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||