Skip to content

Instantly share code, notes, and snippets.

@zarelit
Forked from goodwillcoding/compile_patch.diff
Created May 1, 2018 12:23
Show Gist options
  • Save zarelit/4f76b19aaa2c9963b835bfc07b82b9bb to your computer and use it in GitHub Desktop.
Save zarelit/4f76b19aaa2c9963b835bfc07b82b9bb to your computer and use it in GitHub Desktop.

Revisions

  1. @goodwillcoding goodwillcoding revised this gist Sep 29, 2014. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions compile_patch.diff
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ index 86ed0f4..c52e9d3 100644
    # resources can be checked.
    def check(self):
    diff --git a/nixops/deployment.py b/nixops/deployment.py
    index b504577..7894c3a 100644
    index b504577..61128a6 100644
    --- a/nixops/deployment.py
    +++ b/nixops/deployment.py
    @@ -551,7 +551,7 @@ class Deployment(object):
    @@ -33,7 +33,7 @@ index b504577..7894c3a 100644
    for m2 in active_machines.itervalues():
    if hasattr(m2, 'public_host_key') and m2.public_host_key:
    # Using references to files in same tempdir for now, until NixOS has support
    @@ -627,6 +627,17 @@ class Deployment(object):
    @@ -627,10 +627,21 @@ class Deployment(object):

    names = map(lambda m: m.name, selected)

    @@ -51,3 +51,8 @@ index b504577..7894c3a 100644
    # If we're not running on Linux, then perform the build on the
    # target machines. FIXME: Also enable this if we're on 32-bit
    # and want to deploy to 64-bit.
    - if platform.system() != 'Linux' and os.environ.get('NIX_REMOTE') != 'daemon':
    + if build_remote == True and os.environ.get('NIX_REMOTE') != 'daemon':
    if os.environ.get('NIX_REMOTE_SYSTEMS') == None:
    remote_machines = []
    for m in sorted(selected, key=lambda m: m.index):
  2. @goodwillcoding goodwillcoding created this gist Sep 29, 2014.
    53 changes: 53 additions & 0 deletions compile_patch.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    diff --git a/nixops/backends/__init__.py b/nixops/backends/__init__.py
    index 86ed0f4..c52e9d3 100644
    --- a/nixops/backends/__init__.py
    +++ b/nixops/backends/__init__.py
    @@ -93,6 +93,17 @@ class MachineState(nixops.resources.ResourceState):
    except nixops.ssh_util.SSHCommandFailed:
    return None

    + def get_os_arch(self):
    + """Get the machine's OS archicture."""
    + try:
    + res = self.run_command("uname -m", capture_stdout=True, timeout=15).rstrip()
    + assert len(res) >= 3
    + return res
    + except nixops.ssh_util.SSHConnectionFailed:
    + return None
    + except nixops.ssh_util.SSHCommandFailed:
    + return None
    +
    # FIXME: Move this to ResourceState so that other kinds of
    # resources can be checked.
    def check(self):
    diff --git a/nixops/deployment.py b/nixops/deployment.py
    index b504577..7894c3a 100644
    --- a/nixops/deployment.py
    +++ b/nixops/deployment.py
    @@ -551,7 +551,7 @@ class Deployment(object):
    })


    - # Add SSH public host keys for all machines in network
    + # Add SSH public host keys for all machines in network
    for m2 in active_machines.itervalues():
    if hasattr(m2, 'public_host_key') and m2.public_host_key:
    # Using references to files in same tempdir for now, until NixOS has support
    @@ -627,6 +627,17 @@ class Deployment(object):

    names = map(lambda m: m.name, selected)

    + # get unique values for all of the possible arches (or None if)
    + # arch can not be retrieved
    + machine_arches = set(machine.get_os_arch() for machine in selected)
    + # if we could retrieve some of the target machine arches or if any
    + # targer machine's archs is different then the host machine then
    + # always build remove
    + build_remote = False
    + if len(machine_arches) > 1 or (platform.machine() not in machine_arches):
    + build_remote = True
    + self.logger.log("building everything on target machine(s)")
    +
    # If we're not running on Linux, then perform the build on the
    # target machines. FIXME: Also enable this if we're on 32-bit
    # and want to deploy to 64-bit.