How to break the nix os

I know the philosophy of nix them is much better than some other distros
But I wanted to know what are the fromas of being able to break the system
Not worth removing packages from the system

What do you mean by “break”?

Stop making it work,break the system

I suspect sudo rm -rf / would work. Beyond that, I don’t know what you’re trying to ask.

Recently my NixOS was unable to run because I tried a nixos-rebuild switch with my hard-disk full. Apparently, it broke something in such way that in the boot process the systemd tried to generate core-dumps. However, this is the first time I had this problem with nixos-rebuild in about 5 years with NixOS.

Just boot the system from a usb live NixOS and run nixos-install from it was enough to leave my system perfect again.

In general the good point of NixOS is that doing such upgrades or rebuilds are almost never breaking the system of previous builds and you can always rollback to them.

You couldn’t rollback at the bootloader?

1 Like

Don’t do nix.gc.automatic=true if you’re using nixos to hack your system even semi-regularly.
If your latest generation is broken and the automatic gc is triggered before you notice,then you will need a nixos iso to fix it

1 Like

I have automatic GC enabled and anyone in #nixos-chat on freenode can tell you I mess with weird stuff on NixOS all the time :stuck_out_tongue: Your advice really only applies if the hacking you’re talking about takes like a month and affects boot procedures.

I did mess the display manager procedure the day before the automatic gc

Not a fun time

1 Like

On the topic of garbage collection- I’ve found that min-free approach works best for me, it doesn’t collect periodically but only if my /nix/store partition is running out of space.

What is the min-free approach? I don’t see any option under nix.gc for that, or any flag for nix-collect-garbage.

I managed to lock myself out by deleting the file that was used by my user’s passwordFile. This file is impurely read during every activation (e.g. boot) to avoid storing sensitive information like password hash to Nix store but, obviously, this breaks system activation when deleted. Fortunately, I was able to move it back after I booted into a rescue console with boot.debug1mounts in kernel cmdline.

1 Like

In nix.extraOptions I add a string value '''min-free=4000000000''' so that after ever my nix-build, nix checks if the partition has less free space than this, and if so it collects garbage. There is also max-free. These are nix.conf options.

1 Like

It’s what I replaced nix.gc with

I wish there was a min-inode-free setting, because the issue I’ve run into on my VPS was running out of inodes due to garbage from nightly auto-updates while I still had plenty of disk space left.

1 Like

That shouldn’t be difficult. Nix uses the statvfs function to query free blocks on disk and this also reports free inodes.

1 Like