Skip to content

Conversation

@will-lol
Copy link
Contributor

@will-lol will-lol commented Oct 1, 2025

Description

Adds a colima service. This service will be useful to darwin users who would like to run containers on their computer. It is based on this PR in nix-darwin, but I determined it to be more practical to be in hm. This PR depends on my other PR that adds docker context support.

Colima also supports linux, but is far less commonly used. Still, I have built this hm module to support linux. I have tested it to the best of my abilities without access to a bare metal machine. If someone could give it a spin that would be amazing!

These changes will allow users of nix on darwin to:

  • Enable container support in a few lines of configuration
  • Easily have and switch between multiple docker hosts. This is particularly relevant as more options become available for containerisation on darwin (https://github.com/apple/containerization)

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

@will-lol will-lol force-pushed the colima branch 6 times, most recently from 4f94f6e to f6df623 Compare October 7, 2025 05:52
@will-lol will-lol force-pushed the colima branch 2 times, most recently from 4fde36c to e8a705a Compare October 14, 2025 21:47
@home-manager-ci home-manager-ci bot removed the request for review from FriedrichAltheide October 14, 2025 21:48
@will-lol
Copy link
Contributor Author

Now that my other PR is merged, this one is ready to be considered.
I still don't have access to a bare metal linux box to test this unfortunately! It would be amazing if someone could give this module a spin on linux.

@will-lol
Copy link
Contributor Author

@khaneliman sorry to ping you!
Do you or another maintainer have an opinion on this one?

@khaneliman khaneliman changed the title modules/services/colima: init colima: init service module Oct 18, 2025
Copy link
Collaborator

@khaneliman khaneliman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just initial thoughts/questions

config = mkIf cfg.enable {
home.packages = [ cfg.package ];

home.file.".colima/default/colima.yaml" = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
home.file.".colima/default/colima.yaml" = {
home.file.".colima/default/colima.yaml" = lib.mkIf (cfg.settings != {}) {

If someone doesn't customize it, we shouldn't generate a config.

settings = mkOption {
type = types.submodule {
freeformType = yamlFormat.type;
options = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather all these options be just an example config for the settings option and reference the upstream documentation on how to configure to reduce maintenance burden and possibility of inhibiting a user's config. We also have a lot of default configurations that might overwrite the default behavior of the application.

Comment on lines 267 to 274
services.colima.settings.mountType = mkDefault (
if pkgs.stdenv.isDarwin && cfg.settings.vmType == "vz" then
"virtiofs"
else if cfg.settings.vmType == "qemu" then
"9p"
else
"sshfs"
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels weird to have a freeform setting with a secret behavior for changing the settings option based on other configuration. I think it would be safer if we didn't have all the other options clouding the documentation for options if we limited the declared submodule options to null defaults with a note explaining what happens if you configure it.

enable = true;
config = {
ProgramArguments = [
"${cfg.package}/bin/colima"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"${cfg.package}/bin/colima"
"${lib.getExe cfg.package}"

Wants = [ "network-online.target" ];
};
Service = {
ExecStart = "${cfg.package}/bin/colima start -f --save-config=false";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ExecStart = "${cfg.package}/bin/colima start -f --save-config=false";
ExecStart = "${lib.getExe cfg.package} start -f --save-config=false";

];
KeepAlive = true;
RunAtLoad = true;
EnvironmentVariables.PATH = "${cfg.package}/bin:${pkgs.perl}/bin:${pkgs.docker}/bin:/usr/bin:/usr/sbin:/sbin";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkgs.perl and pkgs.docker should be overrideable through a xPackage option

@will-lol will-lol force-pushed the colima branch 2 times, most recently from 51539bb to 1d6e90a Compare October 19, 2025 05:07
@will-lol will-lol marked this pull request as draft October 19, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants