Skip to content

Mimovnik/mimonixos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mimonixos

Collection of my NixOS configs

Templates

Use development shell templates:

nix flake init -t github:Mimovnik/mimonixos#<devshell>

where <devshell> is one of the devshell templates from template/devshells/<devshell> directory

Installation

1. Host with NixOS

1.1 Enter nix shell with git

nix --extra-experimental-features "nix-command flakes" shell nixpkgs#git

1.2 Clone this repo

git clone https://github.com/Mimovnik/mimonixos ~/.mimonixos

1.3 Link this config to /etc/nixos

# Backup default config
sudo mv /etc/nixos /etc/nixos.bak

# Link
sudo ln -s ~/.mimonixos /etc/nixos

1.4 Rebuild for "myhost"

sudo nixos-rebuild switch --flake ~/.mimonixos#myhost

1.5 Aliases

Once the system is rebuilt you can use aliases for rebuliding, testing, editing, updating and deploying this config:

List them with:

alias | grep mim

2. Other hosts

2.1 Manual install with live iso

Download iso image from here.

Determine usb drive name /dev/sdX with:

sudo blkid

Flash an usb drive:

cp /path/to/iso/file /dev/sdX
sync

Note

This may take a while and no output is printed during the copying.

Before rebooting you may need to reorder the boot records so the live iso is the first record to boot.

You can do it in your BIOS/UEFI or:

On UEFI you can use 'efibootmgr' utility:

See the current boot order:

efibootmgr

or on nix:

nix run nixpkgs#efibootmgr

Look for the name of your usb drive

Change the order so nixos

sudo efibootmgr -o 0007,0002,0003

Boot into the live iso

Proceed with the installation

2.2 Remote install

You can install nixos remotely via ssh using nixos-anywhere I have followed this guide.

Prerequisites

  • Target host
  • Source host with nix
  • Network connectivity between the two

Steps I've taken

Edit target host config on source machine

  1. Add authorized keys to new host config: Somewhere in the nixos module add
users.users.${username}.openssh.authorizedKeys.keys = [
  "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKdW1UbkbF0p1yTBh2CKv//RsDvot07/t7AtdNGeAsx/ mimo@glados"
  "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPb0nrIl2mNjcXMmYWIMalZUGb9Kv/1htsLtqA8hYC/F mimovnik@walle"
];

or import modules/system/common/authorized-keys.nix

Note

It is already imported in modules/system/base/default.nix

  1. Configure storage using disko Create disko-config.nix

Import it in host's system config

Specify the main device:

disko.devices.disk.main.device = "/dev/sda";
  1. Start target host Boot into some linux with openssh

If you don't have os enter some live iso

  1. Test ssh connectivity for root on target host nixos-anywhere requires either ssh to root or passwordless sudo

On nixos iso you can change the root password with sudo passwd because sudo doesn't need authentication

Test with:

TARGET=192.168.0.5
ssh root@$TARGET
  1. Run nixos-anywhere
CONFIG="samurai-tv"
TARGET=192.168.0.5
nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./hosts/$CONFIG/hardware-configuration.nix --flake ~/.mimonixos#$CONFIG --target-host root@$TARGET

Note

git add any new files regarding the new host configuration nix won't see the files unless they are staged

Example of such configuration is in hosts/samurai-tv

Note

I didn't have hardware-configuration.nix before running nixos-anywhere Although I imported it in system.nix

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published