difftreelog
feat prevent restart of NetworkManager during activation
in: trunk
1 file changed
modules/nixos/online.nixdiffbeforeafterboth1{2 config,3 lib,4 ...5}:6let7 inherit (lib.options) mkOption;8 inherit (lib.types)9 attrsOf10 str11 submodule12 either13 listOf14 lines15 bool16 ;17 inherit (lib.attrsets) mapAttrs;18 inherit (lib.trivial) isString;19in20{21 options.system.onlineActivationScripts = mkOption {22 default = { };23 type = attrsOf (24 either str (submodule {25 options = {26 deps = mkOption {27 type = listOf str;28 default = [ ];29 };30 text = mkOption {31 type = lines;32 };33 supportsDryActivation = mkOption {34 type = bool;35 default = false;36 };37 };38 })39 );40 description = ''41 Same as activation scripts, but only ran on online activation (i.e when operator is actively running fleet deploy, and not on system restart)4243 Can be used to apply configuration such as ceph monitor maps, which is required to be up-to-date to correctly function,44 we should not apply outdated ceph monmap.45 '';4647 apply =48 set:49 mapAttrs (50 name: value:51 if isString value then52 {53 text = ''54 if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then55 ${value}56 fi57 '';58 deps = [ "onlineActivation" ];59 }60 else61 value62 // {63 deps = [ "onlineActivation" ] ++ value.deps;64 text = ''65 if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then66 ${value.text}67 fi68 '';69 }70 ) set;71 };7273 config.system.activationScripts = {74 onlineActivation = {75 text = ''76 if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then77 1>&2 echo "online activation; hello, fleet!"78 fi79 '';80 supportsDryActivation = true;81 };82 } // config.system.onlineActivationScripts;83}1{2 config,3 lib,4 ...5}:6let7 inherit (lib.options) mkOption;8 inherit (lib.modules) mkIf mkDefault;9 inherit (lib.types)10 attrsOf11 str12 submodule13 either14 listOf15 lines16 bool17 ;18 inherit (lib.attrsets) mapAttrs;19 inherit (lib.trivial) isString;20in21{22 options.system.onlineActivationScripts = mkOption {23 default = { };24 type = attrsOf (25 either str (submodule {26 options = {27 deps = mkOption {28 type = listOf str;29 default = [ ];30 };31 text = mkOption {32 type = lines;33 };34 supportsDryActivation = mkOption {35 type = bool;36 default = false;37 };38 };39 })40 );41 description = ''42 Same as activation scripts, but only ran on online activation (i.e when operator is actively running fleet deploy, and not on system restart)4344 Can be used to apply configuration such as ceph monitor maps, which is required to be up-to-date to correctly function,45 we should not apply outdated ceph monmap.46 '';4748 apply =49 set:50 mapAttrs (51 name: value:52 if isString value then53 {54 text = ''55 if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then56 ${value}57 fi58 '';59 deps = [ "onlineActivation" ];60 }61 else62 value63 // {64 deps = [ "onlineActivation" ] ++ value.deps;65 text = ''66 if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then67 ${value.text}68 fi69 '';70 }71 ) set;72 };7374 config.system.activationScripts = {75 onlineActivation = {76 text = ''77 if [ ! -z ''${FLEET_ONLINE_ACTIVATION+x} ]; then78 1>&2 echo "online activation; hello, fleet!"79 fi80 '';81 supportsDryActivation = true;82 };83 } // config.system.onlineActivationScripts;8485 config.systemd.services = mkIf config.networking.networkmanager.enable {86 # If machine is managed by fleet, we should not restart NetworkManager during activation,87 # as it will disrupt the activation process. Furthermore, NetworkManager is not declarative,88 # so even if user wants to update his network settings - disabled NetworkManager restart89 # will not affect that.90 NetworkManager.restartIfChanged = mkDefault false;91 };92}