about summary refs log tree commit diff
path: root/nixos/modules/services/system
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2024-04-09 19:42:45 +0200
committerGitHub <noreply@github.com>2024-04-09 19:42:45 +0200
commitd79ff2f15b630bd21024e1b2273e341792d48ab9 (patch)
tree0e35228452286160b01eccbf89b80352c593e80b /nixos/modules/services/system
parent13cc5799321ebb1636e9df71cf592a239a62e81b (diff)
parent3d14617fc7006d161d531a9e9ddff9c163f84734 (diff)
Merge pull request #241816 from Mic92/cloud-init
nixos/cloud-init: enable filesystem based on what is configured
Diffstat (limited to 'nixos/modules/services/system')
-rw-r--r--nixos/modules/services/system/cloud-init.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/nixos/modules/services/system/cloud-init.nix b/nixos/modules/services/system/cloud-init.nix
index e6288270c8e24..689e0000fdd54 100644
--- a/nixos/modules/services/system/cloud-init.nix
+++ b/nixos/modules/services/system/cloud-init.nix
@@ -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.
         '';