Cheatsheet: Difference between revisions

Pigeon (talk | contribs)
m Get the store path for a package: run nix-build with --no-out-link to not produce a link
Pigeon (talk | contribs)
m use "console" highlight instead of "shell", add $ prompt indicator where it's missing
Line 25: Line 25:


==== Get store path for a package from the Flake input ====
==== Get store path for a package from the Flake input ====
When packages are managed using [[Flakes]], store paths to them can be retrieved using <code>nix eval --inputs-from</code>, like this:<syntaxhighlight lang="shell">
When packages are managed using [[Flakes]], store paths to them can be retrieved using <code>nix eval --inputs-from</code>, like this:<syntaxhighlight lang="console">
$ nix eval --inputs-from "$flake_path" --raw "$input#$package"
$ nix eval --inputs-from "$flake_path" --raw "$input#$package"
</syntaxhighlight>For instance, when packages are managed using [[Home Manager]] using standard configuration, store path to the [[Git]] package can be retrieved using this command:<syntaxhighlight lang="shell">
</syntaxhighlight>For instance, when packages are managed using [[Home Manager]] using standard configuration, store path to the [[Git]] package can be retrieved using this command:<syntaxhighlight lang="console">
$ nix eval --inputs-from ~/.config/home-manager --raw nixpkgs#git
$ nix eval --inputs-from ~/.config/home-manager --raw nixpkgs#git
</syntaxhighlight>
</syntaxhighlight>
Line 353: Line 353:
using channels
using channels
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nix-build -E 'with (import <nixpkgs>{}); polybar.override { i3Support = true; }'
$ nix-build -E 'with (import <nixpkgs>{}); polybar.override { i3Support = true; }'
</syntaxhighlight>
</syntaxhighlight>
using a local repo
using a local repo
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nix-build -E 'with (import ./default.nix{}); polybar.override { i3Support = true; }'
$ nix-build -E 'with (import ./default.nix{}); polybar.override { i3Support = true; }'
</syntaxhighlight>
</syntaxhighlight>