Skip to content

tcarrio/nixcfg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tom's [Nix] Configurations

This repository contains a Nix Flake for configuring my computers and home environment. These are the computers this configuration currently manages:

Hostname OEM Model / CPU OS Role Status
alien Alienware A100 Steam Machine NixOS Desktop TBD
kuroi Dell Dell Latitute E5470 NixOS Laptop Live 🧟
obsidian DIY AMD Ryzen 9 3900X NixOS Desktop Live
sktc0 Apple Apple M1 Pro macOS Laptop Live
nuc0 Intel Pentium N3700 NixOS Server TBD
nuc1 Intel Pentium N3700 NixOS Server TBD
nuc2 Intel Pentium N3700 NixOS Server TBD
nuc3 Intel Pentium N3700 NixOS Server TBD
nuc4 Intel Pentium N3700 NixOS Server Live
nuc5 Intel Pentium N3700 NixOS Server Live
nuc6 Intel Pentium N3700 NixOS Server Live
nuc7 Intel Pentium N3700 NixOS Server TBD
nuc8 Intel Pentium N3700 NixOS Server TBD
nuc9 Intel Pentium N3700 NixOS Server Live
rpi2 Raspberry Pi Raspberry Pi 2 NixOS Server WIP

The Graveyard: Decommissioned machines, configurations may be outdated or missing.

Hostname OEM Model / CPU OS Role Status
glass DIY AMD Ryzen 9 3900X NixOS Desktop RIP πŸͺ¦
shiroi DIY Celeron G1610T NixOS Server RIP πŸͺ¦
t510 Lenovo Thinkpad T510 NixOS Laptop RIP πŸͺ¦
tegra0 Nvidia Tegra K1 NixOS Server RIP πŸͺ¦
tegra1 Nvidia Tegra K1 NixOS Server RIP πŸͺ¦
tegra2 Nvidia Tegra K1 NixOS Server RIP πŸͺ¦
tegra3 Nvidia Tegra K1 NixOS Server RIP πŸͺ¦
tegra4 Nvidia Tegra K1 NixOS Server RIP πŸͺ¦

Respects

This project was forked from Wimpy's nixcfg repository, which you can find here. There is plenty of documentation to update so you will see plenty that is out of date here.

Structure

The nixos/mixins and home-manager/mixins are a collection of composited configurations based on the arguments defined in flake.nix.

Installing πŸ’Ύ

  • Two options for booting up into the installer:
    1. ISO images
      • Boot off a .iso image created by this flake using rebuild-iso-desktop or rebuild-iso-console (see below)
      • Put the .iso image on a USB drive
      • Boot the target computer from the USB drive
    2. PXE netboot image
      • Prerequsite: Have a local system running the pixiecore-pxe.nix service mixin
      • Boot your device into network PXE environment
  • Two installation options are available:
    1. Use the graphical Calamares installer to install an adhoc system (only available on iso-desktop)
    2. Run install-system <hostname> <username> <system-type> from a terminal
      • The install script uses Disko to automatically partition and format the disks, then uses my flake via nixos-install to complete a full-system installation
      • This flake is copied to the target user's home directory as ~/0xc/nixcfg
  • Make a cuppa πŸ«–
  • Reboot
  • Login and run rebuild-home (see below) from a terminal to complete the Home Manager configuration.

If the target system is booted from something other than the .iso image created by this flake, you can still install the system using the following:

curl -sL https://raw.githubusercontent.com/tcarrio/nixcfg/main/scripts/shell/install.sh | bash -s <hostname> <username> <type>

Recovery Images

This repository provides a couple of recovery ISO images. They are loosely based on the functionality of tools like SystemRescue. Like the other ISO images, there are console and desktop variants. The desktop variant includes all tools from the console variant, but in addition has some useful graphical tools.

Console

Desktop

Now, building! Run nix build .#nixosConfigurations.iso-recovery-(console|desktop).config.system.build.isoImage, specifying either console or desktop.

Installing Raspberry Pi 2 (WIP)

TBD.

For now, build the image with:

nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage -I nixos-config=./sdcard/rpi2.nix
# outputs to ${REPO_DIR}/result
zstdcat ./result/sd-image/nixos-sd-image-*-aarch64-linux.img.zst | dd bs=1M iflag=fullblock of=/dev/sde status=progress

Installing macOS

The nix-darwin project provides support for managing macOS systems with Nix in a similar fashion to NixOS. With this, we can ensure that the system has everything we need available and that we can reproduce a working development environment with minimal overhead.

For the most part, the scripts/shell/bootstrap-darwin-machine.sh Bash script provides sufficient automation to get a macOS machine fully configured from scratch. This includes installation of Nix through the nixos.org installer then utilizes the latest main ref and Nix dev shells to execute the commands. This infers the targets based on your hostname and username per the darwin-rebuild and home-manager standard, such that darwin-rebuild uses the $hostname for your default target, and home-manager uses $username@$hostname. An example of this is tcarrio@glass. On my glass workstation with the current user tcarrio, no additional arguments would need to be passed.

Note: Because of this, the script does not support additional arguments yet.

Remote Installation Tips

You can often speed things up on smaller systems by delegating the build to another. For example, you might have a NixOS configuration that you could build on e.g. a 32-core AMD that you then deploy or copy resources from to an older dual-core machine. Compiling Rust programs on 3rd-gen Intels? No way!

You can do the following with a few different Nix commands:

remoteUser="foo"
remoteHost="bar"
hostname="baz"

# suppose we have a nixos system config defined in our flake
nix build .#nixosConfigurations.$hostname.config.system.build.toplevel

# we can get a reference to its path in the Nix store with
drvPath="$(nix eval ".#nixosConfigurations.$hostname.config.system.build.toplevel" --json | jq -r .)"

# now we built it locally, we could copy it to a remote system
nix-copy-closure --to $remoteUser@$remoteHost "$drvPath"

## OR, if you have a live system, nixos-rebuild encapsulates this logic and more
nixos-rebuild switch --flake .#$hostname --target-host $remoteUser@$remoteHost

Applying Changes ✨

I clone this repo to ~/0xc/nixcfg. NixOS and Home Manager changes are applied separately because I have some non-NixOS hosts.

git clone git@github:tcarrio/nixcfg ~/0xc/nixcfg

NixOS ❄️

A rebuild-host alias is provided that does the following:

sudo nixos-rebuild switch --flake $HOME/0xc/nixcfg

Home Manager 🏠️

A rebuild-home alias is provided that does the following:

home-manager switch -b backup --flake $HOME/0xc/nixcfg

ISO πŸ“€

Aliases for rebuild-iso-desktop (desktop) and rebuild-iso-console (console only) are provided that create .iso images from this flake. They do the following:

pushd $HOME/0xc/nixcfg
nix build .#nixosConfigurations.iso.config.system.build.isoImage
popd

A live image will be left in ~/$HOME/0xc/nixcfg/result/iso/. These .iso images are also periodically built and published via GitHub Actions and available in this project's Releases.

Available Packages πŸ“¦

This flake provides several custom packages available through pkgs in your NixOS or Home Manager configurations:

Package List

  • kube-rsync - Kubernetes rsync utility
  • zeit - Time tracking tool
  • gqurl - GraphQL URL utility (built with Bun)
  • nixvim - Pre-configured Neovim with plugins and Tokyo Night theme

nixvim Usage

The nixvim package provides a fully configured Neovim setup with LSP, treesitter, telescope, and more. It uses the Tokyo Night "storm" theme by default.

Basic Usage

# In your configuration.nix or home.nix
environment.systemPackages = with pkgs; [
  nixvim
];

Features

The nixvim package includes:

  • Tokyo Night "storm" colorscheme
  • LSP support (Lua, Nix, Rust, TypeScript)
  • Treesitter syntax highlighting
  • Telescope fuzzy finder
  • File explorer (nvim-tree)
  • Terminal integration (toggleterm)
  • Git integration (fugitive, gitsigns)
  • Autocompletion with nvim-cmp
  • Status line with lualine

Customization

The package can be customized by modifying the configuration files in pkgs/nixvim/. For complex customizations, consider forking the configuration or using nixvim directly in your system configuration.

What's in the box? 🎁

Nix is configured with flake support and the unified CLI enabled.

Structure

Here is the directory structure I'm using.

.
β”œβ”€β”€ darwin
β”‚  β”œβ”€β”€ mixins -> ../nixos/mixins/
β”‚  β”œβ”€β”€ default.nix
β”‚  └── sktc0
β”œβ”€β”€ home-manager
β”‚  β”œβ”€β”€ mixins
β”‚  β”‚  β”œβ”€β”€ console
β”‚  β”‚  β”œβ”€β”€ desktop
β”‚  β”‚  β”œβ”€β”€ services
β”‚  β”‚  └── users
β”‚  └── default.nix
β”œβ”€β”€ lib
β”‚  β”œβ”€β”€ default.nix
β”‚  β”œβ”€β”€ helpers.nix
β”‚  └── ssh-matrix.nix
β”œβ”€β”€ LICENSE
β”œβ”€β”€ nixos
β”‚  β”œβ”€β”€ mixins
β”‚  β”‚  β”œβ”€β”€ av
β”‚  β”‚  β”œβ”€β”€ console
β”‚  β”‚  β”œβ”€β”€ desktop
β”‚  β”‚  β”œβ”€β”€ hardware
β”‚  β”‚  β”œβ”€β”€ services
β”‚  β”‚  β”œβ”€β”€ users
β”‚  β”‚  └── virt
β”‚  β”œβ”€β”€ default.nix
β”‚  β”œβ”€β”€ iso
β”‚  β”‚  β”œβ”€β”€ iso-console
β”‚  β”‚  β”œβ”€β”€ iso-desktop
β”‚  β”‚  └── iso-nuc
β”‚  β”œβ”€β”€ server
β”‚  β”‚  β”œβ”€β”€ NUC.md
β”‚  β”‚  β”œβ”€β”€ nuc0
β”‚  β”‚  └── pxe-server
β”‚  └── workstation
β”‚     β”œβ”€β”€ glass
β”‚     β”œβ”€β”€ kuroi
β”‚     β”œβ”€β”€ t510
β”‚     └── vm
β”œβ”€β”€ overlays
β”œβ”€β”€ pkgs
β”œβ”€β”€ scripts
β”œβ”€β”€ sdcard
β”œβ”€β”€ secrets
└── shells

The Shell 🐚

Fish shell with powerline-go and a collection of tools that deliver a somewhat "Modern Unix" experience. The base system has a firewall enabled and also includes OpenSSH, ZeroTier, Podman & Distrobox and, of course, a delightfully configured [micro]. (Fight me! πŸ₯Š)

neofetch on Designare

The Desktop πŸ–₯️

MATE Desktop πŸ§‰ and Pantheon πŸ›οΈ are the two desktop options available. The font configuration is common with both desktops using Work Sans and Fira Code. The usual creature comforts you'd expect to find in a Linux Desktop are integrated such as Pipewire, Bluetooth, Avahi, CUPS, SANE and NetworkManager.

Desktop System Configuration Theme
MATE MATE Install MATE Configuration Yaru Magenta (Dark)
Pantheon Pantheon Install Pantheon Configuration elementary Bubble Gum (Dark)

Eye Candy πŸ‘€πŸ¬

GNOME on Glass

TODO πŸ—’οΈ

Hardware

  • Add all computers to the table
  • Implement Disko partitioning
  • Integrate .iso building
  • Integrate OpenRGB
  • Integrate OpenRazer
  • Integrate StreamDeck
  • Integrate Xone
  • Migrate (maybe) to ZFS, with backups via zrepl
  • Fix Magewell mwprocapture driver: nixpkgs#221209
  • Support Raspberry Pi installer
    • With Nix flakes
  • Support macOS with nix-darwin
  • Support Roccat tools with group-based access control for hidraw

Applications

  • Integrate an Emoji picker
  • Integrate AppCenter and Flathub
  • Integrate Steam
  • Add Ferdium, Rambox or Wavebox
  • Add Password Managers
    • Add Bitwarden
    • Add 1Password

Services

  • Integrate Borg Backups
  • Integrate cockpit (server)
  • Integrate notify
  • Integrate Plex
  • Integrate homepage
  • Integrate fwupd
  • Integrate Keybase
  • Integrate Syncthing
  • Integrate sshguard

Configuration

  • Embed install script in the ISO
  • Integrate agenix or sops-nix
  • Integrate capabilities from nix-starter-configs
  • Integrate wallpapers
  • Integrate faces
  • Include Serif fonts
  • Include fallback fonts for Work Sans, Fira Code and Joypixels
  • Create common user settings and discrete user settings
  • Move application defaults out of the desktop defaults
  • Create standard directories in /home/tcarrio using systemd.user.tmpfiles.rules.
  • Create .envrc files in /home/tcarrio.
  • Bind Syncthing GUI to ZeroTier.
  • Configure Plank.
  • Fix Unfree in Home Manager)

Game Development

  • Defold
  • Godot
  • PICO-8

Shell

  • emacs
  • fzf
  • tmate or tmux
  • neovim
  • nnn or broot or felix or ranger

Inspirations πŸ§‘β€πŸ«

Before preparing my NixOS and Home Manager configurations I took a look at what other Nix users are doing. My colleagues shared their configs and tips which included nome from Luc Perkins, nixos-config from Cole Helbling, flake from Ana Hoverbear and her Declarative GNOME configuration with NixOS blog post. A couple of friends also shared their configurations and here's Jon Seager's nixos-config and Aaron Honeycutt's nix-configs.

While learning Nix I watched some talks/interviews with Matthew Croughan and Will Taylor's Nix tutorials on Youtube. Will Taylor's dotfiles are worth a look, as are his videos, and Matthew Croughan's nixcfg is also a useful reference. After I created my initial flake I found nix-starter-configs by Gabriel Fontes which is an excellent starting point. I'll be incorporating many of the techniques it demonstrates in my nixcfg.

I like the directory hierarchy in Jon Seager's nixos-config and the mixin pattern used in Matthew Croughan's nixcfg, so my initial Nix configuration is heavily influenced by both of those. Ana's excellent Declarative GNOME configuration with NixOS blog post was essential to get a personalised desktop. That said, there's plenty to learn from browsing other people's Nix configurations, not least for discovering cool software. I recommend a search of GitHub nixos configuration from time to time to see what interesting techniques you pick up and new tools you might discover.

The Disko implementation and automated installation is chasing the ideas outlined in these blog posts:

About

Nix configurations for various servers, desktops, and laptops

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •