Hello. There are a few documentation errors in this video. - At 1:25 the curl command should use a lowercase "-o" for its output argument, not an uppercase "-O" like: curl -o /tmp/disko.nix - At 3:46 your nix command copies the flake.nix it to the current working directory.. we need to move it into "mnt/etc/nixos" like: mv flake.nix /mnt/etc/nixos - At 5:10 the cp command should copy "/mnt/etc/nixos" to "/mnt/etc/persist", NOT "/etc/nixos" to "/etc/persist" like: cp /mnt/etc/nixos /mnt/etc/persist - At 7:03 on reboot, I had this error on boot "waiting for device /mnt-root/persist/system/var/lib/nixos to appear..." This happened because I copied /persist/nixos to /etc/nixos before reboot; to prevent this, delete any contents of "/etc/nixos" and then rebuild & reboot like: sudo rm -r /etc/nixos/* sudo nixos-rebuild boot --flake /persist/nixos#default reboot - At 7:27 you must add "inputs" to the argument for the configuration.nix function like: { config, lib, pkgs, inputs, ... }: { imports = [ ./hardware-configuration.nix ]; # ... } - At 7:47 on reboot, I got "[FAILED] Failed to start Home Manager environment for ", so I ran: systemctl status home-manager-mboyea.service which reported: hm-activate-[]: mkdir: cannot create directory "/persist/home": Permission denied The solution is to declare the /persist directories and their owners inside your nixos config. To do so, add the following to configuration.nix: systemd.tmpfiles.rules = { "d /persist/home/ 1777 root root -" # /persist/home created, owned by root "d /persist/home/ 0770 users -" # /persist/home/ created, owned by that user } Then, modify home.nix to target "/persist/home/": { pkgs, inputs, ... }: { # ... home.persistence."/persist/home/" = { # ... }; # ... } Make sure to replace with your username. Now, we finally have a working declarative NixOS config! @Vimjoyer, thank you for your work; your content on NixOS is enabling me to create my ideal Linux PC. Best wishes to you all in the future!
Uh oh! I made an error in this post and now I cannot edit to fix it.. The 7:47 configuration.nix fix should use square brackets & have correct chmod permissions like: systemd.tmpfiles.rules = [ "d /persist/home/ 0777 root root -" # create /persist/home owned by root "d /persist/home/ 0700 users -" # /persist/home/ owned by that user ]
I have the same problem as you at the 7:03 point but your solution doesn't work for me. I followed the instructions verbatim. I get "mounting /mnt-root/persist/system/var/lib/nixos in /mnt-root/var/lib/nixos failed: No such file or directory". What am I missing?
Wish I knew about your videos when I was setting up my heavily NixOS based Homelab. Impermanence took me a couple of weeks to learn and you explained it in 9 minutes lol.
Though more complicated if you really want to tune it, I personally prefer ZFS over LVM/BTRFS - it's far more mature, and quite rigorously tested prior to stable release - and it allows you to do some things that (as far as I know) you can't with BTRFS - primarily Zvols (using a chunk of your ZFS pool as arbitrary block storage), but other things like actually usable RAID5 and the ability to use zfs send with NAS solutions like Truenas is great (although technically you could just create a Zvol formatted with btrfs and use that - I actually did that when migrating from BTRFS to ZFS root).
Great video. I've been using impermanence for some time, but instead of a btrfs subvolume I'm mounting the root partition on a 1GB tmpfs. It's a good option if you have some RAM to spare.
I'm not sure how much RAM you have but you might want to consider removing the tmpfs size option. Without it, the size will default to half your total RAM which isn't an issue as tmpfs only uses as much memory as it needs. If you have 16GB of RAM and tmpfs size is 8GB, it won't actually reserve 8GB of memory all the time, it'll dynamically resize with 8GB being the limit. Thought I'd share because I wasn't aware of this before and I limited my tmpfs to 2GB but ran into issues when doing large system upgrades because build files in /tmp can be 4GB+ in size.
@@JManch_ I didn´t know about that, thanks for the advice! Actually, my /tmp is mounted on a @tmp subvolume, and I configured it to be cleaned on every boot (boot.tmp.cleanOnBoot = true). So far, I've never had any problems with this 1GB limit on /.
This sounds like the perfect setup for my workstation, which has 128G RAM that I rarely use up anyway. The only thing I'm missing right now is setting up LUKS with LVM underneath to merge two NVMEs for the home directory.
For anyone experiencing issues with "waiting for device /mnt-root/persist/system/var/lib/nixos to appear..." etc. after first enabling impermanence, I found that I had to run "sudo mkdir /persist/system" manually before rebooting
When following the tutorial at 7:45 the process crashes at trying to create /persist/home with a permission denied error. I think home-manager is run without root permissions and can't create the folder because of that. What did you do to prevent this?
@@vimjoyer Thank you. Is there a good way to do this from within the nixos config or do I have to create the directory myself every time when I install this config on a new system?
@@Mia-zb4zh Hi! I found a declarative way to solve this. The solution is to declare the /persist directories and their owners inside your nixos config. To do so, add the following to configuration.nix: systemd.tmpfiles.rules = { "d /persist/home/ 1777 root root -" # /persist/home owned by root "d /persist/home/ 0770 users -" # /persist/home/ owned by that user } Then, modify home.nix to target "/persist/home/": { pkgs, inputs, ... }: { # ... home.persistence."/persist/home/" = { # ... }; # ... } Make sure to replace with your username. Hope this helps!
This video has inspired me to play around with my setup. Thanks I do have a question if you have a moment. Is there any particular reason (for this setup) that you are using LVM/BTRFS and not just BTRFS directly?
could you probably do some more tutorials on features/options with btrfs and integrating with nix? like maybe using btrfs specific features for previous generations and so on? One more small thing, could you maybe do a small guide on on getting an fhs distro like arch to be dual booted along side nixos with btrfs file system? (just incase if nixos decides to fail like it happened when linux-firmware was recently packaged incorrectly causing it to not boot on amd gpu or maybe if we need something very fhs specific like some firmware flash tools)
I haven't used any legacy distros in a while, so I'm not sure about the second one. Hovewer I will surely make more NixOS + btrfs / (other filesystems) videos in the future.
You may be able to use something like DistroBox, but for firmware flashing that might be more trouble than it's worth. I generally keep a medicat USB for those purposes.
Their kernels with other linux distribution kernels, how storage in nix store affects performance, how nix store works together with different file systems, many things you can benchmark. @@ruroruro
@@ruroruro RUclips deleted my comment. There are many you can benchmark, nix kеrnels, nix store under different file systems, high performance applications, latency in them.
I use a similar setup; although using zfs & zfs snapshot restore to nuke root. My uptime right now is like 2 months and I'm a bit concerned about restart lmao
Your system won't get cluttered with old program cache / undeclared system state / old logs. Some garbage will usually accumulate in in .local/share, .cache, and other directories, and with this setup it will just get wiped.
@@vimjoyeroh I now also understand why people do that. At first deleting etc and var was looking just like a cool little useless thing to demonstrate how nix is unbrekable but yeahs could be useful to uncluttered the system. Personally Nix is already awesome and reproductible I can easily just reinstall everything but it’s great to finally see how all those automation are done
@@vimjoyer that means when i login to some websites in browser it will get erased??? sounds like this is something suited for servers... not desktops... tooo crazy..
Not related to this video (I'm just commenting here because this is your most recent video), but could you make a video on configuring nextcloud, jellyfin and lets encrypt SSL certificates without your server being exposed with nix/nix OS. It's quite a long process if you configure everything manually, and seems like it would be a logical use-case for nix OS.
Very nice. I'm not good enough to figure out how to do it yet but I really want to see a setup like this that uses ZFS and something like ZFS boot menu in place of grub for booting into previous generations.
@@vimjoyer I was speaking in general rather than requesting that you make a video on it, that feels a little presumptuous, though I'd be very interested to know how it goes if you tinker with a setup like this. ZFS boot menu is it's own minimal linux install that uses kexec to boot into a system image on a ZFS dataset. A couple of the things that are appealing about this are you can have secure boot enabled with ZFS boot menu. Also on a ZFS system you can declaratively specify your policy for snapshotting you ZFS datasets with sanoid and your backup schedule to a remote zpool with syncoid. If using ZFS native encryption you can send raw snapshots and the remote doesn't need the encryption key to receive the snapshot. So you can do block level differential backups to a remote that never has the ability to decrypt your files and retains all of the data integrity guarantees of ZFS.
Also, have I already said that visual quality of your videos is amazing? Well, it is! 😄 How do you animate them? Do you use something programmatic, like Manim?
@@vimjoyer huh! Do you not have a laptop? I thought people at this point always put encryption on atleast their home dir. For a desktop I can see people not bother, but with laptops I assumed it was common.
Yay Good resources for nixos impermaence is searching "Delete Your Darlings" or "tmpfs as root". /home/ is usually be a bind mount to a directory in /persist
It's actually a fair bit better than flatpak to be honest - nixos is pretty good about storage space given all the additional features it gives you. My current install with gnome and a decent amount of software has the nix store at only 14.5 GB - which is better than most flatpak installs that I've seen.
Hello. There are a few documentation errors in this video.
- At 1:25 the curl command should use a lowercase "-o" for its output argument, not an uppercase "-O" like:
curl -o /tmp/disko.nix
- At 3:46 your nix command copies the flake.nix it to the current working directory.. we need to move it into "mnt/etc/nixos" like:
mv flake.nix /mnt/etc/nixos
- At 5:10 the cp command should copy "/mnt/etc/nixos" to "/mnt/etc/persist", NOT "/etc/nixos" to "/etc/persist" like:
cp /mnt/etc/nixos /mnt/etc/persist
- At 7:03 on reboot, I had this error on boot "waiting for device /mnt-root/persist/system/var/lib/nixos to appear..." This happened because I copied /persist/nixos to /etc/nixos before reboot; to prevent this, delete any contents of "/etc/nixos" and then rebuild & reboot like:
sudo rm -r /etc/nixos/*
sudo nixos-rebuild boot --flake /persist/nixos#default
reboot
- At 7:27 you must add "inputs" to the argument for the configuration.nix function like:
{ config, lib, pkgs, inputs, ... }: {
imports = [
./hardware-configuration.nix
];
# ...
}
- At 7:47 on reboot, I got "[FAILED] Failed to start Home Manager environment for ", so I ran:
systemctl status home-manager-mboyea.service
which reported:
hm-activate-[]: mkdir: cannot create directory "/persist/home": Permission denied
The solution is to declare the /persist directories and their owners inside your nixos config.
To do so, add the following to configuration.nix:
systemd.tmpfiles.rules = {
"d /persist/home/ 1777 root root -" # /persist/home created, owned by root
"d /persist/home/ 0770 users -" # /persist/home/ created, owned by that user
}
Then, modify home.nix to target "/persist/home/":
{ pkgs, inputs, ... }: {
# ...
home.persistence."/persist/home/" = {
# ...
};
# ...
}
Make sure to replace with your username.
Now, we finally have a working declarative NixOS config!
@Vimjoyer, thank you for your work; your content on NixOS is enabling me to create my ideal Linux PC.
Best wishes to you all in the future!
Uh oh! I made an error in this post and now I cannot edit to fix it..
The 7:47 configuration.nix fix should use square brackets & have correct chmod permissions like:
systemd.tmpfiles.rules = [
"d /persist/home/ 0777 root root -" # create /persist/home owned by root
"d /persist/home/ 0700 users -" # /persist/home/ owned by that user
]
I have the same problem as you at the 7:03 point but your solution doesn't work for me. I followed the instructions verbatim. I get "mounting /mnt-root/persist/system/var/lib/nixos in /mnt-root/var/lib/nixos failed: No such file or directory". What am I missing?
@@20windfisch11 I got the same issue, and didn't manage to work my way around it sadly
@@20windfisch11 Same issue here :/
@@20windfisch11 Remove `/system` from `environment.persistence."/persist/system"` :3
I will keep forgetting about this video every day👍
All the views are from me
Disko is the piece I've been missing. Being able to declare my partitions in advance is just the thing I've been hoping to do
The video quality keeps getting better. Love it ❤
Wish I knew about your videos when I was setting up my heavily NixOS based Homelab. Impermanence took me a couple of weeks to learn and you explained it in 9 minutes lol.
The editing is getting great!
Though more complicated if you really want to tune it, I personally prefer ZFS over LVM/BTRFS - it's far more mature, and quite rigorously tested prior to stable release - and it allows you to do some things that (as far as I know) you can't with BTRFS - primarily Zvols (using a chunk of your ZFS pool as arbitrary block storage), but other things like actually usable RAID5 and the ability to use zfs send with NAS solutions like Truenas is great (although technically you could just create a Zvol formatted with btrfs and use that - I actually did that when migrating from BTRFS to ZFS root).
5:10 oops, should be /mint/persist not /persist!
🥲
@vimjoyer maybe included in the top of the description of the video itself
ha. this got me when following along in a VM. Set things up, went to make changes and then saw I was doing it again! :D
4:16, alternative solutions are to use tmpfs for root (only for people with lots of RAM!) Or just use zfs and rollback to a blank snapshot on boot :)
Great video. I've been using impermanence for some time, but instead of a btrfs subvolume I'm mounting the root partition on a 1GB tmpfs. It's a good option if you have some RAM to spare.
I'm not sure how much RAM you have but you might want to consider removing the tmpfs size option. Without it, the size will default to half your total RAM which isn't an issue as tmpfs only uses as much memory as it needs. If you have 16GB of RAM and tmpfs size is 8GB, it won't actually reserve 8GB of memory all the time, it'll dynamically resize with 8GB being the limit. Thought I'd share because I wasn't aware of this before and I limited my tmpfs to 2GB but ran into issues when doing large system upgrades because build files in /tmp can be 4GB+ in size.
@@JManch_ I didn´t know about that, thanks for the advice! Actually, my /tmp is mounted on a @tmp subvolume, and I configured it to be cleaned on every boot (boot.tmp.cleanOnBoot = true). So far, I've never had any problems with this 1GB limit on /.
This sounds like the perfect setup for my workstation, which has 128G RAM that I rarely use up anyway. The only thing I'm missing right now is setting up LUKS with LVM underneath to merge two NVMEs for the home directory.
Exactly what I needed to setup my new laptop ! ❤❤❤
For anyone experiencing issues with "waiting for device /mnt-root/persist/system/var/lib/nixos to appear..." etc. after first enabling impermanence, I found that I had to run "sudo mkdir /persist/system" manually before rebooting
Another great video ❤️
When following the tutorial at 7:45 the process crashes at trying to create /persist/home with a permission denied error. I think home-manager is run without root permissions and can't create the folder because of that. What did you do to prevent this?
Yes, you can give user their directory with
`sudo chown -R $(id -u):$(id -g) /persist/home`
@@vimjoyer Thank you. Is there a good way to do this from within the nixos config or do I have to create the directory myself every time when I install this config on a new system?
@@Mia-zb4zh Hi! I found a declarative way to solve this. The solution is to declare the /persist directories and their owners inside your nixos config.
To do so, add the following to configuration.nix:
systemd.tmpfiles.rules = {
"d /persist/home/ 1777 root root -" # /persist/home owned by root
"d /persist/home/ 0770 users -" # /persist/home/ owned by that user
}
Then, modify home.nix to target "/persist/home/":
{ pkgs, inputs, ... }: {
# ...
home.persistence."/persist/home/" = {
# ...
};
# ...
}
Make sure to replace with your username.
Hope this helps!
This video has inspired me to play around with my setup. Thanks
I do have a question if you have a moment. Is there any particular reason (for this setup) that you are using LVM/BTRFS and not just BTRFS directly?
I'm just trying to stay true to impermanence's GitHub README
@@vimjoyer gotcha. Now I have a new place to check :) Thanks again
could you probably do some more tutorials on features/options with btrfs and integrating with nix? like maybe using btrfs specific features for previous generations and so on?
One more small thing, could you maybe do a small guide on on getting an fhs distro like arch to be dual booted along side nixos with btrfs file system? (just incase if nixos decides to fail like it happened when linux-firmware was recently packaged incorrectly causing it to not boot on amd gpu or maybe if we need something very fhs specific like some firmware flash tools)
I haven't used any legacy distros in a while, so I'm not sure about the second one. Hovewer I will surely make more NixOS + btrfs / (other filesystems) videos in the future.
You may be able to use something like DistroBox, but for firmware flashing that might be more trouble than it's worth. I generally keep a medicat USB for those purposes.
Ever thought about doing some benchmarking to see how Nixos perform? There are almost no such benchmarks on the Internet.
Not really interested in that, maybe in the future
Not sure what you mean by "benchmarking NixOS". It's just Linux. What do you want to benchmark exactly?
Their kernels with other linux distribution kernels, how storage in nix store affects performance, how nix store works together with different file systems, many things you can benchmark. @@ruroruro
@@ruroruro RUclips deleted my comment. There are many you can benchmark, nix kеrnels, nix store under different file systems, high performance applications, latency in them.
I use a similar setup; although using zfs & zfs snapshot restore to nuke root. My uptime right now is like 2 months and I'm a bit concerned about restart lmao
Could you share your config? I'm having a hard time getting zfs + impermanence working.
@@xthebumpx yeah sure I can give you the GitHub but it's not public, do you have a GitHub username I can add to the repo?
What are the advantages of this? Would someone that uses NixOS as a stable daily driver benefit from this?
Your system won't get cluttered with old program cache / undeclared system state / old logs. Some garbage will usually accumulate in in .local/share, .cache, and other directories, and with this setup it will just get wiped.
@@vimjoyeroh I now also understand why people do that. At first deleting etc and var was looking just like a cool little useless thing to demonstrate how nix is unbrekable but yeahs could be useful to uncluttered the system.
Personally Nix is already awesome and reproductible I can easily just reinstall everything but it’s great to finally see how all those automation are done
@@vimjoyer that means when i login to some websites in browser it will get erased???
sounds like this is something suited for servers... not desktops... tooo crazy..
@@vaisakh_km you can can be picky about what should be persistant, thus you can keep browser statedata if you want to
@@vaisakh_km your browser cache is almost always stored in your home folder (which is usually a separate partition/bind mount) so that is incorrect.
Not related to this video (I'm just commenting here because this is your most recent video), but could you make a video on configuring nextcloud, jellyfin and lets encrypt SSL certificates without your server being exposed with nix/nix OS. It's quite a long process if you configure everything manually, and seems like it would be a logical use-case for nix OS.
We'll see. I never had such setup myself, but I can look into it
Very nice. I'm not good enough to figure out how to do it yet but I really want to see a setup like this that uses ZFS and something like ZFS boot menu in place of grub for booting into previous generations.
I'll consider
@@vimjoyer I was speaking in general rather than requesting that you make a video on it, that feels a little presumptuous, though I'd be very interested to know how it goes if you tinker with a setup like this. ZFS boot menu is it's own minimal linux install that uses kexec to boot into a system image on a ZFS dataset. A couple of the things that are appealing about this are you can have secure boot enabled with ZFS boot menu. Also on a ZFS system you can declaratively specify your policy for snapshotting you ZFS datasets with sanoid and your backup schedule to a remote zpool with syncoid. If using ZFS native encryption you can send raw snapshots and the remote doesn't need the encryption key to receive the snapshot. So you can do block level differential backups to a remote that never has the ability to decrypt your files and retains all of the data integrity guarantees of ZFS.
Hey, can you make a video about converting PKGBUILDs into flakes?
Also, have I already said that visual quality of your videos is amazing? Well, it is! 😄 How do you animate them? Do you use something programmatic, like Manim?
I got some strange yellow warnings after installation...
Great video as usual, could you also create a video around using this with home-manager as well?
There's a quick home-manager setup at 7:13 👍
@@vimjoyer Ahh so is there is at 7:40
So quick question, since this is not using tmpfs, then where are these things being stored at temporarily, is it being temporarily stored in ram?
No, it's stored on your drive and then deleted. You can also make a similar setup with tempfs.
What kind of things should be changed if you want to have LUKS encryption as well?
I don't do encryption, but this article with a similar setup does - mt-caret.github.io/blog/posts/2020-06-29-optin-state.html
@@vimjoyer huh! Do you not have a laptop? I thought people at this point always put encryption on atleast their home dir. For a desktop I can see people not bother, but with laptops I assumed it was common.
can you add impermanence during install? like using a nixos-install -flake .#test with all impermanence configs enabled
You need to format disks first
Can impermanence only be used with home manager as a nixos module? What about as a standalone?
only as a module
great video, btw can you make a video tutorial how to change from plasma5 to plasma6 in this distro ? keep make contents 👍
`services.xserver.desktopManager.plasma6.enable = true;` on unstable
@@vimjoyeralready did that but it says does not exist
@@nathanneisan5697 it's available in nixos-unstable. If you're using 23.11 then it won't be there
Yay
Good resources for nixos impermaence is searching "Delete Your Darlings" or "tmpfs as root".
/home/ is usually be a bind mount to a directory in /persist
Close the installer in the install process is just hilarious to me
Haha, yeah. You can modify calamares to fit your needs though
@@vimjoyer gotcha
btw, is any of your videos about non nix binaries, i enabled ld but just doesn't work
I don't really like nixos I'm personally an arch user but i like your videos so
Wouldn't this wear out the ssd/hdd faster though?
Yes, a bit faster
You better not speak about "bloating your drive" if you're using nix
It's more about having predictable system state, not debloating your drive
It's actually a fair bit better than flatpak to be honest - nixos is pretty good about storage space given all the additional features it gives you. My current install with gnome and a decent amount of software has the nix store at only 14.5 GB - which is better than most flatpak installs that I've seen.
I don’t understand why this would be desired.
It's cool to have a clean system
Hey Vimjoyer!
Please consider pinning my other comment, as I gave solutions for the documentation errors in this video.
Done, and thanks!
Promo'SM
?