Skip to content

My personal system and $HOME configuration managed by Nix

License

Notifications You must be signed in to change notification settings

kkirkov/dotfiles

 
 

Repository files navigation

Nix Flakes-based System & Home Configuration, Dotfiles, and Install Scripts

CI Status

CI Workflow Target Platform CI Job Status
NixOS System Configuration NixOS NixOS
Home Manager User Configuration Linux / macOS Nix Home Manager
Nix-on-Droid Android (not implemented yet)
Legacy Install Scripts Linux + distro package manager Alpine Arch Linux Debian Ubuntu
Legacy Install Scripts macOS + HomeBrew macOS

Overall status: Actions Status

Overview

This repo contains my personal system configuration that consists of:

It includes a Nix Flake file which acts as an entrypoint for Nix and defines the following outputs:

  • nixosConfigurations.* - NixOS system configurations
  • homeConfigurations.* - Nix Home Manager configuration
  • nixOnDroidConfigurations.* - Nix-on-Droid configuration for Nix-powered Android shell environment

Basic Usage

This is how I apply my Nix configuration on my machines. If you fork this repo (to modify it as per your needs), you should be able to use the same commands as they're written in a generic way.

Apply NixOS system configuration

sudo nixos-rebuild switch --flake "$CFG#$(hostname)"

Apply Home Manager user config

home-manager switch --flake $CFG#$USER

Manually update all Nix Flake inputs

nix flake update $CFG

The versions of most software installed on the system are determined by the Nixpkgs commit hash stored in the flake.lock file. Running the command above will update it (and the other flake inputs) to latest version.

Getting started

Clone the repo, e.g. to $HOME/code/repos:

git clone https://github.com/PetarKirov/dotfiles

Copy a machine configuration and modify it as needed:

cd dotfiles
cp -r nixos/machines/zlx-nixos-desktop2 nixos/machines/my-machine
# Edit nixos/machines/my-machine/*

Nix Ecosystem Docs

Installing NixOS

  1. Boot into a live NixOS environment (either a live CD containing the NixOS installer or an existing NixOS installation on another drive)

    • If you're using a live CD environment, be sure to update /etc/nixos/configuration.nix like so:
    # Open the file and change it to the snippet below:
    sudo nvim /etc/nixos/configuration.nix
    
    # Once the file has been updated and saved, apply the settings:
    sudo nixos-rebuild switch
    { config, pkgs, ... }:
    {
      imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix> ];
      nix = {
        trustedUsers = [ "root" "nixos" ];
        extraOptions = ''
          experimental-features = nix-command flakes
        '';
      };
    }

    These settings will ensure that you're using a recent enough version of Nix with the necessary features enabled.

  2. Clone this repo and cd into it: git clone https://github.com/PetarKirov/dotfiles && cd dotfiles

  3. Assuming that you're installing NixOS on a clean drive, run the automated ZFS partitioning tool:

    • Run it in "dry-run" mode to get information about your system: ./utils/make_zfs.bash
    • If you need to partition your drive run: env DRY_RUN=0 KEEP_PARTITIONS=0 ./utils/make_zfs.bash
    • If your drive is already partitioned, run: env DRY_RUN=0 ./utils/make_zfs.bash
  4. Now there should be a root ZFS partition mounted at /mnt. To install NixOS there, run:

Bash $
mkdir ./nixos/machines/my-machine
sudo nixos-generate-config --root /mnt --dir  /..$(git rev-parse --show-toplevel)/nixos/machines/my-machine
Fish ⋊>
mkdir ./nixos/machines/my-machine
sudo nixos-generate-config --root /mnt --dir  /..(git rev-parse --show-toplevel)/nixos/machines/my-machine

Your files were automatically generated. Now they could be manually changed!

note: Do not forget to set random hostId. You can use the following command for generation:

tr -dc 0-9a-f < /dev/urandom | head -c 8

With everything configured we can continue with:

Bash $
sudo nixos-install --impure --flake '.#my-machine' --root /mnt
Fish ⋊>
sudo nixos-install --impure --flake '.#my-machine' --root /mnt

(Replace my-machine in the command above with the name of the machine config you want to apply.)

  1. Now that NixOS is installed, chroot into (using nixos-enter) and change the password of the default user:

    sudo nixos-enter --root /mnt
    passwd zlx
    exit

    (Replace zlx in the command above with the your username.)

  2. Copy the dotfiles repo inside the user's home dir:

    mkdir -p /mnt/home/$USER/code/repos
    cp -a ../dotfiles /mnt/home/$USER/code/repos
  3. Build the home-manager config and copy it to the new Nix Store:

    nix build ".#homeConfigurations.$USER.activationPackage"
    sudo nix copy --to /mnt ./result/ --no-check-sigs
  4. Reboot into the new Nix install, open a terminal, cd into the dotfiles dir and activate the home-manager config:

    cd /home/$USER/code/repos/dotfiles
    nix path-info ".#homeConfigurations.$USER.activationPackage" | xargs -I@@ sh -c '@@/activate'
  5. You're done!

About

My personal system and $HOME configuration managed by Nix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Nix 49.2%
  • Shell 38.6%
  • D 7.2%
  • Vim Script 5.0%