Skip to content

becknik/dotfiles.nix

Repository files navigation

dotfiles.nix

My over-engineered approach of declaratively syncing my desktop setups between all my devices.

Some nice bits of knowledge I came across along the buildup of this flake are documented accumulated right here

Project Structure

$ tree -a -I '\.git|\.direnv' . # slightly modified for better context/ overview
.
├───────────────────────────────────────────
├── .devenv
├── flake.nix
├── patches # patches for flake inputs
├── disko
│   ├── ext4-encrypted.nix
│   └── ext4-unencrypted.nix
├── .sops.yaml
├── home-manager
│   ├── default.nix
│   ├── users # home-manager is actually user-based
│   │   ├── nixos.nix
│   │   └── darwin.nix # import subset of files that makes sense for my work laptop
│   ├── secrets # secrets are managed using sops & age stored inside of a yubikey
│   │   └── ...
│   ├── packages.nix
│   ├── desktop-env
│   │   └── ...
│   ├── devel
│   │   └── ...
│   └── media
│       └── ...
├── nixos
│   ├── dnix
│   │   ├── default.nix
│   │   └── hardware-configuration.nix
│   ├── lnix #  same as dnix
│   ├── default.nix
│   ├── desktop-env.nix
│   ├── gnome.nix
│   ├── packages.nix
│   ├── systemd.nix
│   └── virtualisation.nix
├── nixvim # see README there
│   └── ...
├── overlays
│   ├── default.nix
│   ├── modifications.nix
│   ├── modification # package patches
│   │   └── ...
├── darwin
│   ├── default.nix
└── pkgs # custom packages (+ nixvim)

Setup

  • Misterio77-style Flake-based NixOS + home-manager setup
    • Configuration for laptop (lnix) & desktop (dnix)
    • nix-hardware setup for each
    • nix-darwin setup for work laptop (wnix), which uses a subset of the home-managed part
    • Overlays & systemd services to make this a bit more convenient
  • Highly customized GNOME Wayland DE with some KDE tools
  • home-manager for managing everything apart from system stuff
  • Home-managed secrets with sops-nix (age encrypted)
  • nixvim setup with standalone approach to enable main branch despite using "stable" home-manager
    • To checkout my nixvim setup, don't hesitate to use nix run .#nixvim <some-file>
    • Used elythh's config as a starting point

Further great Projects used

  • disko: For NixOS partitioning & deployment
  • Flockenzeit: Date & time parsing and formatting in native Nix. Awesome!
    • Used in conjunction with flake's inputs.self.sourceInfo.lastModified for systemd NixOS automatic rebuild logs :^)
  • mac-app-util: Automatically creating trampoline symlinks for home-managed Mac software
    • I really hate MacOS, but this lib makes me hate using it with nix-darwin a bit less
  • nix-vscode-extensions: The few extensions being available in nixpkgs (some of which being outdated) replaced by the latest & all available on open-vsx & marketplace!

Features

  • Over-engineering in it's purest form (heh). Spent days on this config - and there are still ~80 TODOs :|
  • Systemd Services:
    • nixos-upgrade-notify-send-(failure|success).service - Sends desktop notification when nixos-upgrade unit finished
    • nixos-upgrade-automatic-shutdown.service - Shuts down the desktop when nixos-upgrade service finished

    Disabled by default; Must be started manually

    • nixos-upgrade.service writes build logs to /var/log/nixos-upgrade/
  • nixos-fetch-flake-changes.service - Checks for upstream changes of flake and executes nixos-rebuild switch if so
  • rebuild shell alias: See bottom of shell.nix

Getting Started

  • Enter the nix repl
# aliased as nrepl
nix repl --expr "builtins.getFlake \"$HOME/devel/own/dotfiles.nix\""

Deployment

  1. Partition disks with disko:
sudo nix run github:nix-community/disko \
    --extra-experimental-features "nix-command flakes" -- \
    --mode disko ./disko/ext4-(un)encrypted.nix (--arg disks '[ "/dev/sdX" ]')
# If the command succeeds, the partitions are automatically mounted under /mnt
  1. sudo nixos-install --flake </home/nixos/>dotfiles.nix#<host> -j 4 --cores 2
  2. reboot

Todo List for Post-Installation

Sometimes its nice to have a good starting point, when one spent hours on bringing a system to run :) Let's hope this projects break the hours down to minutes

  • Copy the nix-sops secret to the new system
  • Enable the installed GNOME-extensions
    • Setup gsconnect
  • (Configure the CPU-scheduler and profile in cpupower-gui)
  • Fix dconf settings for shortcuts being ignored by home-manager dconf generator (?):
    • "Open the quick settings menu" => Disabled ([delete] key)
    • "Show the overview" => <Super>s

Logins

  • Nextcloud
  • Enter Thunderbird mail account passwords (are mounted, but impossible to automatically pass to Thunderbird)
  • Firefox Account
  • JetBrains (IDEA, CLion, ...)
  • Obsidian
  • Telegram, Signal, Threema, Element
  • planify
  • Anki
  • cider

Autostart must be manually Enabled

  • keepassxc
  • telegram-desktop
  • planify
  • element-desktop (manually created in autostart.nix)

About

My personal & professional flake-managed Nix(OS) setups

Resources

Stars

Watchers

Forks

Packages

No packages published