Skip to content

Feature request: nixos-assimilate: Turn currently running system into NixOS #2079

Closed

Description

@aszlig

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_root into 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

  1. offlinehacker commented on Mar 31, 2014

    @offlinehacker
    Contributor

    Nice :)
    On Mar 31, 2014 12:28 AM, "aszlig" [email protected] wrote:

    This command would not only be very useful for users to switch to NixOS
    but also would get NixOps https://github.com/NixOS/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_root into the new system and bootup NixOS.

    In order to properly (re)partition, we need to do the refactoring of
    nixpart https://github.com/aszlig/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 https://fedoraproject.org/wiki/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#168https://github.com/NixOS/nixops/issues/168and
    #1080 #1080.

    Reply to this email directly or view it on GitHubhttps://github.com//issues/2079
    .

  2. shlevy commented on Apr 5, 2014

    @shlevy
    Member

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

  3. offlinehacker commented on Apr 5, 2014

    @offlinehacker
    Contributor

    I would like to help here :)
    On Apr 5, 2014 8:31 PM, "Shea Levy" [email protected] wrote:

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

    Reply to this email directly or view it on GitHubhttps://github.com//issues/2079#issuecomment-39646760
    .

  4. added this to the milestone on Apr 21, 2014
  5. aszlig commented on Jun 28, 2014

    @aszlig
    MemberAuthor

    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

  6. lucabrunox commented on Jun 28, 2014

    @lucabrunox
    Contributor

    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.

  7. aszlig commented on Jun 28, 2014

    @aszlig
    MemberAuthor

    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.

  8. CMCDragonkai commented on Aug 21, 2014

    @CMCDragonkai
    Member

    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.

  9. wmertens commented on Aug 21, 2014

    @wmertens
    Contributor

    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:

    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.

    —
    Reply to this email directly or view it on GitHub
    #2079 (comment).

  10. CMCDragonkai commented on Aug 21, 2014

    @CMCDragonkai
    Member

    I think the coreos solution does a couple reboots in order to make it work.

  11. CMCDragonkai commented on Aug 21, 2014

    @CMCDragonkai
    Member

    Does blivet work with ZFS? That's what I use. And it would be so cool if could assemble ZFS + LUKS.

  12. aszlig commented on Aug 22, 2014

    @aszlig
    MemberAuthor

    @CMCDragonkai: Unfortunately, it doesn't support ZFS yet :-/

  13. 82 remaining items

  14. mohe2015 commented on Jan 15, 2022

    @mohe2015
    Contributor
  15. nixinator commented on Jan 15, 2022

    @nixinator
    Member

    needs to be on nixos.org :-) for more visibility.

  16. wmertens commented on Jan 25, 2022

    @wmertens
    Contributor

    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.

  17. nixinator commented on Jan 28, 2022

    @nixinator
    Member

    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.

    MIND BLOWN

  18. added
    2.status: stale
    on Jul 30, 2022
  19. changed the title [-]nixos-assimilate - Turn currently running system into NixOS[/-] [+]Feature request: nixos-assimilate: Turn currently running system into NixOS[/+] on Apr 23, 2024
  20. removed
    2.status: stale
    on Apr 23, 2024
  21. added
    2.status: stale
    on Apr 23, 2024
  22. samueldr commented on Apr 23, 2024

    @samueldr
    Member

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

  23. removed
    2.status: stale
    on Apr 23, 2024
  24. added
    2.status: stale
    on Apr 23, 2024
  25. AkechiShiro commented on Apr 23, 2024

    @AkechiShiro
    Contributor

    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 ?

  26. irisjae commented on Apr 23, 2024

    @irisjae

    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?

  27. aszlig commented on Apr 24, 2024

    @aszlig
    MemberAuthor

    How is this different from NixOS lustrate ?

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

0.kind: enhancement2.status: stale6.topic: nixos9.needs: reporter feedback

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions