mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
modules/services/colima: remove with lib;
This commit is contained in:
parent
5bed31196b
commit
38328e30fe
1 changed files with 15 additions and 17 deletions
|
|
@ -4,8 +4,6 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.services.colima;
|
cfg = config.services.colima;
|
||||||
yamlFormat = pkgs.formats.yaml { };
|
yamlFormat = pkgs.formats.yaml { };
|
||||||
|
|
@ -16,33 +14,33 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
options.services.colima = {
|
options.services.colima = {
|
||||||
enable = mkEnableOption "Colima, a container runtime";
|
enable = lib.mkEnableOption "Colima, a container runtime";
|
||||||
|
|
||||||
package = mkPackageOption pkgs "colima" { };
|
package = lib.mkPackageOption pkgs "colima" { };
|
||||||
dockerPackage = lib.mkPackageOption pkgs "docker" { };
|
dockerPackage = lib.mkPackageOption pkgs "docker" { };
|
||||||
perlPackage = lib.mkPackageOption pkgs "perl" { };
|
perlPackage = lib.mkPackageOption pkgs "perl" { };
|
||||||
|
|
||||||
addDockerContext = mkOption {
|
addDockerContext = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Whether to add a Docker context for Colima.";
|
description = "Whether to add a Docker context for Colima.";
|
||||||
};
|
};
|
||||||
|
|
||||||
useAsDefaultContext = mkOption {
|
useAsDefaultContext = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Whether to set Colima docker context as default";
|
description = "Whether to set Colima docker context as default";
|
||||||
};
|
};
|
||||||
|
|
||||||
logFile = mkOption {
|
logFile = lib.mkOption {
|
||||||
type = types.path;
|
type = lib.types.path;
|
||||||
default = "${config.home.homeDirectory}/.local/state/colima.log";
|
default = "${config.home.homeDirectory}/.local/state/colima.log";
|
||||||
defaultText = lib.literalExpression "\${config.home.homeDirectory}/.local/state/colima.log";
|
defaultText = lib.literalExpression "\${config.home.homeDirectory}/.local/state/colima.log";
|
||||||
description = "Combined stdout and stderr log file for the Colima service.";
|
description = "Combined stdout and stderr log file for the Colima service.";
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
type = lib.yamlFormat.type;
|
type = yamlFormat.type;
|
||||||
default = { };
|
default = { };
|
||||||
description = "Colima configuration settings, see <https://github.com/abiosoft/colima/blob/main/embedded/defaults/colima.yaml> or run `colima template`.";
|
description = "Colima configuration settings, see <https://github.com/abiosoft/colima/blob/main/embedded/defaults/colima.yaml> or run `colima template`.";
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
|
|
@ -93,14 +91,14 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.file.".colima/default/colima.yaml" = {
|
home.file.".colima/default/colima.yaml" = lib.mkIf (cfg.settings != { }) {
|
||||||
source = yamlFormat.generate "colima.yaml" cfg.settings;
|
source = yamlFormat.generate "colima.yaml" cfg.settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.docker-cli.contexts = mkIf cfg.addDockerContext {
|
programs.docker-cli.contexts = lib.mkIf cfg.addDockerContext {
|
||||||
colima = {
|
colima = {
|
||||||
Metadata = {
|
Metadata = {
|
||||||
Description = "Colima container runtime";
|
Description = "Colima container runtime";
|
||||||
|
|
@ -109,9 +107,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.docker-cli.settings.currentContext = mkIf cfg.useAsDefaultContext "colima";
|
programs.docker-cli.settings.currentContext = lib.mkIf cfg.useAsDefaultContext "colima";
|
||||||
|
|
||||||
launchd.agents.colima = mkIf pkgs.stdenv.isDarwin {
|
launchd.agents.colima = lib.mkIf pkgs.stdenv.isDarwin {
|
||||||
enable = true;
|
enable = true;
|
||||||
config = {
|
config = {
|
||||||
ProgramArguments = [
|
ProgramArguments = [
|
||||||
|
|
@ -128,7 +126,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.services.colima = mkIf pkgs.stdenv.isLinux {
|
systemd.user.services.colima = lib.mkIf pkgs.stdenv.isLinux {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Colima container runtime";
|
Description = "Colima container runtime";
|
||||||
After = [ "network-online.target" ];
|
After = [ "network-online.target" ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue