at 24.11-pre 1.9 kB view raw
1{ config, lib, pkgs, ... }: 2let 3 inherit (lib) literalExpression types; 4in 5{ 6 options = { 7 openstack = { 8 zfs = { 9 enable = lib.mkOption { 10 default = false; 11 internal = true; 12 description = '' 13 Whether the OpenStack instance uses a ZFS root. 14 ''; 15 }; 16 17 datasets = lib.mkOption { 18 description = '' 19 Datasets to create under the `tank` and `boot` zpools. 20 21 **NOTE:** This option is used only at image creation time, and 22 does not attempt to declaratively create or manage datasets 23 on an existing system. 24 ''; 25 26 default = { }; 27 28 type = types.attrsOf (types.submodule { 29 options = { 30 mount = lib.mkOption { 31 description = "Where to mount this dataset."; 32 type = types.nullOr types.str; 33 default = null; 34 }; 35 36 properties = lib.mkOption { 37 description = "Properties to set on this dataset."; 38 type = types.attrsOf types.str; 39 default = { }; 40 }; 41 }; 42 }); 43 }; 44 }; 45 46 efi = lib.mkOption { 47 default = pkgs.stdenv.hostPlatform.isAarch64; 48 defaultText = literalExpression "pkgs.stdenv.hostPlatform.isAarch64"; 49 internal = true; 50 description = '' 51 Whether the instance is using EFI. 52 ''; 53 }; 54 }; 55 }; 56 57 config = lib.mkIf config.openstack.zfs.enable { 58 networking.hostId = lib.mkDefault "00000000"; 59 60 fileSystems = 61 let 62 mountable = lib.filterAttrs (_: value: ((value.mount or null) != null)) config.openstack.zfs.datasets; 63 in 64 lib.mapAttrs' 65 (dataset: opts: lib.nameValuePair opts.mount { 66 device = dataset; 67 fsType = "zfs"; 68 }) 69 mountable; 70 }; 71}