Cheatsheet: Difference between revisions
m propose merge |
Prefixed comments that start from beginning of line with $, to make them highlighted as comments, not as root user command |
||
| Line 7: | Line 7: | ||
=== Get the store path for a package === | === Get the store path for a package === | ||
< | <syntaxhighlight lang="console"> | ||
$ nix repl | $ nix repl | ||
nix-repl> :l <nixpkgs> | nix-repl> :l <nixpkgs> | ||
| Line 16: | Line 16: | ||
nix-repl> :lf ./configuration.nix # as flakes way for a local file | nix-repl> :lf ./configuration.nix # as flakes way for a local file | ||
# 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 22: | Line 22: | ||
$ nix-build '<nixpkgs>' --no-build-output -A xorg.libXtst | $ nix-build '<nixpkgs>' --no-build-output -A xorg.libXtst | ||
/nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3 | /nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3 | ||
</ | </syntaxhighlight> | ||
==== Get store path for a package from the Flake input ==== | ==== Get store path for a package from the Flake input ==== | ||
| Line 104: | Line 104: | ||
[ "/run/current-system/sw/bin/zsh" ... ] | [ "/run/current-system/sw/bin/zsh" ... ] | ||
# Equivalently, if starting from an existing REPL: | $ # Equivalently, if starting from an existing REPL: | ||
nix-repl> :l <nixpkgs/nixos> | nix-repl> :l <nixpkgs/nixos> | ||
Added 6 variables. | Added 6 variables. | ||
| Line 220: | Line 220: | ||
To initiate the build environment run <code>nix-shell</code> in the project root directory | To initiate the build environment run <code>nix-shell</code> in the project root directory | ||
< | <syntaxhighlight lang="console"> | ||
# this will download add development dependencies and set up the environment so build tools will find them. | $ # this will download add development dependencies and set up the environment so build tools will find them. | ||
$ nix-shell | $ nix-shell | ||
</ | </syntaxhighlight> | ||
The following is specific to bcc or cmake in general: | The following is specific to bcc or cmake in general: | ||
(so you need to adapt the workflow depending on the project, you hack on) | (so you need to adapt the workflow depending on the project, you hack on) | ||
< | <syntaxhighlight lang="console">$ mkdir build | ||
$ mkdir build | |||
$ cd build | $ cd build | ||
# cmakeFlags is also defined in the bcc package. autotools based projects might defined $configureFlags | $ # cmakeFlags is also defined in the bcc package. autotools based projects might defined $configureFlags | ||
$ eval cmake $cmakeFlags .. | $ eval cmake $cmakeFlags .. | ||
$ make | $ make</syntaxhighlight> | ||
</ | |||
=== Evaluate packages for a different platform === | === Evaluate packages for a different platform === | ||