How to rebuild the configuration of a NixOS installation from Live CD?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I installed NixOS 18.03 from Ubuntu on another partition following the NixOS manual's "2.4. Installing from another Linux distribution" section. Everything went fine, but I did a couple idiotic things [?], namely:



  • Forgot to add the extra GRUB boot loader entry for the Ubuntu installation before nixos-install. Added it as an afterthought after install, and did a reboot (of course, no Ubuntu entry)


  • Did not enable any networking in configuration.nix, and ended up with no network configuration commands after reboot to connect to wifi. The catch 22 is that nixos-rebuild switch requires a network connection, so I couldn't finalize any changes.


So my thinking was that I can boot from a NixOS Live CD (17.03),connect to our wifi and somehow rebuild the config of the installation.



It is more than possible that I am missing something essential, have incorrect assumptions above etc; fairly new at nix and NixOS.




EDIT: I forgot to include how my partitions are set up and what I tried before successfully installing NixOS.



Partitions (mountpoints from Ubuntu):



sda
├─sda1 ntfs Recovery # some Win7 artifact
├─sda2 vfat /boot/efi
├─sda3 vfat NIXBOOT # boot partition (esp, boot)
├─sda4 ext4 onyx # NixOS data
├─sda5 swap # Ubuntu swap
│ └─cryptswap1 swap [SWAP]
├─sda6 ext4 # (Arch install)
├─sda7 ext4 / # Ubuntu install
├─sda8 swap nixswap
└─sda9 ext4 home


I didn't want to mess up the Ubuntu boot partition, so I created another one (/dev/sda3). My plan was to later include a menu entry in Ubuntu's GRUB for NixOS, but for now, install, reboot and test booting NixOS from GRUB console (set root=..., linux ..., initrd ..., boot)



sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt --no-bootloader


After reboot, I couldn't see anything on the NixOS boot partition. Went back to Ubunut, installed without --no-bootloader, remembered to add an entry for Ubuntu and reboot. (It was only after this that I realized that systemd-boot and GRUB are two completely different things...)




UPDATE: I was able to get back to Ubuntu by selecting the Ubuntu boot partition as an alternative boot device in BIOS, and the usual GRUB menu came up. I may just redo the install with the right config.







share|improve this question

















  • 1




    Use chroot to edit the configuration and rebuild. wiki.archlinux.org/index.php/Change_root#Using_chroot
    – Mioriin
    May 28 at 15:32










  • In the end it was easier to just re-install NixOS, and the outdated NixOS chroot articles seemed intimidating, but I just realized that nixos-enter does just that. (It is also invoked by nixos-install when installing the boot loader.)
    – toraritte
    May 29 at 19:25















up vote
1
down vote

favorite












I installed NixOS 18.03 from Ubuntu on another partition following the NixOS manual's "2.4. Installing from another Linux distribution" section. Everything went fine, but I did a couple idiotic things [?], namely:



  • Forgot to add the extra GRUB boot loader entry for the Ubuntu installation before nixos-install. Added it as an afterthought after install, and did a reboot (of course, no Ubuntu entry)


  • Did not enable any networking in configuration.nix, and ended up with no network configuration commands after reboot to connect to wifi. The catch 22 is that nixos-rebuild switch requires a network connection, so I couldn't finalize any changes.


So my thinking was that I can boot from a NixOS Live CD (17.03),connect to our wifi and somehow rebuild the config of the installation.



It is more than possible that I am missing something essential, have incorrect assumptions above etc; fairly new at nix and NixOS.




EDIT: I forgot to include how my partitions are set up and what I tried before successfully installing NixOS.



Partitions (mountpoints from Ubuntu):



sda
├─sda1 ntfs Recovery # some Win7 artifact
├─sda2 vfat /boot/efi
├─sda3 vfat NIXBOOT # boot partition (esp, boot)
├─sda4 ext4 onyx # NixOS data
├─sda5 swap # Ubuntu swap
│ └─cryptswap1 swap [SWAP]
├─sda6 ext4 # (Arch install)
├─sda7 ext4 / # Ubuntu install
├─sda8 swap nixswap
└─sda9 ext4 home


I didn't want to mess up the Ubuntu boot partition, so I created another one (/dev/sda3). My plan was to later include a menu entry in Ubuntu's GRUB for NixOS, but for now, install, reboot and test booting NixOS from GRUB console (set root=..., linux ..., initrd ..., boot)



sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt --no-bootloader


After reboot, I couldn't see anything on the NixOS boot partition. Went back to Ubunut, installed without --no-bootloader, remembered to add an entry for Ubuntu and reboot. (It was only after this that I realized that systemd-boot and GRUB are two completely different things...)




UPDATE: I was able to get back to Ubuntu by selecting the Ubuntu boot partition as an alternative boot device in BIOS, and the usual GRUB menu came up. I may just redo the install with the right config.







share|improve this question

















  • 1




    Use chroot to edit the configuration and rebuild. wiki.archlinux.org/index.php/Change_root#Using_chroot
    – Mioriin
    May 28 at 15:32










  • In the end it was easier to just re-install NixOS, and the outdated NixOS chroot articles seemed intimidating, but I just realized that nixos-enter does just that. (It is also invoked by nixos-install when installing the boot loader.)
    – toraritte
    May 29 at 19:25













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I installed NixOS 18.03 from Ubuntu on another partition following the NixOS manual's "2.4. Installing from another Linux distribution" section. Everything went fine, but I did a couple idiotic things [?], namely:



  • Forgot to add the extra GRUB boot loader entry for the Ubuntu installation before nixos-install. Added it as an afterthought after install, and did a reboot (of course, no Ubuntu entry)


  • Did not enable any networking in configuration.nix, and ended up with no network configuration commands after reboot to connect to wifi. The catch 22 is that nixos-rebuild switch requires a network connection, so I couldn't finalize any changes.


So my thinking was that I can boot from a NixOS Live CD (17.03),connect to our wifi and somehow rebuild the config of the installation.



It is more than possible that I am missing something essential, have incorrect assumptions above etc; fairly new at nix and NixOS.




EDIT: I forgot to include how my partitions are set up and what I tried before successfully installing NixOS.



Partitions (mountpoints from Ubuntu):



sda
├─sda1 ntfs Recovery # some Win7 artifact
├─sda2 vfat /boot/efi
├─sda3 vfat NIXBOOT # boot partition (esp, boot)
├─sda4 ext4 onyx # NixOS data
├─sda5 swap # Ubuntu swap
│ └─cryptswap1 swap [SWAP]
├─sda6 ext4 # (Arch install)
├─sda7 ext4 / # Ubuntu install
├─sda8 swap nixswap
└─sda9 ext4 home


I didn't want to mess up the Ubuntu boot partition, so I created another one (/dev/sda3). My plan was to later include a menu entry in Ubuntu's GRUB for NixOS, but for now, install, reboot and test booting NixOS from GRUB console (set root=..., linux ..., initrd ..., boot)



sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt --no-bootloader


After reboot, I couldn't see anything on the NixOS boot partition. Went back to Ubunut, installed without --no-bootloader, remembered to add an entry for Ubuntu and reboot. (It was only after this that I realized that systemd-boot and GRUB are two completely different things...)




UPDATE: I was able to get back to Ubuntu by selecting the Ubuntu boot partition as an alternative boot device in BIOS, and the usual GRUB menu came up. I may just redo the install with the right config.







share|improve this question













I installed NixOS 18.03 from Ubuntu on another partition following the NixOS manual's "2.4. Installing from another Linux distribution" section. Everything went fine, but I did a couple idiotic things [?], namely:



  • Forgot to add the extra GRUB boot loader entry for the Ubuntu installation before nixos-install. Added it as an afterthought after install, and did a reboot (of course, no Ubuntu entry)


  • Did not enable any networking in configuration.nix, and ended up with no network configuration commands after reboot to connect to wifi. The catch 22 is that nixos-rebuild switch requires a network connection, so I couldn't finalize any changes.


So my thinking was that I can boot from a NixOS Live CD (17.03),connect to our wifi and somehow rebuild the config of the installation.



It is more than possible that I am missing something essential, have incorrect assumptions above etc; fairly new at nix and NixOS.




EDIT: I forgot to include how my partitions are set up and what I tried before successfully installing NixOS.



Partitions (mountpoints from Ubuntu):



sda
├─sda1 ntfs Recovery # some Win7 artifact
├─sda2 vfat /boot/efi
├─sda3 vfat NIXBOOT # boot partition (esp, boot)
├─sda4 ext4 onyx # NixOS data
├─sda5 swap # Ubuntu swap
│ └─cryptswap1 swap [SWAP]
├─sda6 ext4 # (Arch install)
├─sda7 ext4 / # Ubuntu install
├─sda8 swap nixswap
└─sda9 ext4 home


I didn't want to mess up the Ubuntu boot partition, so I created another one (/dev/sda3). My plan was to later include a menu entry in Ubuntu's GRUB for NixOS, but for now, install, reboot and test booting NixOS from GRUB console (set root=..., linux ..., initrd ..., boot)



sudo PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --root /mnt --no-bootloader


After reboot, I couldn't see anything on the NixOS boot partition. Went back to Ubunut, installed without --no-bootloader, remembered to add an entry for Ubuntu and reboot. (It was only after this that I realized that systemd-boot and GRUB are two completely different things...)




UPDATE: I was able to get back to Ubuntu by selecting the Ubuntu boot partition as an alternative boot device in BIOS, and the usual GRUB menu came up. I may just redo the install with the right config.









share|improve this question












share|improve this question




share|improve this question








edited May 29 at 4:12
























asked May 28 at 15:22









toraritte

1639




1639







  • 1




    Use chroot to edit the configuration and rebuild. wiki.archlinux.org/index.php/Change_root#Using_chroot
    – Mioriin
    May 28 at 15:32










  • In the end it was easier to just re-install NixOS, and the outdated NixOS chroot articles seemed intimidating, but I just realized that nixos-enter does just that. (It is also invoked by nixos-install when installing the boot loader.)
    – toraritte
    May 29 at 19:25













  • 1




    Use chroot to edit the configuration and rebuild. wiki.archlinux.org/index.php/Change_root#Using_chroot
    – Mioriin
    May 28 at 15:32










  • In the end it was easier to just re-install NixOS, and the outdated NixOS chroot articles seemed intimidating, but I just realized that nixos-enter does just that. (It is also invoked by nixos-install when installing the boot loader.)
    – toraritte
    May 29 at 19:25








1




1




Use chroot to edit the configuration and rebuild. wiki.archlinux.org/index.php/Change_root#Using_chroot
– Mioriin
May 28 at 15:32




Use chroot to edit the configuration and rebuild. wiki.archlinux.org/index.php/Change_root#Using_chroot
– Mioriin
May 28 at 15:32












In the end it was easier to just re-install NixOS, and the outdated NixOS chroot articles seemed intimidating, but I just realized that nixos-enter does just that. (It is also invoked by nixos-install when installing the boot loader.)
– toraritte
May 29 at 19:25





In the end it was easier to just re-install NixOS, and the outdated NixOS chroot articles seemed intimidating, but I just realized that nixos-enter does just that. (It is also invoked by nixos-install when installing the boot loader.)
– toraritte
May 29 at 19:25











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










The simplest way to go is to install from the LiveCD.



nixos-generate-config will regenerate the hardware config, but if it finds configuration.nix already exists it will leave it alone. And nixos-install is designed such that it can be safely executed as many times as needed.



This means you can follow the main installation guide using the filesystem (and configuration) you already created for NixOS and just continue where you left off.



Some things to be mindful of:



  • NixOS will install systemd-boot by default on EFI systems. So you'll end up with a new EFI executable along side the ones you already have.


  • nixos-install will also attempt to set systemd-boot as the default boot manager. I believe you can disable this by setting boot.loader.efi.canTouchEfiVariables to false in configuration.nix

  • I recommend installing NixOS with a basic config; For example, setup networking, users, and install a text editor but not much else. The reason is that the LiveCD uses a Nix store which is held in RAM. Your system will be first installed to this RAM-backed Nix store and then copied to disk. Once installed and bootable you can safely proceed with the rest of the configuration.





share|improve this answer





















  • Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
    – toraritte
    May 29 at 2:53










  • I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
    – toraritte
    May 29 at 5:41







  • 1




    Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
    – Emmanuel Rosa
    May 29 at 17:07


















up vote
0
down vote













Adding this answer for completeness sake: in theory, @Mioriin's suggestion above of chrooting would be the correct answer, that could be achieved by the command nixos-enter.



From Ubuntu, with the NixOS partitions mounted to /mnt:



$ sudo $(which nixos-enter)
...
[root@nixos:/]# nixos-rebuild switch


In practice, this did not work, because networking wouldn't work (probably because my configuration.nix was missing the right setup in the first place), and got a bunch of error messages:



warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:13
System has not been booted with systemd as init system (PID 1). Can't operate.
building Nix...
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
warning: unable to download 'https://cache.nixos.org/nix-cache-info': Couldn't resolve host name (6); retrying in 293 ms
^Cwarning: download of 'https://cache.nixos.org/nix-cache-info' was interrupted
don't know how to build these paths:
/nix/store/z6avpvg24f6d1br2sr6qlphsq3h4d91v-nix-2.0.2
error: interrupted by the user
warning: don't know how to get latest Nix



In the end, @Emmanuel Rosa's answer is right one, especially because (as he points it out) nixos-install can be safely executed multiple times.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446501%2fhow-to-rebuild-the-configuration-of-a-nixos-installation-from-live-cd%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    The simplest way to go is to install from the LiveCD.



    nixos-generate-config will regenerate the hardware config, but if it finds configuration.nix already exists it will leave it alone. And nixos-install is designed such that it can be safely executed as many times as needed.



    This means you can follow the main installation guide using the filesystem (and configuration) you already created for NixOS and just continue where you left off.



    Some things to be mindful of:



    • NixOS will install systemd-boot by default on EFI systems. So you'll end up with a new EFI executable along side the ones you already have.


    • nixos-install will also attempt to set systemd-boot as the default boot manager. I believe you can disable this by setting boot.loader.efi.canTouchEfiVariables to false in configuration.nix

    • I recommend installing NixOS with a basic config; For example, setup networking, users, and install a text editor but not much else. The reason is that the LiveCD uses a Nix store which is held in RAM. Your system will be first installed to this RAM-backed Nix store and then copied to disk. Once installed and bootable you can safely proceed with the rest of the configuration.





    share|improve this answer





















    • Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
      – toraritte
      May 29 at 2:53










    • I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
      – toraritte
      May 29 at 5:41







    • 1




      Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
      – Emmanuel Rosa
      May 29 at 17:07















    up vote
    1
    down vote



    accepted










    The simplest way to go is to install from the LiveCD.



    nixos-generate-config will regenerate the hardware config, but if it finds configuration.nix already exists it will leave it alone. And nixos-install is designed such that it can be safely executed as many times as needed.



    This means you can follow the main installation guide using the filesystem (and configuration) you already created for NixOS and just continue where you left off.



    Some things to be mindful of:



    • NixOS will install systemd-boot by default on EFI systems. So you'll end up with a new EFI executable along side the ones you already have.


    • nixos-install will also attempt to set systemd-boot as the default boot manager. I believe you can disable this by setting boot.loader.efi.canTouchEfiVariables to false in configuration.nix

    • I recommend installing NixOS with a basic config; For example, setup networking, users, and install a text editor but not much else. The reason is that the LiveCD uses a Nix store which is held in RAM. Your system will be first installed to this RAM-backed Nix store and then copied to disk. Once installed and bootable you can safely proceed with the rest of the configuration.





    share|improve this answer





















    • Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
      – toraritte
      May 29 at 2:53










    • I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
      – toraritte
      May 29 at 5:41







    • 1




      Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
      – Emmanuel Rosa
      May 29 at 17:07













    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    The simplest way to go is to install from the LiveCD.



    nixos-generate-config will regenerate the hardware config, but if it finds configuration.nix already exists it will leave it alone. And nixos-install is designed such that it can be safely executed as many times as needed.



    This means you can follow the main installation guide using the filesystem (and configuration) you already created for NixOS and just continue where you left off.



    Some things to be mindful of:



    • NixOS will install systemd-boot by default on EFI systems. So you'll end up with a new EFI executable along side the ones you already have.


    • nixos-install will also attempt to set systemd-boot as the default boot manager. I believe you can disable this by setting boot.loader.efi.canTouchEfiVariables to false in configuration.nix

    • I recommend installing NixOS with a basic config; For example, setup networking, users, and install a text editor but not much else. The reason is that the LiveCD uses a Nix store which is held in RAM. Your system will be first installed to this RAM-backed Nix store and then copied to disk. Once installed and bootable you can safely proceed with the rest of the configuration.





    share|improve this answer













    The simplest way to go is to install from the LiveCD.



    nixos-generate-config will regenerate the hardware config, but if it finds configuration.nix already exists it will leave it alone. And nixos-install is designed such that it can be safely executed as many times as needed.



    This means you can follow the main installation guide using the filesystem (and configuration) you already created for NixOS and just continue where you left off.



    Some things to be mindful of:



    • NixOS will install systemd-boot by default on EFI systems. So you'll end up with a new EFI executable along side the ones you already have.


    • nixos-install will also attempt to set systemd-boot as the default boot manager. I believe you can disable this by setting boot.loader.efi.canTouchEfiVariables to false in configuration.nix

    • I recommend installing NixOS with a basic config; For example, setup networking, users, and install a text editor but not much else. The reason is that the LiveCD uses a Nix store which is held in RAM. Your system will be first installed to this RAM-backed Nix store and then copied to disk. Once installed and bootable you can safely proceed with the rest of the configuration.






    share|improve this answer













    share|improve this answer



    share|improve this answer











    answered May 29 at 2:29









    Emmanuel Rosa

    2,1801410




    2,1801410











    • Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
      – toraritte
      May 29 at 2:53










    • I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
      – toraritte
      May 29 at 5:41







    • 1




      Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
      – Emmanuel Rosa
      May 29 at 17:07

















    • Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
      – toraritte
      May 29 at 2:53










    • I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
      – toraritte
      May 29 at 5:41







    • 1




      Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
      – Emmanuel Rosa
      May 29 at 17:07
















    Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
    – toraritte
    May 29 at 2:53




    Thanks for the great answer! A quick question (and I can ask this in a separate one if you like): based on your first tip, I could have just mounted to the existing boot partition (i.e., /dev/sda2) and nixos-install would only have added another EFI executable, correct? And if boot.loader.efi.canTouchEfiVariables had been set to false, I could've just used Ubuntu's GRUB and have an extra entry set up for NixOS?
    – toraritte
    May 29 at 2:53












    I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
    – toraritte
    May 29 at 5:41





    I guess the answer is yes: How to configure dual boot NixOS with Mac OS X on an (U)EFI MacBook? and NixPkgs issue #21534 - Option to add extra entries to systemd-boot
    – toraritte
    May 29 at 5:41





    1




    1




    Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
    – Emmanuel Rosa
    May 29 at 17:07





    Yep, that's correct. I've dual-booted NixOS with both MacOS and Windows 10 and in both cases I shared the same ESP (EFI partition). Setting boot.loader.efi.canTouchEfiVariables to false should tells the installer to leave your current boot manager (GRUB2) as the default. Then it's a matter of adding systemd-boot to GRUB2 as an item. Another way, especially if you have a lot of systems, is to install rEFInd and let it be the default. rEFInd checks your ESP for EFI executables and lists them, so you don't have to keep adding menu entries.
    – Emmanuel Rosa
    May 29 at 17:07













    up vote
    0
    down vote













    Adding this answer for completeness sake: in theory, @Mioriin's suggestion above of chrooting would be the correct answer, that could be achieved by the command nixos-enter.



    From Ubuntu, with the NixOS partitions mounted to /mnt:



    $ sudo $(which nixos-enter)
    ...
    [root@nixos:/]# nixos-rebuild switch


    In practice, this did not work, because networking wouldn't work (probably because my configuration.nix was missing the right setup in the first place), and got a bunch of error messages:



    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
    error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:13
    System has not been booted with systemd as init system (PID 1). Can't operate.
    building Nix...
    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
    error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
    error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
    warning: unable to download 'https://cache.nixos.org/nix-cache-info': Couldn't resolve host name (6); retrying in 293 ms
    ^Cwarning: download of 'https://cache.nixos.org/nix-cache-info' was interrupted
    don't know how to build these paths:
    /nix/store/z6avpvg24f6d1br2sr6qlphsq3h4d91v-nix-2.0.2
    error: interrupted by the user
    warning: don't know how to get latest Nix



    In the end, @Emmanuel Rosa's answer is right one, especially because (as he points it out) nixos-install can be safely executed multiple times.






    share|improve this answer

























      up vote
      0
      down vote













      Adding this answer for completeness sake: in theory, @Mioriin's suggestion above of chrooting would be the correct answer, that could be achieved by the command nixos-enter.



      From Ubuntu, with the NixOS partitions mounted to /mnt:



      $ sudo $(which nixos-enter)
      ...
      [root@nixos:/]# nixos-rebuild switch


      In practice, this did not work, because networking wouldn't work (probably because my configuration.nix was missing the right setup in the first place), and got a bunch of error messages:



      warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
      warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
      error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:13
      System has not been booted with systemd as init system (PID 1). Can't operate.
      building Nix...
      warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
      warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
      error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
      warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
      warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
      error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
      warning: unable to download 'https://cache.nixos.org/nix-cache-info': Couldn't resolve host name (6); retrying in 293 ms
      ^Cwarning: download of 'https://cache.nixos.org/nix-cache-info' was interrupted
      don't know how to build these paths:
      /nix/store/z6avpvg24f6d1br2sr6qlphsq3h4d91v-nix-2.0.2
      error: interrupted by the user
      warning: don't know how to get latest Nix



      In the end, @Emmanuel Rosa's answer is right one, especially because (as he points it out) nixos-install can be safely executed multiple times.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Adding this answer for completeness sake: in theory, @Mioriin's suggestion above of chrooting would be the correct answer, that could be achieved by the command nixos-enter.



        From Ubuntu, with the NixOS partitions mounted to /mnt:



        $ sudo $(which nixos-enter)
        ...
        [root@nixos:/]# nixos-rebuild switch


        In practice, this did not work, because networking wouldn't work (probably because my configuration.nix was missing the right setup in the first place), and got a bunch of error messages:



        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
        error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:13
        System has not been booted with systemd as init system (PID 1). Can't operate.
        building Nix...
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
        error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
        error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
        warning: unable to download 'https://cache.nixos.org/nix-cache-info': Couldn't resolve host name (6); retrying in 293 ms
        ^Cwarning: download of 'https://cache.nixos.org/nix-cache-info' was interrupted
        don't know how to build these paths:
        /nix/store/z6avpvg24f6d1br2sr6qlphsq3h4d91v-nix-2.0.2
        error: interrupted by the user
        warning: don't know how to get latest Nix



        In the end, @Emmanuel Rosa's answer is right one, especially because (as he points it out) nixos-install can be safely executed multiple times.






        share|improve this answer













        Adding this answer for completeness sake: in theory, @Mioriin's suggestion above of chrooting would be the correct answer, that could be achieved by the command nixos-enter.



        From Ubuntu, with the NixOS partitions mounted to /mnt:



        $ sudo $(which nixos-enter)
        ...
        [root@nixos:/]# nixos-rebuild switch


        In practice, this did not work, because networking wouldn't work (probably because my configuration.nix was missing the right setup in the first place), and got a bunch of error messages:



        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
        error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:13
        System has not been booted with systemd as init system (PID 1). Can't operate.
        building Nix...
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
        error: file 'nixpkgs/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs' does not exist, ignoring
        warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
        error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
        warning: unable to download 'https://cache.nixos.org/nix-cache-info': Couldn't resolve host name (6); retrying in 293 ms
        ^Cwarning: download of 'https://cache.nixos.org/nix-cache-info' was interrupted
        don't know how to build these paths:
        /nix/store/z6avpvg24f6d1br2sr6qlphsq3h4d91v-nix-2.0.2
        error: interrupted by the user
        warning: don't know how to get latest Nix



        In the end, @Emmanuel Rosa's answer is right one, especially because (as he points it out) nixos-install can be safely executed multiple times.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered May 31 at 5:58









        toraritte

        1639




        1639






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446501%2fhow-to-rebuild-the-configuration-of-a-nixos-installation-from-live-cd%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay