Cheatsheet: Difference between revisions
GregoryPower (talk | contribs) update subsection "upgrading invdividual packages to a different channel" so it can be easier for newer users of nix-channel usage |
m style fixes |
||
| Line 7: | Line 7: | ||
=== Get the store path for a package === | === Get the store path for a package === | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="nix"> | ||
$ nix repl | $ nix repl | ||
nix-repl> :l <nixpkgs> | nix-repl> :l <nixpkgs> | ||
| Line 15: | Line 15: | ||
nix-repl> :lf ./configuration.nix # as flakes way for a local file | nix-repl> :lf ./configuration.nix # as flakes way for a local file | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="console"> | |||
$ # load nixos configuration from a nix file | $ # load nixos configuration from a nix file | ||
$ nix repl --file '<nixpkgs/nixos>' -I nixos-config=./configuration.nix | $ nix repl --file '<nixpkgs/nixos>' -I nixos-config=./configuration.nix | ||
| Line 115: | Line 117: | ||
You can do this with configuration files other than the one installed in <code>/etc/nixos</code>, too: | You can do this with configuration files other than the one installed in <code>/etc/nixos</code>, too: | ||
< | <syntaxhighlight lang=nix> | ||
nix-repl> :a import <nixpkgs/nixos> { configuration = /path/to/config.nix; } | nix-repl> :a import <nixpkgs/nixos> { configuration = /path/to/config.nix; } | ||
</ | </syntaxhighlight> | ||
=== Manually switching a NixOS system to a certain version of system closure === | === Manually switching a NixOS system to a certain version of system closure === | ||
| Line 153: | Line 155: | ||
Given the following configuration: | Given the following configuration: | ||
{{file|vm.nix|nix|3= | |||
{ lib, config, ... }: | { lib, config, ... }: | ||
{ | { | ||
| Line 160: | Line 161: | ||
users.users.root.initialPassword = "root"; | users.users.root.initialPassword = "root"; | ||
} | } | ||
}} | |||
a vm can be build using the following command: | a vm can be build using the following command: | ||
| Line 268: | Line 269: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
update the channels using the following command:<syntaxhighlight lang=" | update the channels using the following command: | ||
<syntaxhighlight lang="console"> | |||
$ sudo nix-channel -update nixos nixos-unstable | $ sudo nix-channel -update nixos nixos-unstable | ||
</syntaxhighlight>and the following in <code>configuration.nix</code>: | </syntaxhighlight>and the following in <code>configuration.nix</code>: | ||
| Line 290: | Line 292: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
environment.systemPackages = with pkgs; [ | environment.systemPackages = with pkgs; [ | ||
ddate | |||
devilspie2 | |||
evince | |||
unstable.google-chrome | |||
# ... | |||
zsh | |||
]; | ]; | ||