Skip to content

Prometheus7435/nix-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What am I

This is my NixOS config using flakes. I’m taking a lot of the initial setup from Whimpy’s config. I’m quite new to this and his setup is quite close to what I wanted anyway.

What do I want from me

The big things I want is to have a consistent KDE setup using ZFS for the file system. And someday I’ll figure out how the emacs-overlay works and then use that to replace my emacs org-babel config.

File System

HostnameOEMModelCPUGPUOSFilesystemRoleStatus
phoenixThinkpadT14 AMD Gen 1AMD Ryzen 5 PRO 4650UNixOSZFSlaptopDONE
starbaseDIYCustomAMD EPYC 7302NixOSZFSracktopDONE
fermiVMVMNixOSext4testTODO
akiraThinkpadX1 tablet Gen 3Intel i7NixOSZFSslatetopDONE
odysseyCustomCustomAMD Ryzen 7 3700XNVIDIA A4000NixOSZFSdesktopDONE
marsVMVM8 vCPUNixOSext4IOT VMTODO

I like ZFS and NixOS seems to have the easiest and most stable implementation of it I’ve come across in Linux. Due to the difference in licenses, ZFS can’t be added to the Linux kernel like Btrfs is. To use it in most distros, you have to set it up yourself and the risk is all on you. Not fun. But NixOS has the modules addded by default and make it super easy to implement. Here’s hoping that it’s as stable long term as it’s been short term.

The only place where I won’t be using ZFS is in the VMs. This is because there’s no benefit from nesting ZFS, as it were. ZFS works better when it has direct access to the drives. So I’ll be using boring ol’ ext4 on the VMs. That way, I can take snapshots of the VMs using ZFS and not worry.

Install

Initially, I was using a bash script from mcdonc to make a a basic config for a non-flake install. Now I’m using Whimpy’s install script that uses Disko to build the root filesytem.

Computers

A lot of this will be the same, as I like my KDE and ZFS. The differences will largely come down to the specific hardware found in each. The status below is dependent on the status of the host config and this flake setup overall.

Because I’m being cheeky; laptop is laptop, slatetop is a tablet, racktop is a server, virtualtop are VMs, handtop is a phone, and desktop is desktop.

Machine Naming Convention

Surely the most important subject 😆 Why do this when you should treat mass deployments like cattle? Mostly so I can easily identify them in tailscale. Also, how many servers do you admin?!

I’m following the typical, something super nerdy thing I care deeply for. In this case, Star Trek.

The computers are named after Starfleet classes of starship. Roughly analogous to the size / capability of the class to the computer. For example, my tablet is named after the Akira class, a smaller nimble vessel. While the desktop is named for the Odyssey class, a big strong capable vessel.

The servers are named after starbases. The main one is named after the starbase that orbits Earth. Any offsite ones will be named Deep Space <n> and VMs will be named after a planet of the system that starbase resides in.

Smaller VMs are named after shuttlecraft classes, with the first being the Fermi acting as a pihole.

Installation

  • Clone this repo, cd into it, and run
sh scripts/install.sh <hostname> <username>
  • 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 ~/Zero/nix-config
  • Find ☕ in that nebula
  • Reboot
  • Login and run the command below to complete the Home Manager configuration.
home-manager switch -b backup --flake $HOME/Zero/nix-config

Applying Changes

This is a copy of Whimpy’s README.

I clone this repo to ~/Zero/nix-config. NixOS and Home Manager changes are applied separately.

git clone git@github.com:Prometheus7435/nix-config.git
# gh repo clone wimpysworld/nix-config ~/Zero/nix-config

NixOS snowflake

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

sudo nixos-rebuild switch --flake $HOME/Zero/nix-config

Home Manager house

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

home-manager switch -b backup --flake $HOME/Zero/nix-config

Troubleshooting

Home-Manager

I tried to rebuild the home-manager setup after a fresh install of starbase and it gave me an error. It said it could not find suitable profile directory even though the folder it was looking for exists. Turns out, it’s looking for a different folder it doesn’t tell you about. A simple

mkdir -p ~/.local/state/nix/profiles

rerun the command, and it’s all good.

This “should” be solved in the install script. But it’s here just in case.

Citation to solution: https://www.reddit.com/r/Nix/comments/1443k3o/home_manager_installation_could_not_find_suitable/

Git pulls

When I’ve deployed this to my server, I kept running into an issue where I’d try to pull and couldn’t because of a conflict. My guess is the flake.lock file was changed which caused a conflict. The way around that (assuming you don’t mind losing the local branch) is to run

git fetch --all && git reset --hard origin/main

I use the main branch name instead of the default “master”.

Citation to solution: https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files

Nvidia

My desktop has a Nvidia A4000 in it and when I was fresh installing NixOS on it I kept getting an error saying

When NVIDIA PRIME is enabled, the GPU bus IDs must be configured.

This was weird as I hadn’t configured any dual GPU options which, as I read the wiki, shouldn’t occur. I smashed my head against the wall until I commented out nixos-hardware.nixosModules.common-gpu-nvidia, then it installed fine. My guess is that a config was being set even though I don’t have any other GPUs except the A4000. So it didn’t matter what was in my config, it would flag and fail.

So now my Nvidia config is only declared in the hardware.nix for the desktop. If I, one day, move to a system that has dual graphics I may switch it back.

Emacs Overlay

I have this “mostly” working. I have to call the org-babel config seperately from the init file, but the flake is incorporated and it installs the emacs modules as part of the system install/update. If you wanna see a spagetti mess of an emacs config, check it out.

Side issue that’s hit me a couple of times. If you specify a version of some package, make sure you remove any other package references for that. For this, I had emacs as an install package in the default.nix which overrode the specific emacs version I had set in emacs-config.nix. This also bit me earlier with Python packages. Must make sure to reference a package only in one place.

Inspirations

Wimpy’s nix-config for the basis of all of this

nix-starter-configs for awesome flake templates

mcdonc P51 config and YouTube series and install script

Disko for my disk setup

Ricky Kresslein for a bunch of docker setups

About

NixOS flake config with KDE and ZFS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published