curl -L https://nixos.org/nix/install | sh
bash <(curl -L https://nixos.org/nix/install) --no-daemon
. $HOME/.nix-profile/etc/profile.d/nix.sh
or open new shell
nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
upgrade
nix-channel --update; nix-env --install --attr nixpkgs.nix nixpkgs.cacert
https://status.nixos.org/
https://nixos.wiki/wiki/Nix_channels
https://channels.nixos.org/
nix-latest/
Stable channels (nixos-23.05
)
provide conservative updates for fixing bugs and security vulnerabilities, but do not receive major updates after initial release. New stable channels are released every six months.
unstable channels (nixos-unstable
,nixpkgs-unstable
)
correspond to the main development branch (master) of Nixpkgs, delivering the latest
tested updates on a rolling basis.
Large channels (nixos-23.05
,nixos-unstable
) provide binary builds for the full breadth of
Nixpkgs.
Small channels (nixos-23.05-small
,nixos-unstable-small
) are identical to large channels, but contain fewer binaries. This means they update faster, but require more to be built from source.
#add channel with test
nix-channel --add https://nixos.org/channels/nixos-version nixpkgs
nix-channel --add https://nixos.org/channels/channel-name nixos
nix-channel --add https://nixos.org/channels/nixos-23.05 nixpkgs
nix-channel --update
Install the NixOS installation tools:
nix-env -f '<nixpkgs>' -iA nixos-install-tools
export NIX_PATH=/home/kai/.nix-defexpr/channels
nixos-generate-config
andnixos-install
, some man pages andnixos-enter
available
these 6 derivations will be built:
/nix/store/fffnygd90xk1ymy1xd7iw89gbw8sk5jx-builder.pl.drv
/nix/store/24hw26bp2gvcsfgi4w6p3qgqj9kq5hdz-perl-5.38.0-env.drv
/nix/store/d21gl4d72fym261s7h5a86mrm9s7zcr6-nixos-enter.drv
/nix/store/ngr2zbxnal7s36h1nq8glhiymmyqbsh8-nixos-generate-config.drv
/nix/store/vsicp96ski425gy2ap8q7gfzvgm4f897-nixos-install.drv
/nix/store/j53xfdr68l70d1srpkzzqqbz0j0a5mhm-nixos-install-tools-23.11pre540796.75a52265bda7.drv
these 163 paths will be fetched (156.97 MiB download, 677.23 MiB unpacked):
Like packages installed via nix-env
nix-env --list-generations
nix-env
--install
|-i
[args]
--prebuilt-only
|-b
--attr
|-A
--preserve-installed
|-P
--remove-all
|-r
sudo mkfs.ext4 -L nixos /dev/nvme0n1p5
sudo mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
sudo nixos-generate-config --root /mnt
writing /mnt/etc/nixos/hardware-configuration.nix...
writing /mnt/etc/nixos/configuration.nix...
For more hardware-specific settings, see https://github.com/NixOS/nixos-hardware.
refer to https://nixos.org/manual/nixos/stable/#sec-installation now
nano /mnt/etc/nixos/configuration.nix
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "kat";
networking.wireless.iwd.enable = true;
time.timeZone = "Asia/Kathmandu";
i18n.defaultLocale = "en_US.UTF-8";
for single user install
sudo groupadd -g 30000 nixbld
sudo useradd -u 30000 -g nixbld -G nixbld nixbld
sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` u
PATH="$PATH:/usr/sbin:/sbin
sudo userdel nixbld
sudo groupdel nixbld
sudo rm -rv ~/.nix-* /nix
~/.profile
.
changing nixos config
to build the new configuration, make it the default configuration for booting, and try to realise the configuration in the running system (e.g., by restarting system services).
nixos-rebuild test
to build the configuration and switch the running system to it, but without making it the boot default. So if (say) the configuration locks up your machine, you can just reboot to get back to a working configuration.
nixos-rebuild boot
to build the configuration and make it the boot default, but not switch to it now (so it will only take effect after the next reboot).
nixos-rebuild switch -p test
which causes the new configuration (and previous ones created using
-p test
) to show up in the GRUB submenu “NixOS - Profile ‘test’”.
This can be useful to separate test configurations from “stable”
configurations.
nixos-rebuild build
to build the configuration but nothing more. This is useful to see whether everything compiles cleanly.
nixos-enter
reinstall bootloader
sudo nixos-rebuild --install-bootloader switch
updat pkg
nix-channel --update nixos
https://nixos.org/manual/nix/stable/command-ref/nix-channel
https://nixos.wiki/wiki/Change_root
mount /dev/relevantPartitionNameHere /mnt
mount -o bind /dev /mnt/dev mount -o bind /proc /mnt/proc mount -o bind /sys /mnt/sys chroot /mnt /nix/var/nix/profiles/system/activate chroot /mnt /run/current-system/sw/bin/bash
mount /dev/nvme0n1p5 /mnt/
mount /dev/nvme0n1p1 /boot/
nixos-rebuild
--option sandbox false
Comments
Post a Comment