Nix to Debian phrasebook: Difference between revisions
imported>Makefu No edit summary |
imported>Fadenb replace html entities |
||
| Line 9: | Line 9: | ||
| Install a package | | Install a package | ||
| <code>sudo apt-get install emacs</code> | | <code>sudo apt-get install emacs</code> | ||
| In /etc/nixos/configuration.nix: <code>systemPackages = with pkgs; [ | | In /etc/nixos/configuration.nix: <code>systemPackages = with pkgs; [ <other packages...> emacs ];</code> | ||
| <code>nix-env -iA nixpkgs.emacs</code> | | <code>nix-env -iA nixpkgs.emacs</code> | ||
|- | |- | ||
| Line 41: | Line 41: | ||
| <code>apt-cache depends emacs</code> | | <code>apt-cache depends emacs</code> | ||
| <code>nix-store --query --requisites $(readlink -f /run/current-system) && nix-store -q --tree /nix/var/nix/profiles/system</code> | | <code>nix-store --query --requisites $(readlink -f /run/current-system) && nix-store -q --tree /nix/var/nix/profiles/system</code> | ||
| <code>nix-store --query --references $(nix-instantiate ' | | <code>nix-store --query --references $(nix-instantiate '<nixpkgs>' -A emacs)</code> | ||
|- | |- | ||
| List which packages depend on this one (reverse dependencies) | | List which packages depend on this one (reverse dependencies) | ||
| Line 61: | Line 61: | ||
| Select major version and stable/unstable | | Select major version and stable/unstable | ||
| Change sources.list and apt-get dist-upgrade. A an extremely infrequent and destructive operation. The nix variants are safe and easy to use. | | Change sources.list and apt-get dist-upgrade. A an extremely infrequent and destructive operation. The nix variants are safe and easy to use. | ||
| Add the unstable channel. At that address you will find names for other versions and variants. Name can be any string. <code>nix-channel --add https://nixos.org/channels/nixpkgs-unstable | | Add the unstable channel. At that address you will find names for other versions and variants. Name can be any string. <code>nix-channel --add https://nixos.org/channels/nixpkgs-unstable <name></code>Remove a channel. <code>nix-channel --remove <name></code><br>Show all installed channel. <code>nix-channel --list</code> | ||
| When run by a user channels work locally, when run by root they're used as the system-wide channels. | | When run by a user channels work locally, when run by root they're used as the system-wide channels. | ||
|- | |- | ||
| Line 98: | Line 98: | ||
| Adding a user | | Adding a user | ||
| sudo adduser alice | | sudo adduser alice | ||
| Add <code>users.extraUsers.alice = { isNormalUser = true; home = | | Add <code>users.extraUsers.alice = { isNormalUser = true; home = "/home/alice"; description = "Alice Foobar"; extraGroups = [ "wheel" "networkmanager" ]; openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ]; };</code> to /etc/nixos/configuration.nix. Then run <code>nixos-rebuild switch</code> | ||
| | | | ||
| Line 110: | Line 110: | ||
| <code>cat /etc/debian_version</code> | | <code>cat /etc/debian_version</code> | ||
| <code>nixos-version</code> | | <code>nixos-version</code> | ||
| <code>nix-instantiate --eval ' | | <code>nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion</code> | ||
|- | |- | ||
| Get sources for a package | | Get sources for a package | ||
| <code>apt-get source emacs</code> | | <code>apt-get source emacs</code> | ||
| In Debian, apt-get source gets both the patched upstream source and the recipe for the package. Those need two steps in Nix. To find the package recipe: <code>grep -r emacs $(nix-instantiate --eval --expr ' | | In Debian, apt-get source gets both the patched upstream source and the recipe for the package. Those need two steps in Nix. To find the package recipe: <code>grep -r emacs $(nix-instantiate --eval --expr '<nixpkgs>')</code><br>To download the source as specified by the package recipe: <code>nix-build '<nixpkgs>' -A emacs.src</code><br>The patched source is usually not a derivation itself, but can be produced for most packages with the following command: <code>nix-shell '<nixpkgs>' -A emacs --command 'unpackPhase; patchPhase'</code><br>Compile & install a package from source <code>git clone foobar && echo "with import <nixpkgs> { }; stdenv.lib.overrideDerivation foobar (oldAttrs: { src = ./foobar })" > default.nix && nix-build</code> | ||
| | | | ||