Cheatsheet: Difference between revisions
Prefixed comments that start from beginning of line with $, to make them highlighted as comments, not as root user command |
GregoryPower (talk | contribs) update subsection "upgrading invdividual packages to a different channel" so it can be easier for newer users of nix-channel usage |
||
| (3 intermediate revisions by one other user not shown) | |||
| Line 20: | Line 20: | ||
$ nix-build '<nixpkgs>' --no- | $ nix-build '<nixpkgs>' --no-out-link -A xorg.libXtst | ||
/nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3 | /nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== 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=" | 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=" | </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 262: | Line 262: | ||
For example one can have both the unstable and stable channels on system root: | For example one can have both the unstable and stable channels on system root: | ||
< | <syntaxhighlight lang="console"> | ||
$ sudo nix-channel --list | $ sudo nix-channel --list | ||
nixos https://nixos.org/channels/nixos- | nixos https://nixos.org/channels/nixos-25.11 | ||
nixos-unstable https://nixos.org/channels/nixos-unstable | nixos-unstable https://nixos.org/channels/nixos-unstable | ||
</ | </syntaxhighlight> | ||
and the following in <code>configuration.nix</code>: | update the channels using the following command:<syntaxhighlight lang="bash"> | ||
$ sudo nix-channel -update nixos nixos-unstable | |||
</syntaxhighlight>and the following in <code>configuration.nix</code>: | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
| Line 352: | Line 354: | ||
using channels | using channels | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="console"> | ||
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=" | <syntaxhighlight lang="console"> | ||
nix-build -E 'with (import ./default.nix{}); polybar.override { i3Support = true; }' | $ nix-build -E 'with (import ./default.nix{}); polybar.override { i3Support = true; }' | ||
</syntaxhighlight> | </syntaxhighlight> | ||