Perfect NixOS | Impermanence Setup

แชร์
ฝัง

ความคิดเห็น • 89

  • @matthewboyea3860
    @matthewboyea3860 4 หลายเดือนก่อน +33

    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!

    • @matthewboyea3860
      @matthewboyea3860 4 หลายเดือนก่อน +6

      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
      ]

    • @20windfisch11
      @20windfisch11 17 วันที่ผ่านมา

      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?

  • @TheSast
    @TheSast 5 หลายเดือนก่อน +88

    I will keep forgetting about this video every day👍

  • @bigl9527
    @bigl9527 5 หลายเดือนก่อน +16

    The video quality keeps getting better. Love it ❤

  • @adrianscarlett
    @adrianscarlett 4 หลายเดือนก่อน +6

    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

  • @icyman1998
    @icyman1998 4 หลายเดือนก่อน +2

    The editing is getting great!

  • @josephlucas62
    @josephlucas62 5 หลายเดือนก่อน +1

    Exactly what I needed to setup my new laptop ! ❤❤❤

  • @Redyf
    @Redyf 5 หลายเดือนก่อน +2

    Another great video ❤️

  • @graemewiebe2815
    @graemewiebe2815 5 หลายเดือนก่อน +6

    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).

  • @zyansheep
    @zyansheep 5 หลายเดือนก่อน +4

    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 :)

  • @ggorg0
    @ggorg0 5 หลายเดือนก่อน +12

    5:10 oops, should be /mint/persist not /persist!

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน +2

      🥲

    • @thibaultmol
      @thibaultmol 5 หลายเดือนก่อน +2

      @vimjoyer maybe included in the top of the description of the video itself

    • @shifteleven
      @shifteleven 4 หลายเดือนก่อน

      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

  • @JonathanLucas-cr5nu
    @JonathanLucas-cr5nu 5 หลายเดือนก่อน +4

    It's so cool, and any video plan about overlays override? it's confusing.

  • @djonathandev
    @djonathandev 5 หลายเดือนก่อน +10

    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.

    • @JManch_
      @JManch_ 5 หลายเดือนก่อน +7

      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.

    • @djonathandev
      @djonathandev 5 หลายเดือนก่อน +2

      @@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 /.

    • @attilao
      @attilao 5 หลายเดือนก่อน

      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.

  • @Majiy00
    @Majiy00 5 หลายเดือนก่อน +1

    Great video as usual, could you also create a video around using this with home-manager as well?

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน

      There's a quick home-manager setup at 7:13 👍

    • @Majiy00
      @Majiy00 5 หลายเดือนก่อน

      ​@@vimjoyer Ahh so is there is at 7:40

  • @shifteleven
    @shifteleven 4 หลายเดือนก่อน +1

    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?

    • @vimjoyer
      @vimjoyer  4 หลายเดือนก่อน +1

      I'm just trying to stay true to impermanence's GitHub README

    • @shifteleven
      @shifteleven 4 หลายเดือนก่อน

      @@vimjoyer gotcha. Now I have a new place to check :) Thanks again

  • @RichardJActon
    @RichardJActon 5 หลายเดือนก่อน +1

    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
      @vimjoyer  5 หลายเดือนก่อน

      I'll consider

    • @RichardJActon
      @RichardJActon 5 หลายเดือนก่อน +1

      @@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.

  • @Ayyych
    @Ayyych หลายเดือนก่อน +1

    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

  • @drishalballaney6590
    @drishalballaney6590 5 หลายเดือนก่อน +2

    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)

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน +2

      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.

    • @graemewiebe2815
      @graemewiebe2815 5 หลายเดือนก่อน +1

      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.

  • @realmrcactus3215
    @realmrcactus3215 5 หลายเดือนก่อน +2

    I don't really like nixos I'm personally an arch user but i like your videos so

  • @Mia-zb4zh
    @Mia-zb4zh 5 หลายเดือนก่อน +3

    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
      @vimjoyer  5 หลายเดือนก่อน +1

      Yes, you can give user their directory with
      `sudo chown -R $(id -u):$(id -g) /persist/home`

    • @Mia-zb4zh
      @Mia-zb4zh 5 หลายเดือนก่อน

      @@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?

    • @matthewboyea3860
      @matthewboyea3860 4 หลายเดือนก่อน

      @@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!

  • @biggamer11
    @biggamer11 2 หลายเดือนก่อน +1

    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?

    • @vimjoyer
      @vimjoyer  2 หลายเดือนก่อน

      No, it's stored on your drive and then deleted. You can also make a similar setup with tempfs.

  • @nathanneisan5697
    @nathanneisan5697 4 หลายเดือนก่อน +1

    great video, btw can you make a video tutorial how to change from plasma5 to plasma6 in this distro ? keep make contents 👍

    • @vimjoyer
      @vimjoyer  4 หลายเดือนก่อน

      `services.xserver.desktopManager.plasma6.enable = true;` on unstable

    • @nathanneisan5697
      @nathanneisan5697 4 หลายเดือนก่อน

      @@vimjoyeralready did that but it says does not exist

    • @shifteleven
      @shifteleven 4 หลายเดือนก่อน

      @@nathanneisan5697 it's available in nixos-unstable. If you're using 23.11 then it won't be there

  • @b4mbus60
    @b4mbus60 5 หลายเดือนก่อน +7

    What are the advantages of this? Would someone that uses NixOS as a stable daily driver benefit from this?

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน +5

      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.

    • @gungun974
      @gungun974 5 หลายเดือนก่อน

      @@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

    • @vaisakhkm783
      @vaisakhkm783 5 หลายเดือนก่อน +1

      @@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..

    • @TheSast
      @TheSast 5 หลายเดือนก่อน

      @@vaisakhkm783 you can can be picky about what should be persistant, thus you can keep browser statedata if you want to

    • @caedis_
      @caedis_ 5 หลายเดือนก่อน +5

      @@vaisakhkm783 your browser cache is almost always stored in your home folder (which is usually a separate partition/bind mount) so that is incorrect.

  • @dv_xl
    @dv_xl 5 หลายเดือนก่อน +4

    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

    • @xthebumpx
      @xthebumpx หลายเดือนก่อน

      Could you share your config? I'm having a hard time getting zfs + impermanence working.

    • @dv_xl
      @dv_xl หลายเดือนก่อน

      @@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?

  • @slavakonyshev
    @slavakonyshev 5 หลายเดือนก่อน +3

    Ever thought about doing some benchmarking to see how Nixos perform? There are almost no such benchmarks on the Internet.

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน +2

      Not really interested in that, maybe in the future

    • @ruroruro
      @ruroruro 5 หลายเดือนก่อน +3

      Not sure what you mean by "benchmarking NixOS". It's just Linux. What do you want to benchmark exactly?

    • @slavakonyshev
      @slavakonyshev 5 หลายเดือนก่อน

      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

    • @slavakonyshev
      @slavakonyshev 5 หลายเดือนก่อน

      @@ruroruro TH-cam deleted my comment. There are many you can benchmark, nix kеrnels, nix store under different file systems, high performance applications, latency in them.

  • @caedis_
    @caedis_ 5 หลายเดือนก่อน +6

    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

  • @Godalming123
    @Godalming123 5 หลายเดือนก่อน +2

    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.

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน +2

      We'll see. I never had such setup myself, but I can look into it

  • @AshtonSnapp
    @AshtonSnapp 2 หลายเดือนก่อน +3

    I don’t understand why this would be desired.

    • @vimjoyer
      @vimjoyer  2 หลายเดือนก่อน +3

      It's cool to have a clean system

  • @xuhiko7573
    @xuhiko7573 หลายเดือนก่อน +1

    can you add impermanence during install? like using a nixos-install -flake .#test with all impermanence configs enabled

    • @vimjoyer
      @vimjoyer  หลายเดือนก่อน

      You need to format disks first

  • @thibaultmol
    @thibaultmol 5 หลายเดือนก่อน +1

    What kind of things should be changed if you want to have LUKS encryption as well?

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน

      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

    • @thibaultmol
      @thibaultmol 5 หลายเดือนก่อน

      @@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.

  • @TheMotorcycleBoy-pe2eg
    @TheMotorcycleBoy-pe2eg 29 วันที่ผ่านมา

    I got some strange yellow warnings after installation...

  • @GeorgeGzirishvili
    @GeorgeGzirishvili 5 หลายเดือนก่อน +3

    Hey, can you make a video about converting PKGBUILDs into flakes?

    • @GeorgeGzirishvili
      @GeorgeGzirishvili 5 หลายเดือนก่อน +3

      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?

  • @aleclowry7654
    @aleclowry7654 4 หลายเดือนก่อน

    Can impermanence only be used with home manager as a nixos module? What about as a standalone?

    • @vimjoyer
      @vimjoyer  4 หลายเดือนก่อน +2

      only as a module

  • @Ikxi
    @Ikxi 5 หลายเดือนก่อน +1

    Close the installer in the install process is just hilarious to me

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน

      Haha, yeah. You can modify calamares to fit your needs though

    • @Ikxi
      @Ikxi 5 หลายเดือนก่อน

      @@vimjoyer gotcha
      btw, is any of your videos about non nix binaries, i enabled ld but just doesn't work

  • @matthewboyea3860
    @matthewboyea3860 4 หลายเดือนก่อน +1

    Hey Vimjoyer!
    Please consider pinning my other comment, as I gave solutions for the documentation errors in this video.

    • @vimjoyer
      @vimjoyer  4 หลายเดือนก่อน

      Done, and thanks!

  • @Rundik
    @Rundik 5 หลายเดือนก่อน +2

    You better not speak about "bloating your drive" if you're using nix

    • @vimjoyer
      @vimjoyer  5 หลายเดือนก่อน +3

      It's more about having predictable system state, not debloating your drive

    • @graemewiebe2815
      @graemewiebe2815 5 หลายเดือนก่อน +2

      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.

  • @doriandefonce8243
    @doriandefonce8243 4 หลายเดือนก่อน +1

    Promo'SM

    • @vimjoyer
      @vimjoyer  4 หลายเดือนก่อน

      ?