Cheatsheet: Difference between revisions
imported>Samueldr m Updates heder levels; h1/= should never be used |
imported>Samueldr m → %s/\s\+$//g |
||
Line 15: | Line 15: | ||
| colspan="5" style="text-align:center"| Basic concepts | | colspan="5" style="text-align:center"| Basic concepts | ||
|- | |- | ||
| | | | ||
| | | | ||
|This column will let you do everything you can with Ubuntu and more. | |This column will let you do everything you can with Ubuntu and more. | ||
|This column just isn't possible in Ubuntu. | |This column just isn't possible in Ubuntu. | ||
|- | |- | ||
Line 36: | Line 36: | ||
|- | |- | ||
|Where are packages installed? | |Where are packages installed? | ||
|apt installs globally into /bin/, /usr/, etc. | |apt installs globally into /bin/, /usr/, etc. | ||
|System-wide packages are in /run/current-system/sw/ (these are installed because of /etc/nixos/configuration.nix) and /nix/var/nix/profiles/default/bin/ (this is the profile managed by root). Note that the files are just symlinks to the real packages managed by nix /nix/store/. | |System-wide packages are in /run/current-system/sw/ (these are installed because of /etc/nixos/configuration.nix) and /nix/var/nix/profiles/default/bin/ (this is the profile managed by root). Note that the files are just symlinks to the real packages managed by nix /nix/store/. | ||
|User packages are in ~/.nix-profile/. Note that the files are just symlinks to the real packages managed by nix in /nix/store/. | |User packages are in ~/.nix-profile/. Note that the files are just symlinks to the real packages managed by nix in /nix/store/. | ||
Line 59: | Line 59: | ||
If it's a program add to systemPackages: | If it's a program add to systemPackages: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
systemPackages = with pkgs; | systemPackages = with pkgs; | ||
[ <other packages...> emacs ];</syntaxhighlight> | [ <other packages...> emacs ];</syntaxhighlight> | ||
If it's a service add: | If it's a service add: | ||
Line 68: | Line 68: | ||
<syntaxhighlight lang="bash">nix-env -i all</syntaxhighlight> | <syntaxhighlight lang="bash">nix-env -i all</syntaxhighlight> | ||
Since 17.09pre: | Since 17.09pre: | ||
<syntaxhighlight lang="nix">users.users.<username>.packages = | <syntaxhighlight lang="nix">users.users.<username>.packages = | ||
with pkgs;[ emacs ];</syntaxhighlight> | with pkgs;[ emacs ];</syntaxhighlight> | ||
|- | |- | ||
Line 269: | Line 269: | ||
nix-repl> :l <nixpkgs> | nix-repl> :l <nixpkgs> | ||
Added 7486 variables. | Added 7486 variables. | ||
nix-repl> "${xorg.libXtst}" | nix-repl> "${xorg.libXtst}" | ||
"/nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3" | "/nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3" | ||
Line 313: | Line 313: | ||
This method can be used when testing nixos services for a pull request to nixpkgs. | This method can be used when testing nixos services for a pull request to nixpkgs. | ||
Building nixos from a git is an alternative to using nix channels and set up permanent following this [blog article](http://anderspapitto.com/posts/2015-11-01-nixos-with-local-nixpkgs-checkout.html). | Building nixos from a git is an alternative to using nix channels and set up permanent following this [blog article](http://anderspapitto.com/posts/2015-11-01-nixos-with-local-nixpkgs-checkout.html). | ||
It has a couple of advantages over nixpkgs as it allows back-porting of packages/changes to stable versions | It has a couple of advantages over nixpkgs as it allows back-porting of packages/changes to stable versions | ||
as well as applying customization. | as well as applying customization. | ||
Line 331: | Line 331: | ||
<source lang="nix"> | <source lang="nix"> | ||
# vm.nix | # vm.nix | ||
{ lib, config, ... }: | { lib, config, ... }: | ||
{ | { | ||
services.tor.enable = true; | services.tor.enable = true; | ||
users.users.root.initialPassword = "root"; | users.users.root.initialPassword = "root"; | ||
} | } | ||
</source> | </source> | ||
Line 394: | Line 394: | ||
==== Upgrading individual packages to a different channel ==== | ==== Upgrading individual packages to a different channel ==== | ||
One can track multiple channels on NixOS simultaneously, and then declaratively change packages from the default channel to another one. | One can track multiple channels on NixOS simultaneously, and then declaratively change packages from the default channel to another one. | ||
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: | ||
Line 413: | Line 413: | ||
# Create an alias for the unstable channel | # Create an alias for the unstable channel | ||
packageOverrides = pkgs: { | packageOverrides = pkgs: { | ||
unstable = import <nixos-unstable> { | unstable = import <nixos-unstable> { | ||
# pass the nixpkgs config to the unstable alias | # pass the nixpkgs config to the unstable alias | ||
# to ensure `allowUnfree = true;` is propagated: | # to ensure `allowUnfree = true;` is propagated: | ||
config = config.nixpkgs.config; | config = config.nixpkgs.config; | ||
}; | }; | ||
}; | }; | ||
Line 433: | Line 433: | ||
# ... | # ... | ||
zsh | zsh | ||
]; | ]; | ||
}; | }; | ||
</source> | </source> |