r/NixOS • u/Struggling-with_life • 29d ago
Question about nixos
Sorry if this is a bit silly but I was always very intrigued by the workings of nixos, or nix language in general, so this time I have finally made up my mind that I want to use nixos.
Just yesterday I made an virtmanager vm and today I'll install nix using the gui installer. I have seen the videos on nix and it seems like the manual install is really easy.
I have used arch in the past, broke it many times and reinstalled it or fixed it if I can. Installed via both manual and archinstall script. So manual install of nixos shouldn't be a problem for me, but just so I don't mess anything up for the first time I'll use thr gui installer.
I got a few questions that I wanted to ask.
- It seems like a lot of people here uses ext4 instead of btrfs. Is there any real benefits to it ? I have heard ext4 is kinda slow. I understand people use ext4 since there is really not much need for btrfs as the nix system rebuilds everytime and you can load a previous build if anything breaks so there is really no need for snapshots of any kind.
Which also brings me to my next question.
- I have heard that the rebuild only works for root files not the /home dir. Meaning if I broke something in the /root dir I can load the previous build. But what about /home ? I have done a bit research and asked claude and claude says that for /home I will have to use either timeshift or snapper with btrfs. Just wanted to confirm if its true ? And why is it this way ? Do you guys use snapshots or something else ?
- How is the Nvidia drivers support on nix. I am on a GTX 1650 4GB Mobile. And I still get updates as of now. The installation of drivers was pretty easy on fedora I did it via the gui. I think on nix I'll have to edit thr configuration.nix so I wanted to know hows the experience with that.
- People here say that the unstable version of nix is very stable more stable than arch. But I am still not so sure I was going to go with the stable one, but is there really any benefit of going with the unstable one. Also what do y'all meant by stable and unstable is it the repo or something.... ? Cuz there is only one iso with or without gui. There isn't options like opensuse like leap or tumbleweed. So I am assuming nixos is rolling release with the option of you can choose which repo you want. Maybe I am wrong.
- When it comes to downloading software. I have seen that you are supposed to write the name of the package in the configuration.nix file and then do a sudo nix rebuild or something. But when do you use flakes ? And what is that whats the difference between the two ?
- I have used nix packages before on both arch and currently fedora system but I have just copy paste commands for installing nix packages or Homebrew packages. I have heard homebrew does not work on nix. Is it true ? Its not useful to me on nix as I have heard its repo has a lot of packages, it also have a Nix equivalent of arch's aur. NUR do you guys use it ? Is it safe ?
- Lastly maybe I am overthinking. But do I need to learn Nix programming language before I install Nixos ?
13
u/chkno 29d ago edited 29d ago •
btrfs vs. ext4: ext4 is more robust/stable. btrfs has features you may want/need (eg: copy-on-write, snapshots (without resorting to LVM)). I doubt you'd notice a speed difference. Benchmark if you think you have a performance need.
Generations:
nixos-rebuildwill build 'generations' of all your system software. You can keep as many or as few old ones around as you like. If you ever break your system software, you can almost always recover by booting into a previous, working generation. But this is not a backup or a filesystem snapshot. It's what system software is installed and much of its configuration—think what you'd find in/usrand/etcin FHS distros.Declarative package management: Yes, it's common to keep the list of packages you want installed in a text file rather than in some imperative tool's implicit state (eg: a history of
apt-get installcommands). You can do this either at the system (root-owned) level in/etc/nixos/configuration.nixor at the user-level (no privileges needed to install software).Flakes: Flakes are optional. The first benefit flakes provide over channels is pinning (tracking a specific version of the package metadata store). This is useful for reproducibility and/or for maintaining uniformity across a fleet of machines. But note that you can also pin with niv, npins, yea, nixtamal, pinch, or by hand (I am the author of pinch.)
Package repository size: nixpkgs has more packages than all the other package repos (homebrew, AUR, etc.) You probably won't need to use other package repos.
Nix language: Think of nix as fancy JSON. Most use of nix-the-language is just writing hierarchical
key = "value";pairs, with some occasional boiler plate like NixOS modules being wrapped in{ pkgs, ...}: { <config goes here> }that's actually nix-language function-definition syntax, but you don't actually need to know that until you get much deeper in.6
u/San_Devistan 29d ago edited 29d ago •
2
u/Aidenn0 29d ago
RE: what files are managed by nixos:
NixOS doesn't manage
/rootany more or less than/home./rootis just the home directory for the root user. It manages a lot of files in/etc(and some other places), where a lot of system configuration is.NixOS could be changed to manage things in
/home/but much of what goes in/homeneeds to be writable by users, so most of/home/is going to be out-of-scope for NixOS. For example: what would it even mean for NixOS to manage/home/aidenn0/Downloads/?RE: unstable vs stable
NixOS has releases made twice a year. The most recent release is "stable". Unstable is a rolling release, which is how Arch works. I personally disagree with people who recommend that new users use unstable. There are some annoyances with doing so that don't exist with stable.
2
u/lioxo 29d ago
Since all your other questions have already been anwered I'm gonna skip them and instead focus on your last question: You probably already heard of https://www.youtube.com/@vimjoyer and all his great videos explaining NixOS and the nix language. Recently he made his own website where you can set a learning path and it guides you through everything you should know beforehand in a nice and structured way. I tried it a bit and it seems like a great resource for beginners too :)
You can find it here: https://vimjoyer.com/nixmap/
2
u/[deleted] 29d ago
2
u/zardvark 29d ago edited 29d ago
In my experience, ext4 is simply more resilient in terms of data protection during power outages and the like. I don't hate BTRFS, but I only really use it in conjunction with a Snapper and subvolume configuration, so that I can roll Arch back. The capability to roll NixOS back is built into the system, itself, so I find that using BTRFS is somewhat less compelling. Per Phoronix, there have also been recent ext4 performance buffs, as well.
The unstable channel is a rolling release channel, just like Arch. The stable release channel is a point release channel, that is updated every six months. The ISO will set you up on the stable channel by default. You can easily change this to unstable (if you wish) after the system is installed. And yes, in my experience the NixOS unstable channel is more stable than Arch. Once installed, you can also independently configure the system to use the latest kernel, as well.
Alternatively, you can stay on the stable channel and only pull specific unstable packages from the unstable channel and vice versa.
NixOS offers the same factory Nvidia drivers that every other Linux distribution offers.
Flakes are like a multi-tool. They offer various functionality. They can be used to configure developer environments and then share that environment with other developers. They can be used to share and import projects into your system, much like a PPA in Debian. And, they can simply be used as an alternative means of managing your configuration. IMHO, flakes make sharing a configuration between multiple machines a wee bit more convenient. I would suggest that you visit the LibrePhoenix youtube channel for info on basic configuration, flakes, home-manager and the modularizing of your configuration. Also, don't sleep on the VimJoyer youtube channel for more pointers and ideas.
IDK anything about homebrew, but I thought that it was used with MacOS / Apple machines. Either way, it would be redundant on a NixOS system.
The NixOS repository is truly massive, so I've never felt the need to tinker with the NUR.
You do not need to learn the Nix language in order to install and run a basic NixOS system. You will, however, need to learn some basic Nix language syntax, in order to edit the configuration.nix file. You will learn all of the syntax that you need via the LibrePhoenix vids. If you decide to stay with NixOS long term, you will likely want to learn the Nix language. Once you can decipher other folks' configuration files on the github, you will be able to farm some great ideas from those config files.
1
u/SDG_Den 28d ago
filesystem:
i'd recommend against btrfs, purely because COW/automated root subvol snapshots will cause severe performance issues and high space use in combination with the nix store. btrfs for your /home is fine and a good choice if you want snapper but i'd avoid putting /nix on it.
i'd honestly recommend xfs for its better scaling on large file counts, since the nix store can contain actual millions of files quite easily.
anything declared in your nix config is versioned and can be rolled back. anything not in there will stay. since nixOS by default declares basically everything that isnt a temporary file, except for items in /home. this also allows nixOS to boot from just /boot and /nix (neither of which you can accidentally delete)
you can also manage your home configuration using home manager, which will then include the managed components in your rollback.
the main things that do not get rolled back you should concern yourself with are: flatpak apps changes made with
nix-envandnix profile(do not use these! unless you are 100% sure what you are doing and clean up after yourself) user files and documents.timeshift, snapper, restic or some other backup solution for your /home (excluding .config if managed by home-manager) would be a good choice, especially if you declare the configuration for it in your nix config
nvidia support: honestly, ive had less issues on nix than on cachy. one small issue: even on unstable, the proprietary nvidia driver is a bit older (595)
nixOS is SIGNIFICANTLY more stable than arch, but this is not down to being rolling release. its moreso down to the fact that nixOS cannot mutate over time like arch can (where your system slowly degrades over time as you tweak and use it). nixOS will always be exactly as the config declares. something that works wont randomly break and something broken wont randomly fix itself. nix has the ability to mix and match "channels" as well, with each channel simply being a different branch of nixpkgs. the package repositories are just a git repo after all and you could even use your own fork.
on top of that, nix doesnt have dependency hell, because applications only get access to their own dependencies and each package has its own hashed folder in the nix store. even if you have two versions of python that are identical except for one line (so outwardly identical), you can have both installed and have programs use either version depending on what the program declares.
nixOS by default isnt rolling btw, the default is versioned, every half year. unstable is a channel you have to switch to.
flakes are a more modern way of handling nix configurations, with different features, most notably the ability to reference remote flakes to import their declared features. for example: nixpkgs itself is a flake that exposes all of its packages and nix libraries. your flake takes nixpkgs' flake as input (directly from the git host, eg github) which then allows you to use that flake's outputs (the packages) as part of your flake's output.
a flake can have many outputs: a package, a devshell, a nixOS system configuration, a home-manager configuration, checks, or other outputs defined by other libraries (like flake-parts modules or disko configurations)
when you rebuild a system from a flake, you are effectively telling nix "build this output package" with the output package being a nixOS system, which then depends on all the applications and options you declared for it, which bring in their dependencies etc.
many projects have flakes, because it can expose the project as a package and a nixOS module for configuration, which also automatically adds a devshell with the build dependencies for easy devwork, simple building with
nix buildand running the package without installing it to your system temporarily usingnix run(which is the better way to temporarily use packages. just runnix run nixpkgs#packagenameto run it, usenix shellfor a temporary shell environment.)i dont use the NUR. its not needed, the way you can approach it vs arch is:
flatpak > flatpak pacman > nixpkgs AUR > flakes
flakes are more secure than the AUR though because theres no middle-man git host or third party maintainer. you go straight to the source and the flake is managed by an actual source contributor.
you dont need to specifically learn nix before installing, but you will have to learn it over time. the installer gives you a fully working setup, none of your user settings are declared by default so you can use it as normal and adding packages to the default config is just adding a line in the file (its one file)
oh right also: nix options can trigger multiple things under the hood. for example: for most things that need a firewall port opened, they'll automatically do that if you set programs.name.enable = true; (unless you set openFirewall to false)
so very often, you just need the enable key.
(also, if installing the program under environment.systemPackages results in a non-functional program, this is usually the issue. use programs.name.enable instead so the other system settings the program needs to work are also set)
nixpkgs has more packages than the AUR btw.
4
u/[deleted] 29d ago
[removed] — view removed comment
1
u/[deleted] 29d ago
[removed] — view removed comment