Cheatsheet: Difference between revisions
imported>Samuela |
imported>Peterhoeg No edit summary |
||
Line 1: | Line 1: | ||
'''Notice: until this page is cleaned up, it is much more easily viewed [https://nixos.wiki/index.php?title=Cheatsheet&useskin=vector with the Vector wiki theme].''' | '''Notice: until this page is cleaned up, it is much more easily viewed [https://nixos.wiki/index.php?title=Cheatsheet&useskin=vector with the Vector wiki theme].''' | ||
--- | |||
== A cheat sheet and rough mapping between Ubuntu and NixOS == | == A cheat sheet and rough mapping between Ubuntu and NixOS == | ||
Line 269: | Line 269: | ||
To download the source as specified by the package recipe: <syntaxhighlight lang="bash">nix-build '<nixpkgs>' -A emacs.src</syntaxhighlight> | To download the source as specified by the package recipe: <syntaxhighlight lang="bash">nix-build '<nixpkgs>' -A emacs.src</syntaxhighlight> | ||
The patched source is usually not a derivation itself, but can be produced for most packages with the following command: <syntaxhighlight lang="bash">nix-shell '<nixpkgs>' -A emacs\ | The patched source is usually not a derivation itself, but can be produced for most packages with the following command: <syntaxhighlight lang="bash">nix-shell '<nixpkgs>' -A emacs\ | ||
--command 'unpackPhase; patchPhase'</syntaxhighlight> | |||
|- | |- | ||
|Compile & install a package from source | |Compile & install a package from source | ||
Line 278: | Line 278: | ||
with import <nixpkgs> { }; | with import <nixpkgs> { }; | ||
stdenv.lib.overrideDerivation foobar (oldAttrs : { | stdenv.lib.overrideDerivation foobar (oldAttrs : { | ||
src = ./foobar; | |||
}) | }) | ||
EOF | EOF | ||
Line 289: | Line 289: | ||
|- | |- | ||
|Install a .deb | |Install a .deb | ||
|<syntaxhighlight lang="console">$ sudo dpkg -i package.deb</syntaxhighlight> | |<syntaxhighlight lang="console">\$ sudo dpkg -i package.deb</syntaxhighlight> | ||
| | | | ||
|Install dpkg with Nix, then <syntaxhighlight lang="bash">dpkg -i package.deb</syntaxhighlight> | |Install dpkg with Nix, then <syntaxhighlight lang="bash">dpkg -i package.deb</syntaxhighlight> While this is technically possible it will in all likelihood not work. | ||
|} | |} | ||
</div> | </div> | ||
Line 306: | Line 307: | ||
"/nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3" | "/nix/store/nlpnx21yjdjx2ii7ln4kcmbm0x1vy7w9-libXtst-1.2.3" | ||
$ 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> | </syntaxHighlight> | ||
==== Adding files to the store ==== | ==== Adding files to the store ==== | ||
Line 459: | Line 459: | ||
$ make | $ make | ||
</syntaxHighlight> | </syntaxHighlight> | ||
=== Cross-compile packages === | === Cross-compile packages === | ||
Line 492: | Line 491: | ||
allowUnfree = true; | allowUnfree = true; | ||
# Create an alias for the unstable channel | |||
packageOverrides = pkgs: { | |||
unstable = import <nixos-unstable> { # pass the nixpkgs config to the unstable alias # to ensure `allowUnfree = true;` is propagated: | |||
config = config.nixpkgs.config; | |||
}; | |||
}; | |||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 539: | Line 537: | ||
=== Download a nix store path from the cache === | === Download a nix store path from the cache === | ||
If you want to the exact same nix store path on a different system, you can use the <code>--realise</code> | If you want to the exact same nix store path on a different system, you can use the <code>--realise</code> or short <code>-r</code> parameter in the <code>nix-store</code> command: | ||
<syntaxHighlight lang="console"> | <syntaxHighlight lang="console"> | ||
Line 569: | Line 567: | ||
== See also == | == See also == | ||
- [[Garbage Collection]] | |||
- [[NFS#Nix_store_on_NFS|Nix store on NFS]] |