Perfect NixOS | Impermanence Setup

Поділитися
Вставка
  • Опубліковано 27 тра 2024
  • Discord server: / discord
    Donations: ko-fi.com/vimjoyer
    Code from the video: github.com/vimjoyer/impermane...
  • Наука та технологія

КОМЕНТАРІ • 83

  • @matthewboyea3860
    @matthewboyea3860 2 місяці тому +16

    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 2 місяці тому +2

      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
      ]

  • @TheSast
    @TheSast 3 місяці тому +80

    I will keep forgetting about this video every day👍

  • @adrianscarlett
    @adrianscarlett Місяць тому +5

    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

  • @butterfingers8842
    @butterfingers8842 3 місяці тому +19

    i was just reading about this in "Erase Your Darlings" a few days ago

  • @bigl9527
    @bigl9527 3 місяці тому +14

    The video quality keeps getting better. Love it ❤

  • @graemewiebe2815
    @graemewiebe2815 3 місяці тому +5

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

  • @icyman1998
    @icyman1998 2 місяці тому +1

    The editing is getting great!

  • @ggorg0
    @ggorg0 3 місяці тому +13

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

    • @vimjoyer
      @vimjoyer  3 місяці тому +2

      🥲

    • @thibaultmol
      @thibaultmol 3 місяці тому +2

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

    • @shifteleven
      @shifteleven 2 місяці тому

      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

  • @josephlucas62
    @josephlucas62 3 місяці тому +1

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

  • @zyansheep
    @zyansheep 3 місяці тому +3

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

  • @JonathanLucas-cr5nu
    @JonathanLucas-cr5nu 3 місяці тому +3

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

  • @Redyf
    @Redyf 3 місяці тому +2

    Another great video ❤️

  • @djonathandev
    @djonathandev 3 місяці тому +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_ 3 місяці тому +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 3 місяці тому +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 3 місяці тому

      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.

  • @shifteleven
    @shifteleven 2 місяці тому +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  2 місяці тому +1

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

    • @shifteleven
      @shifteleven 2 місяці тому

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

  • @dv_xl
    @dv_xl 3 місяці тому +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

  • @Majiy00
    @Majiy00 3 місяці тому +1

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

    • @vimjoyer
      @vimjoyer  3 місяці тому

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

    • @Majiy00
      @Majiy00 3 місяці тому

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

  • @RichardJActon
    @RichardJActon 3 місяці тому +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  3 місяці тому

      I'll consider

    • @RichardJActon
      @RichardJActon 3 місяці тому +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.

  • @biggamer11
    @biggamer11 11 годин тому +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  9 годин тому

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

  • @drishalballaney6590
    @drishalballaney6590 3 місяці тому +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  3 місяці тому +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 3 місяці тому +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.

  • @Mia-zb4zh
    @Mia-zb4zh 3 місяці тому +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  3 місяці тому +1

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

    • @Mia-zb4zh
      @Mia-zb4zh 3 місяці тому

      @@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 2 місяці тому

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

  • @slavakonyshev
    @slavakonyshev 3 місяці тому +3

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

    • @vimjoyer
      @vimjoyer  3 місяці тому +2

      Not really interested in that, maybe in the future

    • @ruroruro
      @ruroruro 3 місяці тому +2

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

    • @slavakonyshev
      @slavakonyshev 3 місяці тому

      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 3 місяці тому

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

  • @GeorgeGzirishvili
    @GeorgeGzirishvili 3 місяці тому +3

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

    • @GeorgeGzirishvili
      @GeorgeGzirishvili 3 місяці тому +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?

  • @b4mbus60
    @b4mbus60 3 місяці тому +7

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

    • @vimjoyer
      @vimjoyer  3 місяці тому +4

      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 3 місяці тому

      @@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 3 місяці тому +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 3 місяці тому

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

    • @caedis_
      @caedis_ 3 місяці тому +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.

  • @aleclowry7654
    @aleclowry7654 Місяць тому

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

    • @vimjoyer
      @vimjoyer  Місяць тому +2

      only as a module

  • @thibaultmol
    @thibaultmol 3 місяці тому +1

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

    • @vimjoyer
      @vimjoyer  3 місяці тому

      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 3 місяці тому

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

  • @Godalming123
    @Godalming123 3 місяці тому +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  3 місяці тому +2

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

  • @nathanneisan5697
    @nathanneisan5697 2 місяці тому +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  2 місяці тому

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

    • @nathanneisan5697
      @nathanneisan5697 2 місяці тому

      @@vimjoyeralready did that but it says does not exist

    • @shifteleven
      @shifteleven 2 місяці тому

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

  • @realmrcactus3215
    @realmrcactus3215 3 місяці тому +2

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

  • @AshtonSnapp
    @AshtonSnapp День тому +1

    I don’t understand why this would be desired.

    • @vimjoyer
      @vimjoyer  21 годину тому

      It's cool to have a clean system

  • @Ikxi
    @Ikxi 3 місяці тому +1

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

    • @vimjoyer
      @vimjoyer  3 місяці тому

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

    • @Ikxi
      @Ikxi 3 місяці тому

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

  • @matthewboyea3860
    @matthewboyea3860 2 місяці тому +1

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

    • @vimjoyer
      @vimjoyer  2 місяці тому

      Done, and thanks!

  • @Rundik
    @Rundik 3 місяці тому +2

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

    • @vimjoyer
      @vimjoyer  3 місяці тому +3

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

    • @graemewiebe2815
      @graemewiebe2815 3 місяці тому +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 2 місяці тому +1

    Promo'SM

  • @caedis_
    @caedis_ 3 місяці тому +5

    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