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
6with 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 = "without-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}