Hi. This is my NixOS & home-manager configuration.
flake.nixis the root flake for NixOS / home-manager / packagesmodulescontains my custom modules for configuring programs / features. These modules expose options in thejnamespace.hostscontains the actual host configurations. These use the modules via thej.*options.packagescontains some custon Nix packages.shellscontains flakes with dev shells for various languages. If you install the home-manager config, you can use these in a folder (through direnv) by runninguse-dev-flake NAME.utilcontains Nix helper functions.dotfilescontains verbatim dotfiles (some of these are templated via Mustache).bincontains some scripts that are installed into$PATHthrough the home-manager config.assetscontains media assets (at the moment, only wallpapers).privateis a submodule with configuration I don't want to be publically available (e.g. SSH hosts).
If you stumble across this and are asking yourself if you should use NixOS -- let hlissner answer that question:
Should I use NixOS?
Short answer: no.
Long answer: no really. Don't.
Long long answer: I'm not kidding. Don't.
Unsigned long long answer: Alright alright. Here's why not:
- Its learning curve is steep.
- You will trial and error your way to enlightenment, if you survive the frustration long enough.
- NixOS is unlike other Linux distros. Your issues will be unique and difficult to google. A decent grasp of Linux and your chosen services is a must, if only to distinguish Nix(OS) issues from Linux (or upstream) issues -- as well as to debug them or report them to the correct authority (and coherently).
- If words like "declarative", "generational", and "immutable" don't put your sexuality in jeopardy, you're considering NixOS for the wrong reasons.
- The overhead of managing a NixOS config will rarely pay for itself with 3 systems or fewer (perhaps another distro with nix on top would suit you better?).
- Official documentation for Nix(OS) is vast, but shallow. Unofficial resources and example configs are sparse and tend toward too simple or too complex (and most are outdated). Case in point: this repo.
- The Nix language is obtuse and its toolchain is not intuitive. Your experience will be infinitely worse if functional languages are alien to you, however, learning Nix is a must to do even a fraction of what makes NixOS worth the trouble.
- If you need somebody else to tell you whether or not you need NixOS, you don't need NixOS.
If you're not discouraged by this, then you didn't need my advice in the first place. Stop procrastinating and try NixOS!
nix-shell -p nh
# Rebuild NixOS
./rebuild -s HOSTNAME
# Rebuild home-manager
./rebuild -u USER@HOSTNAMEand reboot.
- Add a new host to the
hostsattrset in flake.nix. The attribute name is the hostname. - Create a corresponding folder in hosts/. Copy
/etc/nixos/hardware-configuration.nixto this folder. - Create at least a
sys.nix(NixOS config) andhome.nix(home-manger config) in the folder.common.nix(if it exists) is added to both configs. Reference the existing hosts for how to structure your host config.
nix-shell -p nh
# Rebuild NixOS
./rebuild -s HOSTNAME
# Rebuild home-manager
./rebuild -u USER@HOSTNAMEand reboot.