Skip to content

Latest commit

 

History

History
181 lines (126 loc) · 4.26 KB

NEW_INSTALL.md

File metadata and controls

181 lines (126 loc) · 4.26 KB

Before Installation

If possible, do this on the previous host:

  1. Backup any data which isn't already backed up somewhere else.

    • Shell history (zsh)
    • Music under $XDG_MUSIC_DIR (I have a backup, but make sure it's really up-to-date)
    • Chrome bookmarks (They should all be in my bookmark manager)
    • Firefox bookmarks should be synced with my Mozilla account, but double-check
    • Files under $XDG_DOWNLOAD_DIR
  2. Commit and push changes for my Git repositories.

    • dotfiles
    • Everything under $XDG_PROJETS_DIR

Install NixOS on a New Host

  1. Switch to the root user.

    sudo su -
  2. Download this repository as a ZIP archive and extract its content at /tmp/dotfiles (with -L, curl follows redirects)

    curl -L https://github.com/dmarcoux/dotfiles/archive/refs/heads/main.zip --output /tmp/dotfiles.zip &&
    unzip /tmp/dotfiles.zip -d /tmp &&
    mv /tmp/dotfiles-main /tmp/dotfiles
  3. Set the hostname for the new host, and create its directory in the dotfiles.

    export HOSTNAME="PICK_A_NAME" &&
    mkdir -p "/tmp/dotfiles/hosts/$HOSTNAME"
  4. To partition, format, and mount the disks, I use disko. Create or adapt one of the disko configurations from the dotfiles. The disko configuration must be at /tmp/dotfiles/hosts/$HOSTNAME/disko-config.nix. Either way, ensure the disk names match what lsblk outputs.

    Example of lsblk output

    NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    sda           8:0    0   1.8T  0 disk
    nvme0n1     259:0    0 476.9G  0 disk

    In this example, the disk names are /dev/sda and /dev/nvme0n1.

    Example of a disko configuration and where to put the disk names

    # ...
    main = {
      type = "disk";
      device = "/dev/sda";
      content = {
        type = "gpt";
    # ...
  5. If encrypting disks with LUKS:

    5.1. Wipe disks before proceeding

    dd if=/dev/zero of=DISK bs=1M status=progress

    5.2. Set passphrase to decrypt disks on boot

    echo -n "password" > /tmp/secret.key
  6. Run disko to partition, format and mount the disks.

    This will erase any existing data on the disks.

    nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount "/tmp/dotfiles/hosts/$HOSTNAME/disko-config.nix"
  7. Create configuration.nix for the system, but without the filesystems. Those are handled by disko.

    nixos-generate-config --no-filesystems --root /mnt
  8. Move the dotfiles and the generated Nix files to the mounted disks.

    mv /tmp/dotfiles /mnt/etc/nixos/ &&
    mv /mnt/etc/nixos/*.nix "/mnt/etc/nixos/dotfiles/hosts/$HOSTNAME/"
  9. Add the new host inside nixosConfigurations = { ... }.

    vim /mnt/etc/nixos/dotfiles/flake.nix
  10. Edit the Nix configuration files for the host.

    vim "/mnt/etc/nixos/dotfiles/hosts/$HOSTNAME/*.nix"
  11. Install NixOS for the new host.

    nixos-install --flake "/mnt/etc/nixos/dotfiles#$HOSTNAME"
  12. Reboot

    reboot

  1. Log in as root with the password set in the NixOS installation

  2. Open a terminal and set password for my user

    passwd dany
  3. Log out

    logout
  4. Log in as my user

  5. Setup 1Password, my password manager. The settings for the CLI, desktop and browser extensions are explained in one of the secure notes.

  6. Clone the dotfiles repository

    git clone [email protected]:dmarcoux/dotfiles.git ~/dotfiles
  7. Setup secrets gitsubmodule

    cd ~/dotfiles &&
    git submodule init &&
    git submodule update &&
    cd secrets &&
    echo "Follow instructions from the Setup section in secrets' README"
  8. Copy over the files from /etc/nixos/dotfiles to the dotfiles repository.

  9. Commit and push the changes to the dotfiles repository.

  10. Build the NixOS system for the host. Its hostname matches one of the directories under hosts/.

    sudo nixos-rebuild boot --flake /home/dany/dotfiles
  11. Reboot

    reboot