==== Time Stamps ==== 00:00 - Intro 00:33 - What is Home Manager? 03:10 - How I use Home Manager 03:34 - Using Home.file 06:09 - Home Manager without Home.file 07:20 - zsh As An Example 08:58 - The Downsides of Home Manager 10:28 - A Few More Benefits, Tho 13:34 - Wrapping Up
So today I want to talk about NixOS Home Manager. Now I need to put some
provisos out there and that I don't know everything. I'm still very much a
noob when it comes to NixOS. I've, despite the fact that I've been using it
for over six months, there's still a lot of stuff here that I don't know a lot
about. So I can't tell you how a lot of stuff works. I can't tell you why some
things are the way that they are. But I do have some general thoughts on Home
Manager itself. Now first off let's explain what Home Manager is. So the idea
behind NixOS is that everything is in a configuration file. So everything
Linux related. So if you've ever used OpenSUSE, which I have the sticker for
still by the way. I am still pointing at the damn sticker. You've
probably used Yast. Yast is a one-stop shop for everything Linux. If you want to
create a systemd service or you want to set up AutoFS or NFS, you go through
Yast to do it. Now you can do it the normal way on OpenSUSE, but a lot of
people would use Yast, at least back in the day when Yast was still a thing. On
NixOS, the configuration file is Yast, basically. That's the way that I have
been looking at it. It is the hub where you do all of the things Linux related.
That's your configuration.nix. And no matter how complex you've made
your configuration, that's where you'll spend a lot of your time when you want
to do things like install an application or set up a service or set an
environment variable. A lot of times you'll do this in your configuration
file and the reason why you do that is because it's called a declarative
operating system, right? You're doing this because you want to be able to take this
configuration and be able to move it from one computer to another or reinstall
all of your stuff exactly the same way it was if you do a reinstall. That's the
reason why the configuration file exists, or at least one of the reasons why, right?
And that makes NixOS obviously fairly unique and it's just kind of the way
that it works. The Home Manager addition to NixOS takes that idea and expands it
from just the Linux side of things to everything. So you can use Home Manager
in several different ways. A lot of people will configure everything inside
of Home Manager. So basically you'll have a configuration file that will look like
a conglomeration of many configuration files. So you'll have your HyperLand and
your Weybar and your Rolfi, all the stuff inside of your home.nix
configuration system. You can obviously source things, whatever, but you're
basically writing all of your configuration files in the Nix
programming language. And the benefits behind doing it that way is that you can
take the same setup, not only Linux-wise, but your entire setup. Your window
manager, your bar, your Rolfi, your key bindings, everything will be able to
stay inside of that configuration file and move with you as you move on to
different installs of NixOS. Another way you can use Home Manager is a little bit
less invasive. It allows you to basically source your dot files into
your home.nix and then use regular language to configure your stuff. So let
me show you my home.nix where you can kind of see an example of both ways of
doing things. So I've done things in a way that is a little bit less extreme
than a lot of NixOS users. I don't have everything configured in Home Manager. I
probably never will. There are a few things that I just will never do in
terms of this, and I'll tell you why here in a few minutes. But basically, my idea
is things that don't change very often, I'm perfectly happy using Home Manager
for. So if I were to take this config, my NixOS config, over to my laptop and
install it, I would have access to my bashrc files. I'd have git set up right
on launch. I'd have zsh set up right on launch, right? Exactly the way that I
want it, along with all my aliases and everything that goes along with it.
That's really cool. So like I said, you can see both ways of doing things right
here in this configuration file. We have the home.file here, which is basically
the idea of sourcing things. So if I were to go to this file here, I could show you
this is just a regular bashrc file. Everything here looks exactly like a
bashrc file would if you were using a regular real distro. Probably outside of
the Pywall stuff, right? It's just the way that a bashrc is supposed to look.
Same thing with the aliases stuff. That's just a list of aliases that you'd find
on any computer. This is basically just sourcing it, and then when you rebuild
Nix, what this does is it takes it from where you've stored your files and puts
them where there need to be in terms of a symlink. It basically symlinks from
your .files folder to where they need to go, and you tell it where it needs to go
by this first part here. So this is telling Nix that it needs to go in
.bashrc, which is in the home directory. Home is always assumed because
it's home.file, right? So this is home.bashrc, and then you end it with
.source. Then it tells NixOS where the actual source file is.
This is where it's going to link it. This is where it's going to source it
from, right? That's the same thing here. This is where it needs to link it to.
This is where it is sourced from. So that's the way you use home.file, and
this is the way that I would prefer to use it if I were going to use it
completely for everything, simply because it allows me to configure stuff in the
language that they're meant to be configured in. So if I were to do my
qtile configuration from here, which I wouldn't do, I would still be able to do
everything in Python, whereas if I were going to do it with the Nix
language, I'd have to use their options that they've built in using home manager,
right? So that's what you're actually seeing here with the git stuff. So this
right here would translate to a git config somewhere on your system, right?
If you were to work on a traditional Linux distro, you would have a git
configuration file somewhere that would tell it all of these things. It would
define the rebase policy. It would set up auto remote and stuff like that if you
wanted to do so, right? With this, you're configuring git in the NixOS language.
So I'm telling it to enable itself. I'm setting some settings. So in this
case, I'm setting some aliases here which will apply no matter what shell I'm
using. It will set the default editor. There's a lot more options and
stuff like that for git. This is just what I've done so far. You can also set,
for example, your email address and your username, because like when you set up
git for the first time, it always asks you for your global email address and
your global username. You could do that here as well. I should probably do that
at some point because I don't actually need to do that the manual way. So
that's how you would go through and do that for basically any program that you
wanted to use if you wanted to use home manager. You could either do it the home
file like I've done up here or you could do it this way. Same thing with like the
ZSH. ZSH will actually give you more of a idea of how this is done. So it
enables itself. It also enables some ZSH plugins. You can also define different
functions within certain areas. The init content here will basically, this right
here, basically adds this stuff to your ZSH RC. So I'm going to source the
p.10k.zsh file. I'm going to source my aliases. I'm going to source a Z alias thing
which is just for ZSH. I'm going to auto load some plugins here. I'm going to
rebind some keys here and that all this stuff here. So if I were to actually open
up my ZSH RC here, you can actually see that it is a symlink which is why it's
green. So if we do that ZSH RC like so, you can actually see that this just
looks like a regular ZSH RC file but it was composed and compiled by NixOS. I
didn't create this at all. It's just not something that I did. I did all of the
work here in Home Manager and it did all the work here in the ZSH RC file. So
all the stuff that I added, so for example the functions and stuff like that,
all the stuff that's right here in the init content function, basically is right
here at the end of the ZSH RC file. It appended it to the end. So that's how
Home Manager works. So obviously that's very broad and I'm sure there's a lot
of things there that I said wrong but you can kind of tell how I
rambled through it that it's still something that I'm still wrapping my
head around. But I think that overall Home Manager is very interesting but it
has some downsides. So the biggest downside, and this is the reason why I'll
never use it in terms of like Qtile or Rofi or anything that I change
themes on all the time, your entire system has to be rebuilt in order to use
Home Manager. Depending on how you've installed Home Manager, you can actually
use Home Manager switch in order to do this if you've installed it in a
certain way. But if you've built it into your NixOS configuration file, you have
to rebuild your entire NixOS config every time you make a change. So every
time I add an alias to bash, for example, I have to do a rebuild of my
NixOS system in order for that to take effect. So that's a big hindrance to
actually this being all that useful for people who make a lot of changes. That's
the reason why I've set it up for things that don't change very often. So I don't
add a lot of aliases anymore. My alias file has been basically the same for
years and only occasionally gets a new addition or subtraction or whatever,
right? So that's okay to be in Home Manager. Things like Git, that never
changes. Things like ZSH, that stuff's never going to change. So by doing it in
Home Manager, it doesn't bother me that I have to do rebuild because it
doesn't happen that often. Whereas if I were to use it with Qtile or something
like that where I change it constantly, I'm always adding new things, I'm always
changing themes, I'd have to rebuild my system probably five or six times a day
just to make my Qtile configuration change. And I don't want to have to do
that. So that's the biggest downside of Home Manager that I can see because it
just takes a lot of extra time. Now there are some benefits beyond just being able
to take your configuration from computer to computer or install to install.
It allows you to set a lot of settings in ways that make a little bit more
sense. So for example, let's just go back to my configuration here and go to that
Git function. Not only does it enable it here, but it allows you to set your
aliases, right? In a normal Git config, you wouldn't set your aliases with your
Git config. You'd use your bashrc or your zshrc or your phish configuration
file, right? That's how you'd set your aliases, which means you'd have two
separate places dealing with Git. And while I still do have two separate
places dealing with Git because I have an aliases file that I've used for years
so all my Git stuff is in there, theoretically I can move all that stuff
here and then all the Git stuff would be together. So it doesn't necessarily mean
that all of this configuration stuff that goes with these things is something
that you would see traditionally in a configuration file. Because of the way
they've done things, it allows you to set some things that are usually outside of
the parameters of the regular configuration file. So things like an
alias here or actually enabling zsh plugins in a regular way instead of
having to like curl something from a random Git repository, you just do that
here within the zsh function and it will do it for you. You don't have to worry
about any of the extraneous stuff you'd usually have to do if you were setting
this up on a traditional distro. So I really do like that aspect of it
where I have a Git section, I have a zsh section, and it allows me to set a lot of
settings within those sections to make changes to whatever I want to make
changes to. And that's kind of the feeling of NixOS I have completely. It
allows you to control your settings in a more condensed fashion where, for
example, here's a good example. I don't know how this would work in in Nix
because I've never done it before, but you could in theory control all of your
plasma settings or at least the ones you'd normally control through a
configuration file in one place, right? Whereas if you were to try to manage
your plasma configuration via configuration file in a normal setting,
you'd have like 40 different configuration files that you'd have to
keep track of, whereas with Nix it would just be the one and all the settings
would be kind of put together. Like I said, I don't know how that would
work, I've never tried it, but I know for a fact that you can at least do some of
the stuff with plasma that way. Things like controlling a lot of the SDDM
configuration files can be done right within your NixOS config, and if you've
ever tried to mess around with the SDDM configuration, you know that it's a mess,
right? With Nix, you're doing it in a Nix language, you're just setting some
options to true or false or whatever, and you're setting some paths if you want to
change like the wallpaper, you can do that right inside of your declarative
NixOS configuration file or with Home Manager if you wanted to. So the idea is
you can kind of combine all of the settings for these things in one
configuration file, and that is pretty cool. Again, it has its drawbacks, but it
also allows you to do some really interesting things that really aren't
possible in the more traditional way of managing configuration files. So that's
how I use Home Manager. I'm not sure that I did a very good job of explaining it. I
hope I did okay. If you have questions, you can leave those in the comment
section below. I'd love to hear from you. You can follow me on Mastodon or
Odyssey. Those links will be in the video description. You can support me on
Patreon at patreon.com slash the Linux cast. There you'll find a weekly exclusive
podcast where I just sit in front of this microphone and yap for about 15 or
15 minutes or so. If that's something that's interesting to you guys, you can
support me on Patreon or YouTube and get that every week. So there's that. Thanks
to everybody who does support me on Patreon or YouTube. You guys are all
absolutely amazing. Without you, the channel just would not be anywhere near
where it is right now. So thank you so very much. If you guys want, if anybody
wants to get a hat like this one, or a t-shirt, or a mug, or whatever, I have all
sorts of merch over on my store which is available at shop.thelinuxcast.org.
All the support there goes directly towards helping me make more Linux
content for you guys. So thank you so very much for checking that out. Thanks
everybody for watching. I hope you have a wonderful day. I will see you next time.