diff --git a/nix/container.nix b/nix/container.nix index b6de2cc42..739e2b54a 100644 --- a/nix/container.nix +++ b/nix/container.nix @@ -33,6 +33,7 @@ in boot.isContainer = true; + nixpkgs.system = mkIf (! any (platform: platform == builtins.currentSystem) platforms.linux) (mkOverride 900 "x86_64-linux"); }; } diff --git a/nixops/backends/container.py b/nixops/backends/container.py index f54eaa4f5..c25bc3754 100644 --- a/nixops/backends/container.py +++ b/nixops/backends/container.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from nixops.backends import MachineDefinition, MachineState +from nixops.nix_expr import py2nix import nixops.util import nixops.ssh_util import subprocess @@ -126,10 +127,14 @@ def create(self, defn, check, allow_reboot, allow_recreate): if self.vm_id is None: self.log("building initial configuration...") + eval_args = self.depl._eval_args(self.depl.nix_exprs) + eval_args['checkConfigurationOptions'] = False expr = " ".join([ '{ imports = [ ];', ' boot.isContainer = true;', ' networking.hostName = "{0}";'.format(self.name), + ' nixpkgs.system = let final = import {0};'.format(py2nix(eval_args, inline=True)), + ' in final.resources.machines.{0}.nixpkgs.system;'.format(self.name), ' users.extraUsers.root.openssh.authorizedKeys.keys = [ "{0}" ];'.format(self.client_public_key), '}']) diff --git a/nixops/deployment.py b/nixops/deployment.py index 5fa6fa845..01da42156 100644 --- a/nixops/deployment.py +++ b/nixops/deployment.py @@ -250,16 +250,26 @@ def _nix_path_flags(self): flags.extend(["-I", "nixops=" + self.expr_path]) return flags + def _eval_args(self, exprs): + args = {key: RawValue(val) for key, val in self.args.iteritems()} + exprs_ = [RawValue(x) if x[0] == '<' else x for x in exprs] + eval_args = { + 'networkExprs' : exprs_, + 'args' : args, + 'uuid' : self.uuid, + 'deploymentName' : self.name if self.name else "" + } + return eval_args + def _eval_flags(self, exprs): flags = self._nix_path_flags() - args = {key: RawValue(val) for key, val in self.args.iteritems()} - exprs_ = [RawValue(x) if x[0] == '<' else x for x in exprs] + args = self._eval_args(exprs) flags.extend( - ["--arg", "networkExprs", py2nix(exprs_, inline=True), - "--arg", "args", py2nix(args, inline=True), - "--argstr", "uuid", self.uuid, - "--argstr", "deploymentName", self.name if self.name else "", + ["--arg", "networkExprs", py2nix(args['networkExprs'], inline=True), + "--arg", "args", py2nix(args['args'], inline=True), + "--argstr", "uuid", args['uuid'], + "--argstr", "deploymentName", args['deploymentName'], ""]) return flags