Skip to content
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

systemd.nspawn: add definition #18320

Merged
merged 3 commits into from
Oct 8, 2016
Merged

systemd.nspawn: add definition #18320

merged 3 commits into from
Oct 8, 2016

Conversation

groxxda
Copy link
Contributor

@groxxda groxxda commented Sep 5, 2016

Motivation for this change

systemd-nspawn can be configured via .nspawn files. This PR adds a nixos module to manage these files.

In the end I want to simplify nixos-containers and make more use of upstream defaults, this is the first step but may be useful on its own.

CC @fpletz

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

this adds the option to manage systemd.nspawn files via
config.systemd.nspawn. The files are placed in "/etc/systemd/nspawn".

@mention-bot
Copy link

@groxxda, thanks for your PR! By analyzing the annotation information on this pull request, we identified @edolstra, @bjornfor and @offlinehacker to be potential reviewers


};

config = mkIf config.systemd.nspawn.enable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe config.systemd.nspawn.enable can be removed and this line replaced by something like mkIf (cfg.instances != {} || cfg.units != {}) like done in other in modules with similar a structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a clear improvement without drawbacks so I'll implement it

description = "Definition of systemd-nspawn configurations.";
};

systemd.nspawn.units = mkOption {
Copy link
Member

Choose a reason for hiding this comment

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

Probably it would be better to combine systemd.nspawn.instances and systemd.nspawn.units into a single option, with one attribute per machine. E.g. rather than

  systemd.nspawn.instances.webserver = { X };
  systemd.nspawn.units.webserver = { Y };

you would have

  systemd.nspawn.machines.webserver = { X; Y; };

this adds the option to manage systemd.nspawn files via
config.systemd.nspawn. The files are placed in "/etc/systemd/nspawn".
@fpletz fpletz merged commit ce7739a into NixOS:master Oct 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants