···1+{ config, lib, pkgs, ... }:
2+3+with lib;
4+5+{
6+ imports = [
7+ ../profiles/qemu-guest.nix
8+ ../profiles/headless.nix
9+ ];
10+11+ config = {
12+ fileSystems."/".device = "/dev/disk/by-label/nixos";
13+14+ boot.kernelParams = [ "console=ttyS0" ];
15+ boot.loader.grub.device = "/dev/vda";
16+ boot.loader.timeout = 0;
17+18+ # Allow root logins
19+ services.openssh.enable = true;
20+ services.openssh.permitRootLogin = "prohibit-password";
21+22+ # Put /tmp and /var on /ephemeral0, which has a lot more space.
23+ # Unfortunately we can't do this with the `fileSystems' option
24+ # because it has no support for creating the source of a bind
25+ # mount. Also, "move" /nix to /ephemeral0 by layering a unionfs-fuse
26+ # mount on top of it so we have a lot more space for Nix operations.
27+28+ /*
29+ boot.initrd.postMountCommands =
30+ ''
31+ mkdir -m 1777 -p $targetRoot/ephemeral0/tmp
32+ mkdir -m 1777 -p $targetRoot/tmp
33+ mount --bind $targetRoot/ephemeral0/tmp $targetRoot/tmp
34+35+ mkdir -m 755 -p $targetRoot/ephemeral0/var
36+ mkdir -m 755 -p $targetRoot/var
37+ mount --bind $targetRoot/ephemeral0/var $targetRoot/var
38+39+ mkdir -p /unionfs-chroot/ro-nix
40+ mount --rbind $targetRoot/nix /unionfs-chroot/ro-nix
41+42+ mkdir -p /unionfs-chroot/rw-nix
43+ mkdir -m 755 -p $targetRoot/ephemeral0/nix
44+ mount --rbind $targetRoot/ephemeral0/nix /unionfs-chroot/rw-nix
45+ unionfs -o allow_other,cow,nonempty,chroot=/unionfs-chroot,max_files=32768 /rw-nix=RW:/ro-nix=RO $targetRoot/nix
46+ '';
47+48+ boot.initrd.supportedFilesystems = [ "unionfs-fuse" ];
49+ */
50+ };
51+}
-65
nixos/modules/virtualisation/nova-image.nix
···1-# Usage:
2-# $ NIXOS_CONFIG=`pwd`/nixos/modules/virtualisation/nova-image.nix nix-build '<nixpkgs/nixos>' -A config.system.build.novaImage
3-4-{ config, lib, pkgs, ... }:
5-6-with lib;
7-8-{
9- system.build.novaImage = import ../../lib/make-disk-image.nix {
10- inherit pkgs lib config;
11- partitioned = true;
12- diskSize = 1 * 1024;
13- configFile = pkgs.writeText "configuration.nix"
14- ''
15- {
16- imports = [ <nixpkgs/nixos/modules/virtualisation/nova-image.nix> ];
17- }
18- '';
19- };
20-21- imports = [
22- ../profiles/qemu-guest.nix
23- ../profiles/headless.nix
24- ];
25-26- fileSystems."/".device = "/dev/disk/by-label/nixos";
27-28- boot.kernelParams = [ "console=ttyS0" ];
29- boot.loader.grub.device = "/dev/vda";
30- boot.loader.timeout = 0;
31-32- # Allow root logins
33- services.openssh.enable = true;
34- services.openssh.permitRootLogin = "prohibit-password";
35-36- # Put /tmp and /var on /ephemeral0, which has a lot more space.
37- # Unfortunately we can't do this with the `fileSystems' option
38- # because it has no support for creating the source of a bind
39- # mount. Also, "move" /nix to /ephemeral0 by layering a unionfs-fuse
40- # mount on top of it so we have a lot more space for Nix operations.
41-42- /*
43- boot.initrd.postMountCommands =
44- ''
45- mkdir -m 1777 -p $targetRoot/ephemeral0/tmp
46- mkdir -m 1777 -p $targetRoot/tmp
47- mount --bind $targetRoot/ephemeral0/tmp $targetRoot/tmp
48-49- mkdir -m 755 -p $targetRoot/ephemeral0/var
50- mkdir -m 755 -p $targetRoot/var
51- mount --bind $targetRoot/ephemeral0/var $targetRoot/var
52-53- mkdir -p /unionfs-chroot/ro-nix
54- mount --rbind $targetRoot/nix /unionfs-chroot/ro-nix
55-56- mkdir -p /unionfs-chroot/rw-nix
57- mkdir -m 755 -p $targetRoot/ephemeral0/nix
58- mount --rbind $targetRoot/ephemeral0/nix /unionfs-chroot/rw-nix
59- unionfs -o allow_other,cow,nonempty,chroot=/unionfs-chroot,max_files=32768 /rw-nix=RW:/ro-nix=RO $targetRoot/nix
60- '';
61-62- boot.initrd.supportedFilesystems = [ "unionfs-fuse" ];
63- */
64-65-}