Lots of formatting?
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
# your system. Help is available in the configuration.nix(5) man page
|
# your system. Help is available in the configuration.nix(5) man page
|
||||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
|
|
||||||
{ config, pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
|||||||
+2
-1
@@ -31,7 +31,8 @@ let
|
|||||||
# Local changes
|
# Local changes
|
||||||
../modules/nix-conf.nix
|
../modules/nix-conf.nix
|
||||||
./baseline.nix
|
./baseline.nix
|
||||||
] ++ lib.optionals (builtins.pathExists ./hosts/${name}) [ ./hosts/${name} ];
|
]
|
||||||
|
++ lib.optionals (builtins.pathExists ./hosts/${name}) [ ./hosts/${name} ];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@ in
|
|||||||
top.nixvimunstable.homeModules.nixvim
|
top.nixvimunstable.homeModules.nixvim
|
||||||
top.self.modules.homeManagerModule
|
top.self.modules.homeManagerModule
|
||||||
./baseline
|
./baseline
|
||||||
] ++ lib.optionals (builtins.pathExists ./hosts/${host}) [ ./hosts/${host} ];
|
]
|
||||||
|
++ lib.optionals (builtins.pathExists ./hosts/${host}) [ ./hosts/${host} ];
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
inherit homeDirectory username;
|
inherit homeDirectory username;
|
||||||
|
|||||||
+2
-1
@@ -38,7 +38,8 @@ let
|
|||||||
./baseline.nix
|
./baseline.nix
|
||||||
top.self.modules.nixosModule
|
top.self.modules.nixosModule
|
||||||
./${name}
|
./${name}
|
||||||
] ++ extraMods;
|
]
|
||||||
|
++ extraMods;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
efi.canTouchEfiVariables = true;
|
efi.canTouchEfiVariables = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages =
|
environment.systemPackages = with pkgs; [
|
||||||
with pkgs;
|
];
|
||||||
[
|
|
||||||
];
|
|
||||||
|
|
||||||
greg = {
|
greg = {
|
||||||
home = true;
|
home = true;
|
||||||
|
|||||||
+6
-3
@@ -65,9 +65,12 @@ in
|
|||||||
++
|
++
|
||||||
|
|
||||||
# Items that are not supported on ARM/Linux
|
# Items that are not supported on ARM/Linux
|
||||||
(excludes [ "aarch64-linux" ] [
|
(excludes
|
||||||
synology-drive-client
|
[ "aarch64-linux" ]
|
||||||
]);
|
[
|
||||||
|
synology-drive-client
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
programs.firefox = {
|
programs.firefox = {
|
||||||
enable = true; # (!pkgs.stdenv.hostPlatform.isDarwin);
|
enable = true; # (!pkgs.stdenv.hostPlatform.isDarwin);
|
||||||
|
|||||||
+264
-266
@@ -432,66 +432,64 @@ in
|
|||||||
# TODO Use `udevadm trigger --settle` instead of the separate `udevadm settle`
|
# TODO Use `udevadm trigger --settle` instead of the separate `udevadm settle`
|
||||||
# once that feature is available to us with systemd >= 238;
|
# once that feature is available to us with systemd >= 238;
|
||||||
# see https://github.com/systemd/systemd/commit/792cc203a67edb201073351f5c766fce3d5eab45
|
# see https://github.com/systemd/systemd/commit/792cc203a67edb201073351f5c766fce3d5eab45
|
||||||
preStart =
|
preStart = ''
|
||||||
''
|
set -x
|
||||||
set -x
|
${ensureCephDirs}
|
||||||
${ensureCephDirs}
|
install -m 755 -o ${config.users.users.ceph.name} -g ${config.users.groups.ceph.name} -d /var/lib/ceph/bootstrap-osd
|
||||||
install -m 755 -o ${config.users.users.ceph.name} -g ${config.users.groups.ceph.name} -d /var/lib/ceph/bootstrap-osd
|
# `install` is not atomic, see
|
||||||
# `install` is not atomic, see
|
# https://lists.gnu.org/archive/html/bug-coreutils/2010-02/msg00243.html
|
||||||
# https://lists.gnu.org/archive/html/bug-coreutils/2010-02/msg00243.html
|
# so use `mktemp` + `mv` to make it atomic.
|
||||||
# so use `mktemp` + `mv` to make it atomic.
|
TMPFILE=$(mktemp --tmpdir=/var/lib/ceph/bootstrap-osd/)
|
||||||
TMPFILE=$(mktemp --tmpdir=/var/lib/ceph/bootstrap-osd/)
|
install -o ${config.users.users.ceph.name} -g ${config.users.groups.ceph.name} ${osdConfig.bootstrapKeyring} "$TMPFILE"
|
||||||
install -o ${config.users.users.ceph.name} -g ${config.users.groups.ceph.name} ${osdConfig.bootstrapKeyring} "$TMPFILE"
|
mv "$TMPFILE" /var/lib/ceph/bootstrap-osd/ceph.keyring
|
||||||
mv "$TMPFILE" /var/lib/ceph/bootstrap-osd/ceph.keyring
|
|
||||||
|
|
||||||
# Trigger udev rules for permissions of block devices and wait for them to settle.
|
# Trigger udev rules for permissions of block devices and wait for them to settle.
|
||||||
udevadm trigger --name-match=${osdConfig.blockDevice}
|
udevadm trigger --name-match=${osdConfig.blockDevice}
|
||||||
|
''
|
||||||
|
+ lib.optionalString (osdConfig.dbBlockDevice != null) ''
|
||||||
|
udevadm trigger --name-match=${osdConfig.dbBlockDevice}
|
||||||
|
''
|
||||||
|
+ ''
|
||||||
|
udevadm settle
|
||||||
|
''
|
||||||
|
+ (optionalString (!osdConfig.skipZap) (
|
||||||
|
''
|
||||||
|
# Zap OSD block devices, otherwise `ceph-osd` below will try to fsck if there's some old
|
||||||
|
# ceph data on the block device (see https://tracker.ceph.com/issues/24099).
|
||||||
|
${cfg.package}/bin/ceph-volume lvm zap ${osdConfig.blockDevice}
|
||||||
''
|
''
|
||||||
+ lib.optionalString (osdConfig.dbBlockDevice != null) ''
|
+ lib.optionalString (osdConfig.dbBlockDevice != null) ''
|
||||||
udevadm trigger --name-match=${osdConfig.dbBlockDevice}
|
${cfg.package}/bin/ceph-volume lvm zap ${osdConfig.dbBlockDevice}
|
||||||
''
|
''
|
||||||
+ ''
|
));
|
||||||
udevadm settle
|
|
||||||
''
|
|
||||||
+ (optionalString (!osdConfig.skipZap) (
|
|
||||||
''
|
|
||||||
# Zap OSD block devices, otherwise `ceph-osd` below will try to fsck if there's some old
|
|
||||||
# ceph data on the block device (see https://tracker.ceph.com/issues/24099).
|
|
||||||
${cfg.package}/bin/ceph-volume lvm zap ${osdConfig.blockDevice}
|
|
||||||
''
|
|
||||||
+ lib.optionalString (osdConfig.dbBlockDevice != null) ''
|
|
||||||
${cfg.package}/bin/ceph-volume lvm zap ${osdConfig.dbBlockDevice}
|
|
||||||
''
|
|
||||||
));
|
|
||||||
|
|
||||||
script =
|
script = ''
|
||||||
''
|
set -euo pipefail
|
||||||
set -euo pipefail
|
set -x
|
||||||
set -x
|
until [ -f /etc/ceph/${cfg.clusterName}.client.admin.keyring ]
|
||||||
until [ -f /etc/ceph/${cfg.clusterName}.client.admin.keyring ]
|
do
|
||||||
do
|
sleep 1
|
||||||
sleep 1
|
done
|
||||||
done
|
|
||||||
|
|
||||||
OSD_SECRET=$(${cfg.package}/bin/ceph-authtool --gen-print-key)
|
OSD_SECRET=$(${cfg.package}/bin/ceph-authtool --gen-print-key)
|
||||||
echo "{\"cephx_secret\": \"$OSD_SECRET\"}" | \
|
echo "{\"cephx_secret\": \"$OSD_SECRET\"}" | \
|
||||||
${cfg.package}/bin/ceph --cluster ${cfg.clusterName} osd new ${osdConfig.uuid} ${toString osdConfig.id} -i - \
|
${cfg.package}/bin/ceph --cluster ${cfg.clusterName} osd new ${osdConfig.uuid} ${toString osdConfig.id} -i - \
|
||||||
-n client.bootstrap-osd -k ${osdConfig.bootstrapKeyring}
|
-n client.bootstrap-osd -k ${osdConfig.bootstrapKeyring}
|
||||||
mkdir -p /var/lib/ceph/osd/${cfg.clusterName}-${toString osdConfig.id}
|
mkdir -p /var/lib/ceph/osd/${cfg.clusterName}-${toString osdConfig.id}
|
||||||
|
|
||||||
ln -s ${osdConfig.blockDevice} /var/lib/ceph/osd/${cfg.clusterName}-${toString osdConfig.id}/block
|
ln -s ${osdConfig.blockDevice} /var/lib/ceph/osd/${cfg.clusterName}-${toString osdConfig.id}/block
|
||||||
''
|
''
|
||||||
+ lib.optionalString (osdConfig.dbBlockDevice != null) ''
|
+ lib.optionalString (osdConfig.dbBlockDevice != null) ''
|
||||||
ln -s ${osdConfig.dbBlockDevice} /var/lib/ceph/osd/${cfg.clusterName}-${toString osdConfig.id}/block.db
|
ln -s ${osdConfig.dbBlockDevice} /var/lib/ceph/osd/${cfg.clusterName}-${toString osdConfig.id}/block.db
|
||||||
''
|
''
|
||||||
+ ''
|
+ ''
|
||||||
|
|
||||||
${cfg.package}/bin/ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${toString osdConfig.id}/keyring \
|
${cfg.package}/bin/ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${toString osdConfig.id}/keyring \
|
||||||
--name osd.${toString osdConfig.id} --add-key $OSD_SECRET
|
--name osd.${toString osdConfig.id} --add-key $OSD_SECRET
|
||||||
|
|
||||||
${cfg.package}/bin/ceph-osd -i ${toString osdConfig.id} --mkfs --osd-uuid ${osdConfig.uuid} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name} --osd-objectstore bluestore
|
${cfg.package}/bin/ceph-osd -i ${toString osdConfig.id} --mkfs --osd-uuid ${osdConfig.uuid} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name} --osd-objectstore bluestore
|
||||||
touch ${osdExistenceFile}
|
touch ${osdExistenceFile}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
@@ -529,7 +527,8 @@ in
|
|||||||
path = [
|
path = [
|
||||||
# TODO: use wrapProgram in the ceph package for this in the future
|
# TODO: use wrapProgram in the ceph package for this in the future
|
||||||
pkgs.getopt
|
pkgs.getopt
|
||||||
] ++ cephDeviceHealthMonitoringPathsOrPackages;
|
]
|
||||||
|
++ cephDeviceHealthMonitoringPathsOrPackages;
|
||||||
|
|
||||||
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
||||||
|
|
||||||
@@ -692,238 +691,237 @@ in
|
|||||||
) cfg.osds
|
) cfg.osds
|
||||||
);
|
);
|
||||||
|
|
||||||
systemd.services =
|
systemd.services = {
|
||||||
{
|
|
||||||
|
|
||||||
ceph-mon-setup = mkIf cfg.monitor.enable {
|
ceph-mon-setup = mkIf cfg.monitor.enable {
|
||||||
description = "Initialize ceph monitor";
|
description = "Initialize ceph monitor";
|
||||||
|
|
||||||
preStart = ensureCephDirs;
|
preStart = ensureCephDirs;
|
||||||
|
|
||||||
script =
|
script =
|
||||||
let
|
let
|
||||||
# `--addv` seems currently required to get msgr-v2 working, see:
|
# `--addv` seems currently required to get msgr-v2 working, see:
|
||||||
# https://tracker.ceph.com/issues/53751#note-11
|
# https://tracker.ceph.com/issues/53751#note-11
|
||||||
monmapNodes = builtins.concatStringsSep " " (
|
monmapNodes = builtins.concatStringsSep " " (
|
||||||
lib.concatMap (mon: [
|
lib.concatMap (mon: [
|
||||||
"--addv"
|
"--addv"
|
||||||
mon.hostname
|
mon.hostname
|
||||||
"[v2:${mon.ipAddress}:3300,v1:${mon.ipAddress}:6789]"
|
"[v2:${mon.ipAddress}:3300,v1:${mon.ipAddress}:6789]"
|
||||||
]) cfg.initialMonitors
|
]) cfg.initialMonitors
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
# Monitors cannot simply be changed in config, one has to update the monmap, see note [replacing-ceph-monmap-ips-for-existing-cluster]
|
# Monitors cannot simply be changed in config, one has to update the monmap, see note [replacing-ceph-monmap-ips-for-existing-cluster]
|
||||||
''
|
''
|
||||||
set -euo pipefail
|
|
||||||
rm -rf "${monDir}" # Start from scratch.
|
|
||||||
echo "Initializing monitor."
|
|
||||||
MONMAP_DIR=`mktemp -d`
|
|
||||||
${cfg.package}/bin/monmaptool --create ${monmapNodes} --fsid ${cfg.fsid} "$MONMAP_DIR/monmap"
|
|
||||||
${cfg.package}/bin/ceph-mon --cluster ${cfg.clusterName} --mkfs -i ${cfg.monitor.nodeName} --monmap "$MONMAP_DIR/monmap" --keyring ${cfg.monitor.initialKeyring}
|
|
||||||
rm -r "$MONMAP_DIR"
|
|
||||||
touch ${monDir}/done
|
|
||||||
'';
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
PermissionsStartOnly = true; # only run the script as ceph
|
|
||||||
User = config.users.users.ceph.name;
|
|
||||||
Group = config.users.groups.ceph.name;
|
|
||||||
};
|
|
||||||
unitConfig = {
|
|
||||||
ConditionPathExists = "!${monDir}/done";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
ceph-mon = mkIf cfg.monitor.enable {
|
|
||||||
description = "Ceph monitor";
|
|
||||||
|
|
||||||
requires = [ (ensureUnitExists config "ceph-mon-setup.service") ];
|
|
||||||
requiredBy = [ "multi-user.target" ];
|
|
||||||
after = [
|
|
||||||
"network.target"
|
|
||||||
"local-fs.target"
|
|
||||||
"time-sync.target"
|
|
||||||
(ensureUnitExists config "ceph-mon-setup.service")
|
|
||||||
];
|
|
||||||
wants = [
|
|
||||||
"network.target"
|
|
||||||
"local-fs.target"
|
|
||||||
"time-sync.target"
|
|
||||||
];
|
|
||||||
|
|
||||||
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
|
||||||
|
|
||||||
path = cephDeviceHealthMonitoringPathsOrPackages;
|
|
||||||
|
|
||||||
preStart = ensureTransientCephDirs;
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
LimitNOFILE = "1048576";
|
|
||||||
LimitNPROC = "1048576";
|
|
||||||
ExecStart = ''
|
|
||||||
${cfg.package}/bin/ceph-mon -f --cluster ${cfg.clusterName} --id ${cfg.monitor.nodeName} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name} "--public_bind_addr=${cfg.monitor.bindAddr}" "--public_addr=${cfg.monitor.advertisedPublicAddr}"
|
|
||||||
'';
|
|
||||||
ExecReload = ''
|
|
||||||
${pkgs.coreutils}/bin/kill -HUP $MAINPID
|
|
||||||
'';
|
|
||||||
PrivateDevices = "yes";
|
|
||||||
ProtectHome = "true";
|
|
||||||
ProtectSystem = "full";
|
|
||||||
PrivateTmp = "true";
|
|
||||||
TasksMax = "infinity";
|
|
||||||
Restart = "on-failure";
|
|
||||||
# StartLimitBurst="5";
|
|
||||||
RestartSec = "10";
|
|
||||||
};
|
|
||||||
# startLimitIntervalSec = 30 * 60;
|
|
||||||
};
|
|
||||||
|
|
||||||
ceph-mgr-setup = mkIf cfg.manager.enable {
|
|
||||||
description = "Initialize Ceph manager";
|
|
||||||
|
|
||||||
preStart = ensureCephDirs;
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
mkdir -p ${mgrDir}
|
rm -rf "${monDir}" # Start from scratch.
|
||||||
until [ -f /etc/ceph/${cfg.clusterName}.client.admin.keyring ]
|
echo "Initializing monitor."
|
||||||
do
|
MONMAP_DIR=`mktemp -d`
|
||||||
sleep 1
|
${cfg.package}/bin/monmaptool --create ${monmapNodes} --fsid ${cfg.fsid} "$MONMAP_DIR/monmap"
|
||||||
done
|
${cfg.package}/bin/ceph-mon --cluster ${cfg.clusterName} --mkfs -i ${cfg.monitor.nodeName} --monmap "$MONMAP_DIR/monmap" --keyring ${cfg.monitor.initialKeyring}
|
||||||
${cfg.package}/bin/ceph auth get-or-create mgr.${cfg.manager.nodeName} mon 'allow profile mgr' mds 'allow *' osd 'allow *' -o ${mgrDir}/keyring
|
rm -r "$MONMAP_DIR"
|
||||||
touch "${mgrDir}/.nix_done"
|
touch ${monDir}/done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
PermissionsStartOnly = true; # only run the script as ceph
|
PermissionsStartOnly = true; # only run the script as ceph
|
||||||
User = config.users.users.ceph.name;
|
User = config.users.users.ceph.name;
|
||||||
Group = config.users.groups.ceph.name;
|
Group = config.users.groups.ceph.name;
|
||||||
};
|
|
||||||
unitConfig = {
|
|
||||||
ConditionPathExists = "!${mgrDir}/.nix_done";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
unitConfig = {
|
||||||
ceph-mgr = mkIf cfg.manager.enable {
|
ConditionPathExists = "!${monDir}/done";
|
||||||
description = "Ceph manager";
|
|
||||||
|
|
||||||
requires = [ (ensureUnitExists config "ceph-mgr-setup.service") ];
|
|
||||||
requiredBy = [ "multi-user.target" ];
|
|
||||||
after = [
|
|
||||||
"network.target"
|
|
||||||
"local-fs.target"
|
|
||||||
"time-sync.target"
|
|
||||||
(ensureUnitExists config "ceph-mgr-setup.service")
|
|
||||||
];
|
|
||||||
wants = [
|
|
||||||
"network.target"
|
|
||||||
"local-fs.target"
|
|
||||||
"time-sync.target"
|
|
||||||
];
|
|
||||||
|
|
||||||
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
|
||||||
|
|
||||||
preStart = ensureTransientCephDirs;
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
LimitNOFILE = "1048576";
|
|
||||||
LimitNPROC = "1048576";
|
|
||||||
|
|
||||||
ExecStart = ''
|
|
||||||
${cfg.package}/bin/ceph-mgr -f --cluster ${cfg.clusterName} --id ${cfg.manager.nodeName} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name}
|
|
||||||
'';
|
|
||||||
ExecReload = ''
|
|
||||||
${pkgs.coreutils}/bin/kill -HUP $MAINPID
|
|
||||||
'';
|
|
||||||
Restart = "on-failure";
|
|
||||||
RestartSec = 10;
|
|
||||||
# StartLimitBurst="3";
|
|
||||||
};
|
|
||||||
# startLimitIntervalSec = 30 * 60;
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
ceph-mds-setup = mkIf cfg.mds.enable {
|
ceph-mon = mkIf cfg.monitor.enable {
|
||||||
description = "Initialize Ceph MDS";
|
description = "Ceph monitor";
|
||||||
|
|
||||||
preStart = ensureCephDirs;
|
requires = [ (ensureUnitExists config "ceph-mon-setup.service") ];
|
||||||
|
requiredBy = [ "multi-user.target" ];
|
||||||
|
after = [
|
||||||
|
"network.target"
|
||||||
|
"local-fs.target"
|
||||||
|
"time-sync.target"
|
||||||
|
(ensureUnitExists config "ceph-mon-setup.service")
|
||||||
|
];
|
||||||
|
wants = [
|
||||||
|
"network.target"
|
||||||
|
"local-fs.target"
|
||||||
|
"time-sync.target"
|
||||||
|
];
|
||||||
|
|
||||||
script = ''
|
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
||||||
set -euo pipefail
|
|
||||||
mkdir -p ${mdsDir}
|
path = cephDeviceHealthMonitoringPathsOrPackages;
|
||||||
until [ -f /etc/ceph/${cfg.clusterName}.client.admin.keyring ]
|
|
||||||
do
|
preStart = ensureTransientCephDirs;
|
||||||
sleep 1
|
|
||||||
done
|
serviceConfig = {
|
||||||
${cfg.package}/bin/ceph auth get-or-create mds.${cfg.mds.nodeName} osd 'allow rwx' mds 'allow' mon 'allow profile mds' -o ${mdsDir}/keyring
|
LimitNOFILE = "1048576";
|
||||||
touch "${mdsDir}/.nix_done"
|
LimitNPROC = "1048576";
|
||||||
|
ExecStart = ''
|
||||||
|
${cfg.package}/bin/ceph-mon -f --cluster ${cfg.clusterName} --id ${cfg.monitor.nodeName} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name} "--public_bind_addr=${cfg.monitor.bindAddr}" "--public_addr=${cfg.monitor.advertisedPublicAddr}"
|
||||||
'';
|
'';
|
||||||
|
ExecReload = ''
|
||||||
serviceConfig = {
|
${pkgs.coreutils}/bin/kill -HUP $MAINPID
|
||||||
Type = "oneshot";
|
'';
|
||||||
RemainAfterExit = true;
|
PrivateDevices = "yes";
|
||||||
PermissionsStartOnly = true; # only run the script as ceph
|
ProtectHome = "true";
|
||||||
User = config.users.users.ceph.name;
|
ProtectSystem = "full";
|
||||||
Group = config.users.groups.ceph.name;
|
PrivateTmp = "true";
|
||||||
};
|
TasksMax = "infinity";
|
||||||
unitConfig = {
|
Restart = "on-failure";
|
||||||
ConditionPathExists = "!${mdsDir}/.nix_done";
|
# StartLimitBurst="5";
|
||||||
};
|
RestartSec = "10";
|
||||||
};
|
};
|
||||||
|
# startLimitIntervalSec = 30 * 60;
|
||||||
|
};
|
||||||
|
|
||||||
ceph-mds = mkIf cfg.mds.enable {
|
ceph-mgr-setup = mkIf cfg.manager.enable {
|
||||||
description = "Ceph MDS";
|
description = "Initialize Ceph manager";
|
||||||
|
|
||||||
requires = [ (ensureUnitExists config "ceph-mds-setup.service") ];
|
preStart = ensureCephDirs;
|
||||||
requiredBy = [ "multi-user.target" ];
|
|
||||||
after = [
|
|
||||||
"network.target"
|
|
||||||
"local-fs.target"
|
|
||||||
"time-sync.target"
|
|
||||||
(ensureUnitExists config "ceph-mds-setup.service")
|
|
||||||
];
|
|
||||||
wants = [
|
|
||||||
"network.target"
|
|
||||||
"local-fs.target"
|
|
||||||
"time-sync.target"
|
|
||||||
];
|
|
||||||
|
|
||||||
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
script = ''
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p ${mgrDir}
|
||||||
|
until [ -f /etc/ceph/${cfg.clusterName}.client.admin.keyring ]
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
${cfg.package}/bin/ceph auth get-or-create mgr.${cfg.manager.nodeName} mon 'allow profile mgr' mds 'allow *' osd 'allow *' -o ${mgrDir}/keyring
|
||||||
|
touch "${mgrDir}/.nix_done"
|
||||||
|
'';
|
||||||
|
|
||||||
preStart = ensureTransientCephDirs;
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
serviceConfig = {
|
RemainAfterExit = true;
|
||||||
LimitNOFILE = "1048576";
|
PermissionsStartOnly = true; # only run the script as ceph
|
||||||
LimitNPROC = "1048576";
|
User = config.users.users.ceph.name;
|
||||||
|
Group = config.users.groups.ceph.name;
|
||||||
ExecStart = ''
|
|
||||||
${cfg.package}/bin/ceph-mds -f --cluster ${cfg.clusterName} --id ${cfg.mds.nodeName} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name} "--public_addr=${cfg.mds.listenAddr}"
|
|
||||||
'';
|
|
||||||
ExecReload = ''
|
|
||||||
${pkgs.coreutils}/bin/kill -HUP $MAINPID
|
|
||||||
'';
|
|
||||||
Restart = "on-failure";
|
|
||||||
# StartLimitBurst="3";
|
|
||||||
};
|
|
||||||
# startLimitIntervalSec = 30 * 60;
|
|
||||||
};
|
};
|
||||||
|
unitConfig = {
|
||||||
|
ConditionPathExists = "!${mgrDir}/.nix_done";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
ceph-mgr = mkIf cfg.manager.enable {
|
||||||
# Make one OSD service for each configured OSD.
|
description = "Ceph manager";
|
||||||
// lib.mapAttrs' (
|
|
||||||
localOsdServiceName: osdConfig:
|
requires = [ (ensureUnitExists config "ceph-mgr-setup.service") ];
|
||||||
nameValuePair "ceph-osd-setup-${localOsdServiceName}" (
|
requiredBy = [ "multi-user.target" ];
|
||||||
makeCephOsdSetupSystemdService localOsdServiceName osdConfig
|
after = [
|
||||||
)
|
"network.target"
|
||||||
) cfg.osds
|
"local-fs.target"
|
||||||
// lib.mapAttrs' (
|
"time-sync.target"
|
||||||
localOsdServiceName: osdConfig:
|
(ensureUnitExists config "ceph-mgr-setup.service")
|
||||||
nameValuePair "ceph-osd-${localOsdServiceName}" (
|
];
|
||||||
makeCephOsdSystemdService localOsdServiceName osdConfig
|
wants = [
|
||||||
)
|
"network.target"
|
||||||
) cfg.osds;
|
"local-fs.target"
|
||||||
|
"time-sync.target"
|
||||||
|
];
|
||||||
|
|
||||||
|
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
||||||
|
|
||||||
|
preStart = ensureTransientCephDirs;
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
LimitNOFILE = "1048576";
|
||||||
|
LimitNPROC = "1048576";
|
||||||
|
|
||||||
|
ExecStart = ''
|
||||||
|
${cfg.package}/bin/ceph-mgr -f --cluster ${cfg.clusterName} --id ${cfg.manager.nodeName} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name}
|
||||||
|
'';
|
||||||
|
ExecReload = ''
|
||||||
|
${pkgs.coreutils}/bin/kill -HUP $MAINPID
|
||||||
|
'';
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 10;
|
||||||
|
# StartLimitBurst="3";
|
||||||
|
};
|
||||||
|
# startLimitIntervalSec = 30 * 60;
|
||||||
|
};
|
||||||
|
|
||||||
|
ceph-mds-setup = mkIf cfg.mds.enable {
|
||||||
|
description = "Initialize Ceph MDS";
|
||||||
|
|
||||||
|
preStart = ensureCephDirs;
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p ${mdsDir}
|
||||||
|
until [ -f /etc/ceph/${cfg.clusterName}.client.admin.keyring ]
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
${cfg.package}/bin/ceph auth get-or-create mds.${cfg.mds.nodeName} osd 'allow rwx' mds 'allow' mon 'allow profile mds' -o ${mdsDir}/keyring
|
||||||
|
touch "${mdsDir}/.nix_done"
|
||||||
|
'';
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
PermissionsStartOnly = true; # only run the script as ceph
|
||||||
|
User = config.users.users.ceph.name;
|
||||||
|
Group = config.users.groups.ceph.name;
|
||||||
|
};
|
||||||
|
unitConfig = {
|
||||||
|
ConditionPathExists = "!${mdsDir}/.nix_done";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
ceph-mds = mkIf cfg.mds.enable {
|
||||||
|
description = "Ceph MDS";
|
||||||
|
|
||||||
|
requires = [ (ensureUnitExists config "ceph-mds-setup.service") ];
|
||||||
|
requiredBy = [ "multi-user.target" ];
|
||||||
|
after = [
|
||||||
|
"network.target"
|
||||||
|
"local-fs.target"
|
||||||
|
"time-sync.target"
|
||||||
|
(ensureUnitExists config "ceph-mds-setup.service")
|
||||||
|
];
|
||||||
|
wants = [
|
||||||
|
"network.target"
|
||||||
|
"local-fs.target"
|
||||||
|
"time-sync.target"
|
||||||
|
];
|
||||||
|
|
||||||
|
restartTriggers = [ config.environment.etc."ceph/${cfg.clusterName}.conf".source ];
|
||||||
|
|
||||||
|
preStart = ensureTransientCephDirs;
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
LimitNOFILE = "1048576";
|
||||||
|
LimitNPROC = "1048576";
|
||||||
|
|
||||||
|
ExecStart = ''
|
||||||
|
${cfg.package}/bin/ceph-mds -f --cluster ${cfg.clusterName} --id ${cfg.mds.nodeName} --setuser ${config.users.users.ceph.name} --setgroup ${config.users.groups.ceph.name} "--public_addr=${cfg.mds.listenAddr}"
|
||||||
|
'';
|
||||||
|
ExecReload = ''
|
||||||
|
${pkgs.coreutils}/bin/kill -HUP $MAINPID
|
||||||
|
'';
|
||||||
|
Restart = "on-failure";
|
||||||
|
# StartLimitBurst="3";
|
||||||
|
};
|
||||||
|
# startLimitIntervalSec = 30 * 60;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
# Make one OSD service for each configured OSD.
|
||||||
|
// lib.mapAttrs' (
|
||||||
|
localOsdServiceName: osdConfig:
|
||||||
|
nameValuePair "ceph-osd-setup-${localOsdServiceName}" (
|
||||||
|
makeCephOsdSetupSystemdService localOsdServiceName osdConfig
|
||||||
|
)
|
||||||
|
) cfg.osds
|
||||||
|
// lib.mapAttrs' (
|
||||||
|
localOsdServiceName: osdConfig:
|
||||||
|
nameValuePair "ceph-osd-${localOsdServiceName}" (
|
||||||
|
makeCephOsdSystemdService localOsdServiceName osdConfig
|
||||||
|
)
|
||||||
|
) cfg.osds;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-18
@@ -22,25 +22,24 @@ with lib;
|
|||||||
};
|
};
|
||||||
# Sets up a basic KDE installation
|
# Sets up a basic KDE installation
|
||||||
systemd.services.bluetooth.requiredBy = [ "multi-user.target" ];
|
systemd.services.bluetooth.requiredBy = [ "multi-user.target" ];
|
||||||
services =
|
services = {
|
||||||
{
|
libinput.enable = true;
|
||||||
libinput.enable = true;
|
blueman.enable = true;
|
||||||
blueman.enable = true;
|
|
||||||
|
|
||||||
pipewire = {
|
pipewire = {
|
||||||
enable = true;
|
enable = true;
|
||||||
alsa.enable = true;
|
alsa.enable = true;
|
||||||
alsa.support32Bit = true;
|
alsa.support32Bit = true;
|
||||||
pulse.enable = true;
|
pulse.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// (optionalAttrs (builtins.hasAttr "plasma6" options.services.xserver.desktopManager) {
|
// (optionalAttrs (builtins.hasAttr "plasma6" options.services.xserver.desktopManager) {
|
||||||
desktopManager.plasma6.enable = true;
|
desktopManager.plasma6.enable = true;
|
||||||
displayManager = {
|
displayManager = {
|
||||||
defaultSession = "plasma";
|
defaultSession = "plasma";
|
||||||
sddm.enable = true;
|
sddm.enable = true;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
programs.dconf.enable = true;
|
programs.dconf.enable = true;
|
||||||
|
|
||||||
|
|||||||
@@ -56,22 +56,21 @@ in
|
|||||||
];
|
];
|
||||||
|
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
allowedTCPPorts =
|
allowedTCPPorts = [
|
||||||
[
|
80
|
||||||
80
|
443
|
||||||
443
|
5432
|
||||||
5432
|
6443
|
||||||
6443
|
]
|
||||||
]
|
++ (
|
||||||
++ (
|
if cfg.agentOnly then
|
||||||
if cfg.agentOnly then
|
[ ]
|
||||||
[ ]
|
else
|
||||||
else
|
[
|
||||||
[
|
2379
|
||||||
2379
|
2380
|
||||||
2380
|
]
|
||||||
]
|
);
|
||||||
);
|
|
||||||
allowedUDPPorts = [ 8472 ];
|
allowedUDPPorts = [ 8472 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user