[Nix-dev] disk setup for nixos installation
Shea Levy
shea at shealevy.com
Sun Aug 18 18:38:48 CEST 2013
Hi Tim,
Generally, in NixOS we achieve effects outside of the store in a
two-phase process: We have derivations to create data (config files,
systemd units, shell scripts, etc.) in the store that represent the end
state we want (including a master activation script that joins all the
rest into a whole), and then a particular system state is transitioned
to by running the top level script.
Generally, these derivations are generated from a declarative
specification made possible by a module system implemented purely in
nix. We work hard to make the generated scripts idempotent, to make it
possible to transition arbitrarily between system configurations, to
make the system behave identically (for the relevant aspects) if a given
system configuration is switched to after having previously used
thousands of different configurations compared to if a system is freshly
installed with that configuration. We try to minimize the chances of
inconsistent system state. But generally these things are much harder to
achieve when considering an operating system as a whole rather than an
immutable file store, so guarantees are obviously less stringent than
what we can offer in the nix store itself.
Regarding your initial question: Already, we have NixOS modules to
describe the partitions/filesystems in use. There's no fundamental
reason why that information couldn't be used to automatically partition
and install filesystems, at least in simple cases, but currently it is
only used to manage fstab, determine which filesystems to boot from the
initrd, etc. IMO an automated partitioning system based on a NixOS
config would be an awesome addition.
Cheers,
Shea
On 8/17/13 7:22 AM, Tim Barbour wrote:
> I would like to be able to boot from nixos installation media, then do
> automated partitioning, LVM setup and filesystem creation, then let nixops do
> the rest. What is the best way to automate partitioning, LVM setup and
> filesystem creation ? I wrote a shell script to do this (just for one disk, so
> far) using parted etc., but it looks ugly, and I wonder if it would be better
> done using nix.
>
> Does nix / nixos provide any existing mechanisms for doing this ?
>
> I am an experienced functional programmer (Haskell, not nix), but I don't
> understand how to do IO in nix. Perhaps I should be modelling the disk setup
> as the building of some derivations, but such derivations would not produce a
> result in the nix store. If I made them produce a result in the store, then
> the disk setup would be a side-effect, and not referentially transparent. I
> get the feeling that this is outside the scope of nix.
>
> Tim
> ---
> GPG public key available at:
> http://phasechangeit.com/~trb/gpg-key or
> http://subkeys.pgp.net:11371
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
More information about the nix-dev
mailing list