[Nix-dev] Proposal: Standard installation procedure

Nicolas Pierron nicolas.b.pierron at gmail.com
Fri Oct 17 22:53:02 CEST 2014


Hi Ertugrul,

On Thu, Oct 16, 2014 at 1:00 PM, Ertugrul Söylemez <ertesx at gmx.de> wrote:
> Proposal
> ========
>
> The basic idea is this:  To build a system, you use a standard function
> from Nixpkgs and pass it a configuration module.  The result is a
> derivation that represents a complete self-contained system.  The
> initialisation program ($out/init) is not systemd directly, but a script
> that first checks whether the filesystem has already been initialised.
> If not, it sets up all necessary directories (like /etc) and then starts
> systemd as normal.
>
> In other words a container-based NixOS system is really just a Nix
> store, nothing more.  It doesn't need to contain any additional files or
> directories and building it does not require us to understand the
> complexity of nixos-install, because it will all be moved to the system
> initialisation phase.  Ideally we should factor out the initialisation
> into a separate script $out/pre-init that accepts a prefix argument.
> Then $out/init would simply look like this:
>
>     #! /bin/sh
>     /nix/store/abcxyz-nixos/pre-init --prefix=/
>     exec /nix/store/abc123-systemd/bin/systemd

I think the exec should be calling $out/post-init, which then execute
systemd, such as init is just a convenient concatenation of pre-init
and post-init.

> If we can also move pre-boot initialisation (like installing the boot
> loader) into the system itself (say, $out/pre-boot), then we could build
> entire virtual machines completely without relying on a hypervisor and
> the complexity of having to communicate with the installation process.
> Just set up the disk image, install the system and use the resulting
> $out/pre-boot script with appropriate override arguments:
>
>     out=`nix-build my-machine.nix`
>     # ... copy the closure ...
>     $out/pre-boot --override-grub-device=disk.img
>
> This would greatly simplify the implementation of nixos-install (just
> build the system and invoke the pre-boot script without overrides), but
> more importantly it would provide a very simple and standardised
> installation procedure for virtual machines and containers that we can
> rely on.
>
> […]
>
> Final remarks
> =============
>
> […]
>
> What do you think?  I would love to provide a prototype, but I really
> need help with this one.

I think this is an awesome idea.  I you need help/suggestion for this
project feel free to ask me. (pierron on irc / nbp on github).

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/


More information about the nix-dev mailing list