Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

116 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS Configuration Repo

My NixOS configuration repo. Important notes: I don't know what I'm doing, I'm learning from others, and if you want to learn from this repo, make sure this is one of many data points in your learning journey.

Layout

Repo is organized around the hosts that get configured:

  • HyperV-NixOS: Hyper-V-based VM
  • X299-NixOS: Intel desktop
  • X13-NixOS: AMD-based laptop

Usage (HyperV)

Start by creating a new gen 2 VM with 4GB of RAM or more and make sure it's connected to the local network. Disable Secure Boot and configure the VM to boot from the virtual optical drive mounting the latest minimal ISO image that you can download from https://nixos.org/download.html.

Upon boot, double check that network is working and elevate yourself:

$ sudo -i

Download this repo (or better yet, clone it and make your changes offline with your preferred IDE/code editor) and unzip it on your home directory:

$ curl -L https://github.com/CarlosMendonca/NixOS/archive/refs/heads/main.zip -O main.zip
$ unzip main.zip

Parition the disk however you want, but there are simple instructions on the NixOS manual. You can also just execute the following script to automate this:

$ cd ~/NixOS-main
$ chmod +x scripts/setup-HyperV-NixOS.sh
$ ./scripts/setup-HyperV-NixOS.sh

If you want to check that the flake is working, you can run the check command (the --experimental-features may not be required in the future):

$ nix flake check --experimental-features 'nix-command flakes'

The outptus available on this flake are the pre-configured machines references by their hostnames. To get a sense of the outputs available on this flake, run the show command:

$ nix flake show --experimental-features 'nix-command flakes'

To install this flake, simply run the nix-install command while specifying the path to the flake (current dir, in this case) and which specific output (the machine hostname, in this case):

$ nixos-install --flake .#HyperV-NixOS

If everything went well, you can reboot now to boot from the disk. Going forward, you should be able to remote login via ssh provided that you configured the public key on the users/<username>.nix file.

Getting Started (bare metal)

From the miminal ISO image, configure Wi-Fi:

$ sudo -i
$ systemctl start wpa_supplicant
$ wpa_cli

From wpa_cli do:

> add_network
> set_network 0 ssid "SSID"
> set_network 0 psk "password"
> enable_network 0
> quit

Partition the disk and leave the Windows boot partition (SYSTEM) alone. A partition script for Windows is available on Microsoft documentation.

Mount partitions.

Install with:

$ nixos-install --flake .#X13-NixOS

Set the password for user carlos with:

$ nixos-enter --root /mnt -c "passwd carlos"
$ reboot now

Maintenance

If the /boot partition becomes full, you may want to delete old generations. List generations with:

$ df
$ ls /boot/EFI/nixos -lh
$ nixos-rebuild list-generations

Collect some garbage with:

$ sudo nixos-collect-garbage --delete-older-than 15d

Clean up old generations with:

$ sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations +5
$ sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations 3 4 5
$ sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations 30d

$ sudo nix-collect-garbage -d

Force rebuild for remaining generations with (i.e. clean up boot entries):

$ sudo /run/current-system/bin/switch-to-configuration boot

TO-DOs

  • Expand to Darwin
  • Implement statix
  • Secrets
  • Disk encryption
  • Hibernation
  • Overlays, to modify packages if necessary
  • Terminal and vscode themes
  • nixfmt

DONE

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages