Skip to content

Commit

Permalink
Recover services.k3s.extraFlags.
Browse files Browse the repository at this point in the history
  • Loading branch information
bglgwyng committed Jan 24, 2025
1 parent 3b24b4b commit 8149a03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
7 changes: 4 additions & 3 deletions modules/nixos/containerd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ let
];
};

in {
in
{
imports = [
../common/containerd.nix
./k3s.nix
Expand Down Expand Up @@ -41,7 +42,7 @@ in {
systemd.services.containerd.path = cfg.path;
}
(lib.mkIf cfg.k3sIntegration {
services.k3s.moreFlags = [
services.k3s.extraFlags = [
"--container-runtime-endpoint unix:///run/containerd/containerd.sock"
];

Expand Down Expand Up @@ -75,7 +76,7 @@ in {
};
})
(lib.mkIf (cfg.k3sIntegration && cfg.nixSnapshotterIntegration) {
services.k3s.moreFlags = [
services.k3s.extraFlags = [
"--image-service-endpoint unix:///run/nix-snapshotter/nix-snapshotter.sock"
];
})
Expand Down
25 changes: 4 additions & 21 deletions modules/nixos/k3s.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,18 @@ let
inherit (lib)
mkOption
types
;
;

cfg = config.services.k3s;

in {
in
{
imports = [
../common/k3s.nix
];

options = {
services.k3s = {
# This was introduced to provide a mergeable listOf type.
moreFlags = mkOption {
type = types.listOf types.str;
description = lib.mdDoc "Extra flags to pass to the k3s command.";
default = [];
example = [ "--no-deploy traefik" "--cluster-cidr 10.24.0.0/16" ];
};
};
};

config = lib.mkIf cfg.enable {
environment.extraInit =
environment.extraInit =
(lib.optionalString cfg.setEmbeddedContainerd ''
if [ -z "$CONTAINERD_ADDRESS" ]; then
export CONTAINERD_ADDRESS="/run/k3s/containerd/containerd.sock"
Expand All @@ -43,12 +32,6 @@ in {
fi
'');

services.k3s = {
moreFlags = [ "--snapshotter ${cfg.snapshotter}" ];

extraFlags = toString cfg.moreFlags;
};

systemd.services.k3s.path = lib.mkIf (cfg.snapshotter == "nix") [
pkgs.nix
];
Expand Down

0 comments on commit 8149a03

Please sign in to comment.