darko-mesaros / nixos

My NixOS Configuration files, flakes and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NixOS Configuration With Flakes, Home-manager

This Repo was started and inspired by a blog post by the amazing Karl Voit. Make sure to check out the blog post AND his GitHub repo for more awesomness!

Basic Concept

My setup is using the flake.nix as a central point.

flake.nix is calling most of the other files depending on the set hostname:

  • hosts/$HOSTNAME/default.nix
  • configuration.nix
  • all files related to home-manager: homemanager.nix and homemanager/*

The directory assets contain various configuration and binary files I wanted to keep close to my NixOS configuration files.

Installation

  1. Download installer ISO
  2. Install NixOS using that ISO
    • Learn how to set up a USB thumb drive and boot from it for installing the basic OS
  3. Modify default configuration.nix:
    1. Start an editor:
      sudo nano /etc/nixos/configuration.nix
      
    2. Change hostname on new host from default if necessary:
    3. Activate flakes: https://nixos.wiki/wiki/Flakes
      • On NixOS set the following options in configuration.nix and run nixos-rebuild
      { pkgs, ... }: {   # usual, this line is already there
      
        nix.settings.experimental-features = [ "nix-command" "flakes" ];
      
      }                  # usual, this line is already there
    4. Add the git and package. Also add your favourite editor as well for fixing miscellaneous things. I'm using vim for that.
    5. Update and activate your setup
      sudo nixos-rebuild switch
      
  4. Create a new user and add it to the wheel group:
    useradd -c "Darko Mesaros" -m darko
    usermod -G wheel
    passwd darko
    
  5. Clone this Git repo to ~/nixos/: git clone https://github.com/novoid/nixos-config.git ~/nixos
  6. Create a configuration for the $HOSTNAME in the nixos-configuration git repo
    1. Adapt flakes.nix
    2. Create ~/nixos/hosts/$HOSTNAME (from the DEFAULT host as template)
    3. Get the hardware-configuration.nix into your new setup
      cd ~/nixos
      cp /etc/nixos/hardware-configuration.nix ~/nixos/hosts/$HOSTNAME/
      cp /etc/nixos/configuration.nix ~/nixos/hosts/$HOSTNAME/default.nix
      git add 
  7. Run flakes with the new setup:
    1. Switch to nixos-config dir

    2. Double-check: make sure that hostname matches a config

    3. Run flakes with current nixos-config dir:

      sudo nixos-rebuild switch --flake .
      
    4. Fix any error that may arise at this point.

      • Yes, this can be frustrating. I wish you good luck here.
      • Usually, you just have to remove stuff from ~/nixos/hosts/$HOSTNAME/default.nix when it is also defined in flakes.nix or other existing files.
      • Futhermore, you might have to create (and git add) configuration files that are assumed to exist such as assets/.tmuxp/$HOSTNAME.yaml.
    5. I do recommend a reboot here to cleanly boot the updated OS with all of its settings.

    6. Execute store optimization (replacing copies with hardlinks):

      nix-store --optimise
      
    7. OPTIONALLY: Symlink /etc/nixos to ~/nixos if you want to use nixos-rebuild without the optional parameter for the path.

License

If not specified otherwise, this configuration is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License

About

My NixOS Configuration files, flakes and more

License:Other


Languages

Language:Python 42.7%Language:Lua 35.9%Language:Nix 11.2%Language:Shell 10.1%Language:CSS 0.1%