Repository navigation
Description
This command would not only be very useful for users to switch to NixOS but also would get NixOps to support a large variety of different hosters. Also this would simplify the Hetzner bootstrapping process.
The implementation would look like this:
- Gather hardware, networking and maybe partition information.
- Evaluate configuration and build NixOS system.
- Inject a initrd+kernel somewhere in the current system (maybe search for a continuous region within the free disk space).
- Overwrite boot loader with pointers to the injected initrd+kernel.
- Sync
reboot -f- Erase disk and repartition (at least in the first implementation of
nixos-assimilate, because detecting available partitions and reusing them could become quite difficult). - Create filesystems and mount.
- Copy closures into the new filesystem layout.
pivot_rootinto the new system and bootup NixOS.
In order to properly (re)partition, we need to do the refactoring of nixpart to first of all not be based on kickstart syntax and also have a sane way to specify filesystem layouts.
nixpart is based on blivet, which works with partitioning information in a tree-like structure and also is able to detect existing filesystem layouts, so it's perfectly suited to work with Nix expressions.
That means we need to refactor nixpart to use Nix expressions to specify the filesystem layout and remove all kickstart-related stuff (kickstart is more than just a way to specify partitioning and has dependencies and complexity which we really don't need).
And of course, before we could do that, we need to come up with a sane layout for specifying partitions, possibly something that would blend in seamlessly with the fileSystems attribute set.
This possibly affects/fixes NixOS/nixops#168 and #1080.
Activity
offlinehacker commentedon Mar 31, 2014
Nice :)
On Mar 31, 2014 12:28 AM, "aszlig" [email protected] wrote:
shlevy commentedon Apr 5, 2014
+1. Would also be nice to work with pxe and livecd boots too. Do you have an idea of where others might be helpful here?
offlinehacker commentedon Apr 5, 2014
I would like to help here :)
On Apr 5, 2014 8:31 PM, "Shea Levy" [email protected] wrote:
aszlig commentedon Jun 28, 2014
Created a wiki at the nixpart repository, which details some basic design about the upcoming version 1.0 which is needed for
nixos-assimilate. I'm open for suggestions and/or help on that front (also need to specify the format of the device tree, but that's coming soon), so far there is only the partition remapper, please let me know what you think and/or add possible problems/obstacles to the draft:https://github.com/aszlig/nixpart/wiki/Partition-remapper-%28draft%29
lucabrunox commentedon Jun 28, 2014
Somebody, can't remember if mm_freak or whoelse, installed nixos simply in a subdirectory like /nixos. Then somehow install grub in some device (probably a file in the host file system), and add this device to be chainloaded from the main bootloader. In the hope that grub supports set root=(...)/nixos.
Finally modified initrd from configuration.nix to change root to /nixos.
This is a great thing that should be documented somewhere, or be part of nix-assimilate, in that it keeps your existing partitions and system intact, yet you are able to run nixos natively.
I'm sure a large number of people (like me) would instantly install it.
aszlig commentedon Jun 28, 2014
That's what I did on some systems as well, and if you have something like btrfs, you could simply change root subvolumes for switching distros. And that's what I had in mind if you want to keep your current partitioning layout. The block device remapper is only if you want to change the partitioning while retaining current data, so essentially we're doing exactly the same but just change the layout (might break the existing system however).
The main reason for the block device remapper is for supporting different dedicated server hosting providers for NixOps. Most of these hosters are preinstalling an image with a fixed filesystem layout, so it's a way to change that without the need to do manual intervention.
CMCDragonkai commentedon Aug 21, 2014
This is such a cool idea.
Somebody managed to do this for CoreOS if that helps.
https://github.com/ibuildthecloud/coreos-on-do
It manages to "assimilate" DO's VM into a CoreOS instance using kexec.
wmertens commentedon Aug 21, 2014
Ooh I didn't think of that use case, neat!
Digital Ocean is a very cheap provider so having NixOS on there would be
awesome. I wonder if the kexec is required, a simple reboot should work as
well?
I also took the multiple btrfs subvols approach, and I keep my old Ubuntu
mounted to run not-yet-nixified software in a chroot.
On Aug 21, 2014 7:45 AM, "Roger Qiu" [email protected] wrote:
CMCDragonkai commentedon Aug 21, 2014
I think the coreos solution does a couple reboots in order to make it work.
CMCDragonkai commentedon Aug 21, 2014
Does blivet work with ZFS? That's what I use. And it would be so cool if could assemble ZFS + LUKS.
aszlig commentedon Aug 22, 2014
@CMCDragonkai: Unfortunately, it doesn't support ZFS yet :-/
82 remaining items
mohe2015 commentedon Jan 15, 2022
https://nixos.wiki/wiki/NixOS_friendly_hosters
nixinator commentedon Jan 15, 2022
needs to be on nixos.org :-) for more visibility.
wmertens commentedon Jan 25, 2022
Woah that kexec tool (https://github.com/cleverca22/nix-tests/tree/master/kexec) is a good idea! Just run a binary and your system is suddenly a NixOS installer on a ramdisk.
nixinator commentedon Jan 28, 2022
MIND BLOWN
[-]nixos-assimilate - Turn currently running system into NixOS[/-][+]Feature request: nixos-assimilate: Turn currently running system into NixOS[/+]samueldr commentedon Apr 23, 2024
(I know it's not technically a feature request, but this is the closest phrasing I could think so the issue is better understood at a glance in the list of issues.)
AkechiShiro commentedon Apr 23, 2024
How is this different from NixOS lustrate ?
https://nixos.org/manual/nixos/stable/#sec-installing-from-other-distro
EDIT : Sorry this is mentioned in the beginning exactly what kind of feature it is and what it covers. It's a more broad use case of NixOS Lustrate I guess ?
irisjae commentedon Apr 23, 2024
I've been told that https://github.com/nix-community/nixos-anywhere, which uses kexec, can be preferred over nixos-infect. How does nixos-anywhere compare to lustrate?
aszlig commentedon Apr 24, 2024
The difference is mainly that it would repartition whilst keeping your data, but given that I haven't had time to continue working on this project, I'm now officially marking this as dead since there are other options and stuff such as disko for declarative partitioning.