Perfect NixOS | Impermanence Setup

Поделиться
HTML-код
  • Опубликовано: 22 дек 2024

Комментарии •

  • @matthewboyea3860
    @matthewboyea3860 9 месяцев назад +47

    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 9 месяцев назад +8

      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 5 месяцев назад +1

      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?

    • @adriaanbrumsen4336
      @adriaanbrumsen4336 4 месяца назад

      @@20windfisch11 I got the same issue, and didn't manage to work my way around it sadly

    • @shivangjhalani1934
      @shivangjhalani1934 4 месяца назад

      @@20windfisch11 Same issue here :/

    • @hiibolt
      @hiibolt 2 месяца назад

      @@20windfisch11 Remove `/system` from `environment.persistence."/persist/system"` :3

  • @TheSast
    @TheSast 10 месяцев назад +92

    I will keep forgetting about this video every day👍

    • @spageen
      @spageen 25 дней назад +1

      All the views are from me

  • @adrianscarlett
    @adrianscarlett 8 месяцев назад +11

    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

  • @bigl9527
    @bigl9527 10 месяцев назад +17

    The video quality keeps getting better. Love it ❤

  • @mcculleytech
    @mcculleytech 2 месяца назад +1

    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.

  • @icyman1998
    @icyman1998 9 месяцев назад +4

    The editing is getting great!

  • @graemewiebe2815
    @graemewiebe2815 10 месяцев назад +8

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

  • @ggorg0
    @ggorg0 10 месяцев назад +15

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад +3

      🥲

    • @thibaultmol
      @thibaultmol 10 месяцев назад +2

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

    • @shifteleven
      @shifteleven 9 месяцев назад

      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

  • @zyansheep
    @zyansheep 10 месяцев назад +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 :)

  • @djonathandev
    @djonathandev 10 месяцев назад +11

    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_ 10 месяцев назад +8

      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 10 месяцев назад +3

      @@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 10 месяцев назад +1

      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.

  • @josephlucas62
    @josephlucas62 10 месяцев назад +1

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

  • @Ayyych
    @Ayyych 6 месяцев назад +2

    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

  • @Redyf
    @Redyf 10 месяцев назад +2

    Another great video ❤️

  • @Mia-zb4zh
    @Mia-zb4zh 10 месяцев назад +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  10 месяцев назад +1

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

    • @Mia-zb4zh
      @Mia-zb4zh 10 месяцев назад

      @@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 9 месяцев назад

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

  • @shifteleven
    @shifteleven 9 месяцев назад +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  9 месяцев назад +1

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

    • @shifteleven
      @shifteleven 9 месяцев назад

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

  • @drishalballaney
    @drishalballaney 10 месяцев назад +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  10 месяцев назад +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 10 месяцев назад +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.

  • @slavakonyshev
    @slavakonyshev 10 месяцев назад +3

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад +2

      Not really interested in that, maybe in the future

    • @ruroruro
      @ruroruro 10 месяцев назад +4

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

    • @slavakonyshev
      @slavakonyshev 10 месяцев назад

      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 10 месяцев назад

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

  • @dv_xl
    @dv_xl 10 месяцев назад +5

    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 6 месяцев назад +1

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

    • @dv_xl
      @dv_xl 6 месяцев назад

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

  • @b4mbus60
    @b4mbus60 10 месяцев назад +7

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад +7

      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 10 месяцев назад

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

    • @vaisakh_km
      @vaisakh_km 10 месяцев назад +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 10 месяцев назад

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

    • @caedis_
      @caedis_ 10 месяцев назад +7

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

  • @Godalming123
    @Godalming123 10 месяцев назад +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  10 месяцев назад +2

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

  • @RichardJActon
    @RichardJActon 10 месяцев назад +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  10 месяцев назад

      I'll consider

    • @RichardJActon
      @RichardJActon 10 месяцев назад +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.

  • @GeorgeGzirishvili
    @GeorgeGzirishvili 10 месяцев назад +3

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

    • @GeorgeGzirishvili
      @GeorgeGzirishvili 10 месяцев назад +4

      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?

  • @TheMotorcycleBoy-pe2eg
    @TheMotorcycleBoy-pe2eg 5 месяцев назад

    I got some strange yellow warnings after installation...

  • @Majiy00
    @Majiy00 10 месяцев назад +1

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад

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

    • @Majiy00
      @Majiy00 10 месяцев назад

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

  • @biggamer11
    @biggamer11 6 месяцев назад +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  6 месяцев назад +1

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

  • @thibaultmol
    @thibaultmol 10 месяцев назад +1

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад +1

      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 10 месяцев назад

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

  • @xuhiko7573
    @xuhiko7573 6 месяцев назад +1

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

    • @vimjoyer
      @vimjoyer  6 месяцев назад +1

      You need to format disks first

  • @aleclowry7654
    @aleclowry7654 8 месяцев назад +1

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

    • @vimjoyer
      @vimjoyer  8 месяцев назад +3

      only as a module

  • @nathanneisan5697
    @nathanneisan5697 9 месяцев назад +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  9 месяцев назад

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

    • @nathanneisan5697
      @nathanneisan5697 9 месяцев назад

      @@vimjoyeralready did that but it says does not exist

    • @shifteleven
      @shifteleven 9 месяцев назад

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

  • @caedis_
    @caedis_ 10 месяцев назад +7

    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

  • @Ikxi
    @Ikxi 10 месяцев назад +2

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад +2

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

    • @Ikxi
      @Ikxi 10 месяцев назад

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

  • @realmrcactus3215
    @realmrcactus3215 10 месяцев назад +2

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

  • @whoman0385
    @whoman0385 3 месяца назад +1

    Wouldn't this wear out the ssd/hdd faster though?

    • @vimjoyer
      @vimjoyer  3 месяца назад

      Yes, a bit faster

  • @Rundik
    @Rundik 10 месяцев назад +3

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

    • @vimjoyer
      @vimjoyer  10 месяцев назад +6

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

    • @graemewiebe2815
      @graemewiebe2815 10 месяцев назад +3

      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.

  • @AshtonSnapp
    @AshtonSnapp 7 месяцев назад +3

    I don’t understand why this would be desired.

    • @vimjoyer
      @vimjoyer  7 месяцев назад +5

      It's cool to have a clean system

  • @matthewboyea3860
    @matthewboyea3860 9 месяцев назад +2

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

    • @vimjoyer
      @vimjoyer  9 месяцев назад +2

      Done, and thanks!

  • @doriandefonce8243
    @doriandefonce8243 9 месяцев назад +1

    Promo'SM