git.delta.rocks / jrsonnet / refs/commits / 0f6e11e64e77

difftreelog

feat(nixos) system.onlineActivationScripts

Lach2025-04-24parent: #1b47815.patch.diff
in: trunk

1 file changed

modifiedmodules/nixos/online.nixdiffbeforeafterboth
after · modules/nixos/online.nix
1{2  config,3  lib,4  ...5}: let6  inherit (lib.options) mkOption;7  inherit (lib.types) attrsOf str submodule either listOf lines bool;8  inherit (lib.attrsets) mapAttrs;9  inherit (lib.trivial) isString;10in {11  options.system.onlineActivationScripts = mkOption {12    default = {};13    type = attrsOf (either str (submodule {14      options = {15        deps = mkOption {16          type = listOf str;17          default = [];18        };19        text = mkOption {20          type = lines;21        };22        supportsDryActivation = mkOption {23          type = bool;24          default = false;25        };26      };27    }));28    description = ''29      Same as activation scripts, but only ran on online activation (i.e when operator is actively running fleet deploy, and not on system restart)3031      Can be used to apply configuration such as ceph monitor maps, which is required to be up-to-date to correctly function,32      we should not apply outdated ceph monmap.33    '';3435    apply = set:36      mapAttrs (37        name: value:38          if isString value39          then {40            text = ''41              if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then42              	${value}43              fi44            '';45            deps = ["onlineActivation"];46          }47          else48            value49            // {50              deps = ["onlineActivation"] ++ value.deps;51              text = ''52                if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then53                	${value.text}54                fi55              '';56            }57      )58      set;59  };6061  config.system.activationScripts =62    {63      onlineActivation = {64        text = ''65          if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then66          	1>&2 echo "online activation; hello, fleet!"67          fi68        '';69        supportsDryActivation = true;70      };71    }72    // config.system.onlineActivationScripts;73}