-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
colima: init service module #7913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
4f94f6e to
f6df623
Compare
4fde36c to
e8a705a
Compare
|
Now that my other PR is merged, this one is ready to be considered. |
|
@khaneliman sorry to ping you! |
There was a problem hiding this 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
modules/services/colima.nix
Outdated
| config = mkIf cfg.enable { | ||
| home.packages = [ cfg.package ]; | ||
|
|
||
| home.file.".colima/default/colima.yaml" = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
modules/services/colima.nix
Outdated
| settings = mkOption { | ||
| type = types.submodule { | ||
| freeformType = yamlFormat.type; | ||
| options = { |
There was a problem hiding this comment.
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.
modules/services/colima.nix
Outdated
| 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" | ||
| ); |
There was a problem hiding this comment.
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.
modules/services/colima.nix
Outdated
| enable = true; | ||
| config = { | ||
| ProgramArguments = [ | ||
| "${cfg.package}/bin/colima" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "${cfg.package}/bin/colima" | |
| "${lib.getExe cfg.package}" |
modules/services/colima.nix
Outdated
| Wants = [ "network-online.target" ]; | ||
| }; | ||
| Service = { | ||
| ExecStart = "${cfg.package}/bin/colima start -f --save-config=false"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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"; |
There was a problem hiding this comment.
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
51539bb to
1d6e90a
Compare
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:
Checklist
Change is backwards compatible.
Code formatted with
nix fmtornix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.Code tested through
nix run .#tests -- test-allornix-shell --pure tests -A run.all.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
If this PR adds an exciting new feature or contains a breaking change.