1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 15:11:35 +00:00
nixpkgs/nixos/modules
obadz 24f8cf08cc nixos/lib/make-disk-image: refactor to use nixos-install
- Replace hand-rolled version of nixos-install in make-disk-image by an
  actual call to nixos-install
- Required a few cleanups of nixos-install
- nixos-install invokes an activation script which the hand-rolled version
  in make-disk-image did not do. We remove /etc/machine-id as that's
  a host-specific, impure, output of the activation script

Testing:

nix-build '<nixpkgs/nixos/release.nix>' -A tests.installer.simple passes

Also tried generating an image with:

nix-build -E 'let
    pkgs = import <nixpkgs> {};
    lib = pkgs.lib;
    nixos = import <nixpkgs/nixos> {
      configuration = {
        fileSystems."/".device = "/dev/disk/by-label/nixos";
        boot.loader.grub.devices = [ "/dev/sda" ];
        boot.loader.grub.extraEntries = '"''"'
          menuentry "Ubuntu" {
             insmod ext2
             search --set=root --label ubuntu
             configfile /boot/grub/grub.cfg
          }
        '"''"';
      };
    };
  in import <nixpkgs/nixos/lib/make-disk-image.nix> {
    inherit pkgs lib;
    config = nixos.config;
    diskSize = 2000;
    partitioned = false;
    installBootLoader = false;
  }'

Then installed the image:
$ sudo df if=./result/nixos.img of=/dev/sdaX bs=1M
$ sudo resize2fs /dev/disk/by-label/nixos
$ sudo mount /dev/disk/by-label/nixos /mnt
$ sudo mount --rbind /proc /mnt/proc
$ sudo mount --rbind /dev /mnt/dev
$ sudo chroot /mnt /nix/var/nix/profiles/system/bin/switch-to-configuration boot

[ … optionally do something about passwords … ]

and successfully rebooted to that image.

Was doing all this from inside a Ubuntu VM with a single user nix install.
2016-08-16 15:31:16 +01:00
..
config Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
hardware Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
i18n/input-method fcitx-unikey: mention in dockbook 2016-08-12 14:36:36 +07:00
installer nixos/lib/make-disk-image: refactor to use nixos-install 2016-08-16 15:31:16 +01:00
misc mattermost service: init 2016-08-15 04:15:11 +02:00
profiles documentation: fix start display-manager command 2016-07-04 10:25:31 +02:00
programs unity3d: use chromium-suid-sandbox 2016-08-08 10:49:00 +03:00
security grsecurity module: systemd-nspawn requires cap_sys_admin 2016-08-15 20:36:47 +02:00
services Merge pull request #17743 from mayflower/service/mattermost 2016-08-16 14:54:25 +02:00
system Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
tasks Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
testing KDE test: Bump kdm start timeout 2016-05-27 11:22:27 +02:00
virtualisation Revert "Merge branch 'modprobe-fix' of git://github.com/abbradar/nixpkgs" 2016-08-15 19:05:52 -04:00
module-list.nix mattermost service: init 2016-08-15 04:15:11 +02:00
rename.nix unity3d: use chromium-suid-sandbox 2016-08-08 10:49:00 +03:00