Skip to content

dafitt/dotfiles

Repository files navigation

My daily driver's NixOS❄️ desktop flake

Preview

InstallationUsageConfigurationTroubleshooting

My dotfiles are not perfekt, but they strive to be:

  • highly structured 🧱
  • modular 🎛️
  • a consistent look'n'feel ✨
  • KISS (keep it stupid simple)🥴

Notes

This flake can and will radically change as I learn, discover new things and have new ideas.

Most important features and programs

Installation

New machine - Using the official Installer

  1. Install NixOS and enable the nix feature "flakes"

  2. Dotfiles preparation (mandatory changes to my dotfiles):

    1. git clone https://github.com/dafitt/dotfiles.git

    2. cd dotfiles

    3. Read and understand my dotfiles' structure and code

    4. Add (your own) system-configuration to hosts/<host>/configuration.nix.

      1. Copy and import hardware-configuration.nix

      2. Set the correct current system.stateVersion

    5. Add (your own) home-configuration(s) to hosts/<host>/users/<user>.nix

    6. Commit all changes:

      git add . && git commit -m "hosts/<host>: Added new host"
      
    7. Uncomment nixConfig in flake.nix and enter nix develop on your first build for faster build time

  3. Build:

    1. Enter (nix-shell and then) nix develop .#default
    2. sudo nixos-rebuild --flake .#<host> boot
    3. Check for home-manager errors with systemctl status home-manager-<user>.service and resolve them if necessary
    • NOTE: First install may take some time; especially with flatpaks enabled.
  4. reboot

New standalone home environment

  1. Install nix and enable the nix feature "flakes"

  2. Dotfiles preparation (mandatory changes to my dotfiles):

    1. git clone https://github.com/dafitt/dotfiles.git

    2. cd dotfiles

    3. Read and understand my dotfiles' structure and code

    4. Set the correct current home.stateVersion

    5. Add (your own) home-configuration to hosts/<host>/users/<user>.nix

    6. Commit all changes:

      git add . && git commit -m "hosts/<host>: Added new home"
      
    7. Uncomment nixConfig in flake.nix and enter nix develop on your first build for faster build time

  3. Check your system's requirements when importing the following modules (Installation depending on your distribution):

  4. Build:

    1. Enter nix develop .#default
      or run: nix run home-manager -- --flake .#<user>@<host> switch
    2. home-manager --flake .#<user>@<host> switch
    3. Check for home-manager errors with systemctl status home-manager-<user>.service and resolve them if necessary
    • NOTE: First install may take some time; especially with flatpaks enabled.

New machine - Using the custom ISO

I have configured my own custom installer iso in hosts/DavidISO, which can be used to install a new system. It can also be used to repair a broken existing machine.

  1. Dotfiles preparation:

    1. git clone https://github.com/dafitt/dotfiles.git

    2. cd dotfiles

    3. Read and understand my dotfiles' structure and code

    4. Add (your own) system-configuration to hosts/<host>/configuration.nix.

      1. Copy and import hardware-configuration.nix

      2. Set the correct current system.stateVersion

    5. Add (your own) home-configuration(s) to hosts/<host>/users/<user>.nix

    6. Commit all changes:

      git add . && git commit -m "hosts/<host>: Added new host"
      
  2. Build install-iso with the current dotfiles:

nix build .#nixosConfigurations.DavidISO.config.formats.install-iso
  • (optional) Flash the result to a USB-Stick
dd if=result/<file.iso> of=/dev/<usb>
  1. Boot from the ISO (or USB-Stick) on the target system

  2. Follow the instructions on the commands help-install or help-repair

Imperative (not Declarative)

Post-install imperative setup

  • Accounts and Logins
  • Age keypair for sops: age-keygen -o ~/.config/sops/age/keys.txt
  • Firefox Addons (Settings)
  • Flatpak: Osu ~/.var/app/sh.ppy.osu/data/osu/
  • Hyprland: Monitor setup with nwg-displays
  • Pavucontrol: Set standard audio output
  • SSH keypair ~/.ssh ssh-keygen
  • Syncthing https://localhost:8384/
  • VPN
  • Xfce/Thunar: Set mime-apps xfce4-mime-settings (nix shell nixpkgs#xfce.xfce4-settings)

Usage

Flake

Some basic flake commands

Shell environment

nix-shell shell.nix # only when on legacy-nix: enables flakes & git (works only locally)

nix develop github:dafitt/dotfiles#default

Overview

nix flake show github:dafitt/dotfiles

Build and switch configuration

NixOS & Home-manager:

nixos-rebuild --flake .#[<host>] switch

Home-manager standalone:

home-manager --flake .#[<user>@<host>] switch

Update flake inputs

nix flake update --commit-lock-file

# specific input
nix flake lock --update-input [input]

Rollback

Code formatting

nix fmt [./folder] [./file.nix]

Repl

nixos-rebuild --flake .#[<host>] repl

> config # current system configuration
> perSystem.self.homeConfigurations."<user>@<host>".config # current home configuration

Super&Control - System and Hyprland control
Super - Window control
Super&Alt - Applications
Shift - reverse, grab, move

keybind table
Keybind Dispatcher Command
Super&Alt B exec pypr toggle bluetooth
Super&Alt W exec firefox
Super&Alt P exec pypr toggle btop
Super&Alt E exec micro
Super&Alt F exec nautilus
XF86Calculator exec gnome-calculator
Super&Control Q exit
Super&Control R exec hyprctl reload; forcerendererreload
Super&Control ADIAERESIS exec poweroff
Super&Control ODIAERESIS exec poweroff --reboot
Super UDIAERESIS exec systemctl suspend
Super DELETE exec hyprctl kill
Super X killactive
Super&Shift X forcekillactive
Super P pseudo
Super R togglesplit
Super H swapnext
Super&Shift H swapnext prev
Super F fullscreen
Super A fullscreen 1
Super V togglefloating
Super Z alterzorder top
Super&Shift Z alterzorder bottom
Super B pin
Super left movefocus l
Super right movefocus r
Super up movefocus u
Super down movefocus d
Super Tab cyclenext
Super Tab cyclenext prev
Super&Shift left swapwindow l
Super&Shift right swapwindow r
Super&Shift up swapwindow u
Super&Shift down swapwindow d
Super&Shift Tab swapnext
Super&Alt plus resizeactive 100 0
Super&Alt minus resizeactive -100 0
Super&Alt right resizeactive 100 0
Super&Alt left resizeactive -100 0
Super&Alt down resizeactive 0 100
Super&Alt up resizeactive 0 -100
Super&Control G togglegroup
Super G changegroupactive f
Super&Shift G changegroupactive f
Super&Shift&Control left movewindoworgroup l
Super&Shift&Control right movewindoworgroup r
Super&Shift&Control up movewindoworgroup u
Super&Shift&Control down movewindoworgroup d
Super 1 focusworkspaceoncurrentmonitor 1
Super 2 focusworkspaceoncurrentmonitor 2
Super 3 focusworkspaceoncurrentmonitor 3
Super 4 focusworkspaceoncurrentmonitor 4
Super 5 focusworkspaceoncurrentmonitor 5
Super 6 focusworkspaceoncurrentmonitor 6
Super 7 focusworkspaceoncurrentmonitor 7
Super 8 focusworkspaceoncurrentmonitor 8
Super 9 focusworkspaceoncurrentmonitor 9
Super 0 focusworkspaceoncurrentmonitor 10
Super D focusworkspaceoncurrentmonitor name:D
Super code:87 focusworkspaceoncurrentmonitor 1
Super code:88 focusworkspaceoncurrentmonitor 2
Super code:89 focusworkspaceoncurrentmonitor 3
Super code:83 focusworkspaceoncurrentmonitor 4
Super code:84 focusworkspaceoncurrentmonitor 5
Super code:85 focusworkspaceoncurrentmonitor 6
Super code:79 focusworkspaceoncurrentmonitor 7
Super code:80 focusworkspaceoncurrentmonitor 8
Super code:81 focusworkspaceoncurrentmonitor 9
Super code:91 focusworkspaceoncurrentmonitor 10
Super code:86 focusworkspaceoncurrentmonitor +1
Super code:82 focusworkspaceoncurrentmonitor -1
Super backspace focusworkspaceoncurrentmonitor previous
Super mouse_down focusworkspaceoncurrentmonitor -1
Super mouse_up focusworkspaceoncurrentmonitor +1
Super&Shift 1 movetoworkspacesilent 1
Super&Shift 2 movetoworkspacesilent 2
Super&Shift 3 movetoworkspacesilent 3
Super&Shift 4 movetoworkspacesilent 4
Super&Shift 5 movetoworkspacesilent 5
Super&Shift 6 movetoworkspacesilent 6
Super&Shift 7 movetoworkspacesilent 7
Super&Shift 8 movetoworkspacesilent 8
Super&Shift 9 movetoworkspacesilent 9
Super&Shift 0 movetoworkspacesilent 10
Super&Shift code:87 movetoworkspacesilent 1
Super&Shift code:88 movetoworkspacesilent 2
Super&Shift code:89 movetoworkspacesilent 3
Super&Shift code:83 movetoworkspacesilent 4
Super&Shift code:84 movetoworkspacesilent 5
Super&Shift code:85 movetoworkspacesilent 6
Super&Shift code:79 movetoworkspacesilent 7
Super&Shift code:80 movetoworkspacesilent 8
Super&Shift code:81 movetoworkspacesilent 9
Super&Shift code:91 movetoworkspacesilent 10
Super&Shift code:86 movetoworkspacesilent +1
Super&Shift code:82 movetoworkspacesilent -1
Super&Control left movecurrentworkspacetomonitor l
Super&Control right movecurrentworkspacetomonitor r
Super&Control up movecurrentworkspacetomonitor u
Super&Control down movecurrentworkspacetomonitor d
Super&Alt U exec gnome-characters
Super&Alt K exec wl-copy
XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
ALT XF86AudioMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
XF86AudioMicMute exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
PRINT exec grimblast copysave output /home/david/Pictures/Screenshots/$(date +'%F-%T_%N.png')
Super PRINT exec grimblast --notify --freeze copysave area /home/david/Pictures/Screenshots/$(date +'%F-%T_%N.png')
ALT PRINT exec satty --filename - --fullscreen --output-filename /home/david/Pictures/Screenshots/$(date +'%F-%T_%N.png')
Super&Alt PRINT exec satty --filename - --output-filename /home/david/Pictures/Screenshots/$(date +'%F-%T_%N.png')
Super&Alt V exec wl-copy'
Super L exec hyprlock
Super Z exec pypr zoom
Super minus exec pypr zoom --0.5
Super plus exec pypr zoom ++0.5
Super&Alt mouse_down exec pypr zoom ++0.5
Super&Alt mouse_up exec pypr zoom --0.5
Super&Alt mouse:274 exec pypr zoom
Super ODIAERESIS exec pypr toggle_dpms
Super Y exec pypr toggle_special minimized
Super&Shift Y togglespecialworkspace minimized
Super W exec hyprpanel toggleWindow bar-0
Super SPACE exec fuzzel
Super&Alt N exec pypr toggle networkmanager
Super&Alt PERIOD exec bitwarden
Super&Alt A exec pypr toggle pavucontrol
XF86AudioPlay exec playerctl play-pause
XF86AudioPause exec playerctl play-pause
XF86AudioStop exec playerctl stop
XF86AudioNext exec playerctl next
XF86AudioPrev exec playerctl previous
CTRL XF86AudioRaiseVolume exec playerctl position 1+
CTRL XF86AudioLowerVolume exec playerctl position 1-
ALT XF86AudioNext exec playerctld shift
ALT XF86AudioPrev exec playerctld unshift
ALT XF86AudioPlay exec systemctl --user restart playerctld
Super&Alt Z exec xdg-open https://localhost:8384
Super RETURN exec kitty
Super&Alt T exec pypr toggle kitty
Super&Alt G exec codium
XF86AudioRaiseVolume exec wpctl set-volume -l '1.0' @DEFAULT_AUDIO_SINK@ 2.5%+
XF86AudioLowerVolume exec wpctl set-volume -l '1.0' @DEFAULT_AUDIO_SINK@ 2.5%-
ALT XF86AudioRaiseVolume exec wpctl set-volume -l '1.0' @DEFAULT_AUDIO_SOURCE@ 2.5%+
ALT XF86AudioLowerVolume exec wpctl set-volume -l '1.0' @DEFAULT_AUDIO_SOURCE@ 2.5%-
XF86KbdBrightnessUp exec light -s sysfs/leds/kbd_backlight -A 10
XF86KbdBrightnessDown exec light -s sysfs/leds/kbd_backlight -U 10
XF86MonBrightnessUp exec light -U 5
XF86MonBrightnessDown exec light -A 5
Super mouse:272 movewindow
Super mouse:273 resizewindow
Escape exec pypr hide '*'

Configuration

Helpful Nix resources

NixOS stable branch

To use nixpkgs stable branch, update the following inputs to the latest release (25.05 as an example) in flake.nix and rebuild the system.
ATTENTION! When the latest release of nixpkgs is some time away, then you will likely need to refactor some breaking changed options. See the backward incompatibilities in the release notes for those. Directly after a new release should be the best time to switch.

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager/release-25.05";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    stylix.url = "github:danth/stylix/release-25.05";
  };
}

To still let specific packages follow nixpkgs unstable while on the stable branch you can add an overlay:

{ inputs, ... }:

final: prev:
with inputs.nixpkgs-unstable.legacyPackages.${prev.system}; {
  inherit
    gamescope
    lutris
    vscodium
    ;
}

Importing my modules

You can try using my modules through importing them:

# flake.nix
inputs = {
  dafitt.url = "github:dafitt/dotfiles";
  dafitt.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = { nixpkgs, ... }@inputs: {
  nixosConfigurations."<host>" = nixpkgs.lib.nixosSystem {
    system = "x86_64-linux";
    modules = [
      # e.g.
      inputs.dafitt.nixosModules.hyprland
      inputs.dafitt.homeModules.hyprland
      inputs.dafitt.homeModules.browser-firefox
    ];
  };
};

But it is certainly better to simply copy them into your dotfiles and adapt them to your needs.

You want to build from here?

Starting points for customization:

Troubleshooting

Unable to see fonts

Manually reload the fontconfig cache using

fc-cache -r [-f]

Bluetooth does not power on

Error messages:

Failed to set power on: org.bluez.Error.Failed
bluetoothd: Failed to set mode: Failed (0x03)

Check and unblock bluetooth software side with:

rfkill list
sudo rfkill unblock bluetooth

Application won't open with Home-manager standalone

Corrupted /nix/var/nix/db/db.sqlite

You need to reinstall NixOS.

Create a new subvolume (i.e. @nix.new) and mount it under /mnt/nix (i.e. mount -o subvol=nix2 /tmp/foo/nix --mkdir). Next bind-mount your /boot and/or efi in the same place relative to /mnt/ as they are in the real system (i.e. /mnt/boot). Then you nixos-install --flake .#<hostname>.

Now you’ve got a working Nix store with your current closure in the nix.new subvolume and a bootloader set up to boot from it. All that is left to do is swap the @nix.new subvol with your regular @nix subvol (that’s where your fstab is set up to find it) and reboot. If you’ve done everything correctly, you should boot into your current generation with a brand new Nix store.

Commands to help:

mount /dev/nvme0n1p2 /mnt
btrfs subvolume create /mnt/@nix.new
umount /mnt
mkdir /mnt/nix /mnt/boot
mount /dev/nvme0n1p1 /mnt/nix
mount -o subvol=@nix2 /dev/nvme0n1p2 /mnt/nix
nixos-install --flake .#<hostname>
umount /mnt/nix /mnt/boot
mount /dev/nvme0n1p2 /mnt
mv /mnt/@nix /mnt/@nix.old
mv /mnt/@nix.new /mnt/@nix
reboot
mount /dev/nvme0n1p2 /mnt
btrfs subvolume delete /mnt/@nix.old

👀, 🏆 and ❤️

About

My NixOS desktop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors