Merge pull request #241816 from Mic92/cloud-init

nixos/cloud-init: enable filesystem based on what is configured
This commit is contained in:
Jörg Thalheim 2024-04-09 19:42:45 +02:00 committed by GitHub
commit d79ff2f15b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -17,6 +17,7 @@ let
++ optional cfg.ext4.enable e2fsprogs
++ optional cfg.xfs.enable xfsprogs
;
hasFs = fsName: lib.any (fs: fs.fsType == fsName) (lib.attrValues config.fileSystems);
settingsFormat = pkgs.formats.yaml { };
cfgfile = settingsFormat.generate "cloud.cfg" cfg.settings;
in
@ -44,7 +45,8 @@ in
btrfs.enable = mkOption {
type = types.bool;
default = false;
default = hasFs "btrfs";
defaultText = literalExpression ''hasFs "btrfs"'';
description = mdDoc ''
Allow the cloud-init service to operate `btrfs` filesystem.
'';
@ -52,7 +54,8 @@ in
ext4.enable = mkOption {
type = types.bool;
default = true;
default = hasFs "ext4";
defaultText = literalExpression ''hasFs "ext4"'';
description = mdDoc ''
Allow the cloud-init service to operate `ext4` filesystem.
'';
@ -60,7 +63,8 @@ in
xfs.enable = mkOption {
type = types.bool;
default = false;
default = hasFs "xfs";
defaultText = literalExpression ''hasFs "xfs"'';
description = mdDoc ''
Allow the cloud-init service to operate `xfs` filesystem.
'';