Cheatsheet: Difference between revisions
imported>Samueldr m use bootstrap's responsive-table to work around overflowing table issue. |
imported>Samueldr m Updates heder levels; h1/= should never be used |
||
Line 1: | Line 1: | ||
= A cheat sheet and rough mapping between Ubuntu and NixOS = | == A cheat sheet and rough mapping between Ubuntu and NixOS == | ||
This is meant to give you basic ideas and get you unstuck. NixOS being very different from most distributions, a deeper understanding will be necessary sooner or later! Follow the links to the manual pages and browse the wiki to find real NixOS tutorials. | This is meant to give you basic ideas and get you unstuck. NixOS being very different from most distributions, a deeper understanding will be necessary sooner or later! Follow the links to the manual pages and browse the wiki to find real NixOS tutorials. | ||
Line 261: | Line 261: | ||
</div> | </div> | ||
= Working with the nix store = | == Working with the nix store == | ||
== Get the store path for a package == | === Get the store path for a package === | ||
<source lang="nix"> | <source lang="nix"> | ||
Line 277: | Line 277: | ||
=== Adding files to the store === | ==== Adding files to the store ==== | ||
It is sometimes necessary to add files to the store manually. | It is sometimes necessary to add files to the store manually. | ||
Line 303: | Line 303: | ||
</source> | </source> | ||
== Build nixos from nixpkgs repo == | === Build nixos from nixpkgs repo === | ||
The following snippet will build the system from a git checkout: | The following snippet will build the system from a git checkout: | ||
Line 323: | Line 323: | ||
</source> | </source> | ||
== Building a service as a VM (for testing) == | === Building a service as a VM (for testing) === | ||
While `nixos-rebuild build-vm` allows to build a vm out of the current system configuration, there is a more light-weight alternative when only a single service needs to be tested. | While `nixos-rebuild build-vm` allows to build a vm out of the current system configuration, there is a more light-weight alternative when only a single service needs to be tested. | ||
Line 352: | Line 352: | ||
</source> | </source> | ||
== Reuse a package as a build environment == | === Reuse a package as a build environment === | ||
As packages already contains all build dependencies, they can be reused to a build environment quickly. | As packages already contains all build dependencies, they can be reused to a build environment quickly. | ||
In the following a setup for the cmake-based project [bcc](https://github.com/iovisor/bcc) is shown. | In the following a setup for the cmake-based project [bcc](https://github.com/iovisor/bcc) is shown. | ||
Line 390: | Line 390: | ||
</source> | </source> | ||
== Customizing Packages == | === Customizing Packages === | ||
=== 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. | ||
Line 437: | Line 437: | ||
</source> | </source> | ||
== Building statically linked packages == | === Building statically linked packages === | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 443: | Line 443: | ||
</source> | </source> | ||
== Rebuild a package with debug symbols == | === Rebuild a package with debug symbols === | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 452: | Line 452: | ||
==See also== | == See also == | ||
* [[Garbage Collection]] | * [[Garbage Collection]] | ||
* [[NFS#Nix_store_on_NFS|Nix store on NFS]] | * [[NFS#Nix_store_on_NFS|Nix store on NFS]] |