# Installing from another Linux distribution {#sec-installing-from-other-distro}
Because Nix (the package manager) & Nixpkgs (the Nix packages
collection) can both be installed on any (most?) Linux distributions,
they can be used to install NixOS in various creative ways. You can, for
instance:
1. Install NixOS on another partition, from your existing Linux
distribution (without the use of a USB or optical device!)
1. Install NixOS on the same partition (in place!), from your existing
non-NixOS Linux distribution using `NIXOS_LUSTRATE`.
1. Install NixOS on your hard drive from the Live CD of any Linux
distribution.
The first steps to all these are the same:
1. Install the Nix package manager:
Short version:
```ShellSession
$ curl -L https://nixos.org/nix/install | sh
$ . $HOME/.nix-profile/etc/profile.d/nix.sh # …or open a fresh shell
```
More details in the [ Nix
manual](https://nixos.org/nix/manual/#chap-quick-start)
1. Switch to the NixOS channel:
If you've just installed Nix on a non-NixOS distribution, you will
be on the `nixpkgs` channel by default.
```ShellSession
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
```
As that channel gets released without running the NixOS tests, it
will be safer to use the `nixos-*` channels instead:
```ShellSession
$ nix-channel --add https://nixos.org/channels/nixos-<version> nixpkgs
```
Where `<version>` corresponds to the latest version available on [channels.nixos.org](https://channels.nixos.org/).
You may want to throw in a `nix-channel --update` for good measure.
1. Install the NixOS installation tools:
You'll need `nixos-generate-config` and `nixos-install`, but this
also makes some man pages and `nixos-enter` available, just in case
you want to chroot into your NixOS partition. NixOS installs these
by default, but you don't have NixOS yet..
```ShellSession
$ nix-env -f '<nixpkgs>' -iA nixos-install-tools
```
1. ::: {.note}
The following 5 steps are only for installing NixOS to another
partition. For installing NixOS in place using `NIXOS_LUSTRATE`,
skip ahead.
:::
Prepare your target partition:
At this point it is time to prepare your target partition. Please
refer to the partitioning, file-system creation, and mounting steps
of [](#sec-installation)
If you're about to install NixOS in place using `NIXOS_LUSTRATE`
there is nothing to do for this step.
1. Generate your NixOS configuration:
```ShellSession
$ sudo `which nixos-generate-config` --root /mnt
```
You'll probably want to edit the configuration files. Refer to the
`nixos-generate-config` step in [](#sec-installation) for more
information.
Consider setting up the NixOS bootloader to give you the ability to
boot on your existing Linux partition. For instance, if you're
using GRUB and your existing distribution is running Ubuntu, you may
want to add something like this to your `configuration.nix`:
```nix
{
boot.loader.grub.extraEntries = ''
menuentry "Ubuntu" {
search --set=ubuntu --fs-uuid 3cc3e652-0c1f-4800-8451-033754f68e6e
configfile "($ubuntu)/boot/grub/grub.cfg"
}
'';
}
```
(You can find the appropriate UUID for your partition in
`/dev/disk/by-uuid`)
1. Create the `nixbld` group and user on your original distribution:
```ShellSession
$ sudo groupadd -g 30000 nixbld
$ sudo useradd -u 30000 -g nixbld -G nixbld nixbld
```
1. Download/build/install NixOS:
::: {.warning}
Once you complete this step, you might no longer be able to boot on
existing systems without the help of a rescue USB drive or similar.
:::
::: {.note}
On some distributions there are separate PATHS for programs intended
only for root. In order for the installation to succeed, you might