0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Merge pull request #237802 from SuperSandro2000/ceph-package-options

nixos/ceph: add options to configure package used by each component
This commit is contained in:
Sandro 2023-07-09 23:38:28 +02:00 committed by GitHub
commit eae22520b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,18 +3,18 @@
with lib; with lib;
let let
cfg = config.services.ceph; cfg = config.services.ceph;
# function that translates "camelCaseOptions" to "camel case options", credits to tilpner in #nixos@freenode # function that translates "camelCaseOptions" to "camel case options", credits to tilpner in #nixos@freenode
expandCamelCase = replaceStrings upperChars (map (s: " ${s}") lowerChars); expandCamelCase = replaceStrings upperChars (map (s: " ${s}") lowerChars);
expandCamelCaseAttrs = mapAttrs' (name: value: nameValuePair (expandCamelCase name) value); expandCamelCaseAttrs = mapAttrs' (name: value: nameValuePair (expandCamelCase name) value);
makeServices = (daemonType: daemonIds: makeServices = daemonType: daemonIds:
mkMerge (map (daemonId: mkMerge (map (daemonId:
{ "ceph-${daemonType}-${daemonId}" = makeService daemonType daemonId cfg.global.clusterName pkgs.ceph; }) { "ceph-${daemonType}-${daemonId}" = makeService daemonType daemonId cfg.global.clusterName cfg.${daemonType}.package; })
daemonIds)); daemonIds);
makeService = (daemonType: daemonId: clusterName: ceph: makeService = daemonType: daemonId: clusterName: ceph:
let let
stateDirectory = "ceph/${if daemonType == "rgw" then "radosgw" else daemonType}/${clusterName}-${daemonId}"; in { stateDirectory = "ceph/${if daemonType == "rgw" then "radosgw" else daemonType}/${clusterName}-${daemonId}"; in {
enable = true; enable = true;
@ -54,9 +54,9 @@ let
} // optionalAttrs ( daemonType == "mon") { } // optionalAttrs ( daemonType == "mon") {
RestartSec = "10"; RestartSec = "10";
}; };
}); };
makeTarget = (daemonType: makeTarget = daemonType:
{ {
"ceph-${daemonType}" = { "ceph-${daemonType}" = {
description = "Ceph target allowing to start/stop all ceph-${daemonType} services at once"; description = "Ceph target allowing to start/stop all ceph-${daemonType} services at once";
@ -65,8 +65,7 @@ let
before = [ "ceph.target" ]; before = [ "ceph.target" ];
unitConfig.StopWhenUnneeded = true; unitConfig.StopWhenUnneeded = true;
}; };
} };
);
in in
{ {
options.services.ceph = { options.services.ceph = {
@ -211,6 +210,7 @@ in
to the id part in ceph i.e. [ "name1" ] would result in mgr.name1 to the id part in ceph i.e. [ "name1" ] would result in mgr.name1
''; '';
}; };
package = mkPackageOptionMD pkgs "ceph" { };
extraConfig = mkOption { extraConfig = mkOption {
type = with types; attrsOf str; type = with types; attrsOf str;
default = {}; default = {};
@ -231,6 +231,7 @@ in
to the id part in ceph i.e. [ "name1" ] would result in mon.name1 to the id part in ceph i.e. [ "name1" ] would result in mon.name1
''; '';
}; };
package = mkPackageOptionMD pkgs "ceph" { };
extraConfig = mkOption { extraConfig = mkOption {
type = with types; attrsOf str; type = with types; attrsOf str;
default = {}; default = {};
@ -251,7 +252,7 @@ in
to the id part in ceph i.e. [ "name1" ] would result in osd.name1 to the id part in ceph i.e. [ "name1" ] would result in osd.name1
''; '';
}; };
package = mkPackageOptionMD pkgs "ceph" { };
extraConfig = mkOption { extraConfig = mkOption {
type = with types; attrsOf str; type = with types; attrsOf str;
default = { default = {
@ -279,6 +280,7 @@ in
to the id part in ceph i.e. [ "name1" ] would result in mds.name1 to the id part in ceph i.e. [ "name1" ] would result in mds.name1
''; '';
}; };
package = mkPackageOptionMD pkgs "ceph" { };
extraConfig = mkOption { extraConfig = mkOption {
type = with types; attrsOf str; type = with types; attrsOf str;
default = {}; default = {};
@ -290,6 +292,7 @@ in
rgw = { rgw = {
enable = mkEnableOption (lib.mdDoc "Ceph RadosGW daemon"); enable = mkEnableOption (lib.mdDoc "Ceph RadosGW daemon");
package = mkPackageOptionMD pkgs "ceph" { };
daemons = mkOption { daemons = mkOption {
type = with types; listOf str; type = with types; listOf str;
default = []; default = [];
@ -328,16 +331,16 @@ in
{ assertion = cfg.global.fsid != ""; { assertion = cfg.global.fsid != "";
message = "fsid has to be set to a valid uuid for the cluster to function"; message = "fsid has to be set to a valid uuid for the cluster to function";
} }
{ assertion = cfg.mon.enable == true -> cfg.mon.daemons != []; { assertion = cfg.mon.enable -> cfg.mon.daemons != [];
message = "have to set id of atleast one MON if you're going to enable Monitor"; message = "have to set id of atleast one MON if you're going to enable Monitor";
} }
{ assertion = cfg.mds.enable == true -> cfg.mds.daemons != []; { assertion = cfg.mds.enable -> cfg.mds.daemons != [];
message = "have to set id of atleast one MDS if you're going to enable Metadata Service"; message = "have to set id of atleast one MDS if you're going to enable Metadata Service";
} }
{ assertion = cfg.osd.enable == true -> cfg.osd.daemons != []; { assertion = cfg.osd.enable -> cfg.osd.daemons != [];
message = "have to set id of atleast one OSD if you're going to enable OSD"; message = "have to set id of atleast one OSD if you're going to enable OSD";
} }
{ assertion = cfg.mgr.enable == true -> cfg.mgr.daemons != []; { assertion = cfg.mgr.enable -> cfg.mgr.daemons != [];
message = "have to set id of atleast one MGR if you're going to enable MGR"; message = "have to set id of atleast one MGR if you're going to enable MGR";
} }
]; ];