···11+{ config, lib, pkgs, ... }:
22+33+with lib;
44+55+{
66+ imports = [
77+ ../profiles/qemu-guest.nix
88+ ../profiles/headless.nix
99+ ];
1010+1111+ config = {
1212+ fileSystems."/".device = "/dev/disk/by-label/nixos";
1313+1414+ boot.kernelParams = [ "console=ttyS0" ];
1515+ boot.loader.grub.device = "/dev/vda";
1616+ boot.loader.timeout = 0;
1717+1818+ # Allow root logins
1919+ services.openssh.enable = true;
2020+ services.openssh.permitRootLogin = "prohibit-password";
2121+2222+ # Put /tmp and /var on /ephemeral0, which has a lot more space.
2323+ # Unfortunately we can't do this with the `fileSystems' option
2424+ # because it has no support for creating the source of a bind
2525+ # mount. Also, "move" /nix to /ephemeral0 by layering a unionfs-fuse
2626+ # mount on top of it so we have a lot more space for Nix operations.
2727+2828+ /*
2929+ boot.initrd.postMountCommands =
3030+ ''
3131+ mkdir -m 1777 -p $targetRoot/ephemeral0/tmp
3232+ mkdir -m 1777 -p $targetRoot/tmp
3333+ mount --bind $targetRoot/ephemeral0/tmp $targetRoot/tmp
3434+3535+ mkdir -m 755 -p $targetRoot/ephemeral0/var
3636+ mkdir -m 755 -p $targetRoot/var
3737+ mount --bind $targetRoot/ephemeral0/var $targetRoot/var
3838+3939+ mkdir -p /unionfs-chroot/ro-nix
4040+ mount --rbind $targetRoot/nix /unionfs-chroot/ro-nix
4141+4242+ mkdir -p /unionfs-chroot/rw-nix
4343+ mkdir -m 755 -p $targetRoot/ephemeral0/nix
4444+ mount --rbind $targetRoot/ephemeral0/nix /unionfs-chroot/rw-nix
4545+ unionfs -o allow_other,cow,nonempty,chroot=/unionfs-chroot,max_files=32768 /rw-nix=RW:/ro-nix=RO $targetRoot/nix
4646+ '';
4747+4848+ boot.initrd.supportedFilesystems = [ "unionfs-fuse" ];
4949+ */
5050+ };
5151+}
-65
nixos/modules/virtualisation/nova-image.nix
···11-# Usage:
22-# $ NIXOS_CONFIG=`pwd`/nixos/modules/virtualisation/nova-image.nix nix-build '<nixpkgs/nixos>' -A config.system.build.novaImage
33-44-{ config, lib, pkgs, ... }:
55-66-with lib;
77-88-{
99- system.build.novaImage = import ../../lib/make-disk-image.nix {
1010- inherit pkgs lib config;
1111- partitioned = true;
1212- diskSize = 1 * 1024;
1313- configFile = pkgs.writeText "configuration.nix"
1414- ''
1515- {
1616- imports = [ <nixpkgs/nixos/modules/virtualisation/nova-image.nix> ];
1717- }
1818- '';
1919- };
2020-2121- imports = [
2222- ../profiles/qemu-guest.nix
2323- ../profiles/headless.nix
2424- ];
2525-2626- fileSystems."/".device = "/dev/disk/by-label/nixos";
2727-2828- boot.kernelParams = [ "console=ttyS0" ];
2929- boot.loader.grub.device = "/dev/vda";
3030- boot.loader.timeout = 0;
3131-3232- # Allow root logins
3333- services.openssh.enable = true;
3434- services.openssh.permitRootLogin = "prohibit-password";
3535-3636- # Put /tmp and /var on /ephemeral0, which has a lot more space.
3737- # Unfortunately we can't do this with the `fileSystems' option
3838- # because it has no support for creating the source of a bind
3939- # mount. Also, "move" /nix to /ephemeral0 by layering a unionfs-fuse
4040- # mount on top of it so we have a lot more space for Nix operations.
4141-4242- /*
4343- boot.initrd.postMountCommands =
4444- ''
4545- mkdir -m 1777 -p $targetRoot/ephemeral0/tmp
4646- mkdir -m 1777 -p $targetRoot/tmp
4747- mount --bind $targetRoot/ephemeral0/tmp $targetRoot/tmp
4848-4949- mkdir -m 755 -p $targetRoot/ephemeral0/var
5050- mkdir -m 755 -p $targetRoot/var
5151- mount --bind $targetRoot/ephemeral0/var $targetRoot/var
5252-5353- mkdir -p /unionfs-chroot/ro-nix
5454- mount --rbind $targetRoot/nix /unionfs-chroot/ro-nix
5555-5656- mkdir -p /unionfs-chroot/rw-nix
5757- mkdir -m 755 -p $targetRoot/ephemeral0/nix
5858- mount --rbind $targetRoot/ephemeral0/nix /unionfs-chroot/rw-nix
5959- unionfs -o allow_other,cow,nonempty,chroot=/unionfs-chroot,max_files=32768 /rw-nix=RW:/ro-nix=RO $targetRoot/nix
6060- '';
6161-6262- boot.initrd.supportedFilesystems = [ "unionfs-fuse" ];
6363- */
6464-6565-}