about summary refs log tree commit diff
path: root/nix/modules/libvirtnix/os.nix
blob: 41f36f347fe38a34caa26a4b5285d04b8bb3ef81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{ lib, ... }:

let
  mkOption = lib.mkOption;
  submodule = lib.types.submodule;
  types = lib.types;

  os = {
    firmware = mkOption {
      type = types.enum [
        "bios"
        "efi"
      ];
      default = "efi";
      example = "bios";
    };

    type = mkOption {
      type = types.enum [
        "hvm"
        "linux"
      ];
      default = "hvm";
      example = "linux";
    };

    arch = mkOption { type = types.str; };
    machine = mkOption { type = types.str; };

    # TODO(emile): features
    # Search for the following...
    # > When using firmware auto-selection there are different features enabled in the firmwares
    # ... here: https://libvirt.org/formatdomain.html
    # can't bother to implement this now

    # features = mkOption {
    # 	type = types.submodule {
    # 		options = {
    # 			enabled = {
    # 				type = types.enum [ "yes" "no" ];
    # 			};
    # 			name = {};
    # 		};
    # 	};
    # };

    # such as:
    # <loader readonly='yes' secure='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    loader = mkOption {
      type = types.submodule {
        options = {
          readonly = mkOption {
            type = types.enum [
              "yes"
              "no"
            ];
          };
          type = mkOption {
            type = types.enum [
              "rom"
              "pflash"
            ];
          };
          secure = mkOption {
            type = types.enum [
              "yes"
              "no"
            ];
          };
          stateless = mkOption {
            type = types.enum [
              "yes"
              "no"
            ];
          };
          format = mkOption {
            type = types.enum [
              "raw"
              "qcow2"
            ];
          };
          value = mkOption {
            type = types.str;
            example = "/usr/share/OVMF/OVMF_CODE.fd";
          };
        };
      };
    };

    # <nvram type='network'>
    #   <source protocol='iscsi' name='iqn.2013-07.com.example:iscsi-nopool/0'>
    #     <host name='example.com' port='6000'/>
    #     <auth username='myname'>
    #       <secret type='iscsi' usage='mycluster_myname'/>
    #     </auth>
    #   </source>
    # </nvram>

    # nvram = {
    # 	type = "network";
    # 	source = {
    # 		protocol = "iscsi";
    # 		name = "iqn.2013-07.com.example:iscsi-nopool/0";
    # 	};
    # };
    
  };
in
{
  options = {
    os = mkOption {
      type = submodule {
        options = {
          inherit (os) firmware type arch machine loader;
        };
      };
    };
  };
}