terraform-provider-nix icon indicating copy to clipboard operation
terraform-provider-nix copied to clipboard

Build dependencies

Open tomberek opened this issue 5 years ago • 2 comments

Found BuildHost, but I'm not sure how complete that is. My use case is deploying to AWS (working on a minimal example) with a team on both OSX and Linux. So probably want to do all building on the target, so I use a known ami to start the process, rather than a local build of the image. I'm not sure how much can be delegated to the build host.

tomberek avatar Aug 15 '19 05:08 tomberek

I have never tried cross deploying as I developed this with Linux exclusively.

I don't have any OSX machines so can't help you too much. This plugin uses nixos-rebuild directly, which may not be supported from OSX.

andrewchambers avatar Aug 15 '19 08:08 andrewchambers

While i cannot confirm yet if this works on OSX (I am Linux but my colleagues are OSX but we are all isolated WFH for the pandemic) however as I understand nix's cross compiling capabilities you should be able to build locally on osx and still deploy to a linux machine. The obvious issue is how to get nixos-rebuild on a mac. I have been using this in a shell.nix to create a package like nixpkgs does and add it to the buildInputs in my shell.

with <nixpkgs>;

let
    nixos-rebuild = let
      fallback = import <nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix>;
    in substituteAll {
      name = "nixos-rebuild";
      dir = "bin";
      isExecutable = true;
      src = <nixpkgs/nixos/modules/installer/tools/nixos-rebuild.sh>;
      nix = nix.out;
      nix_x86_64_linux = fallback.x86_64-linux;
      nix_i686_linux = fallback.i686-linux;
      path = makeBinPath [ jq ];
    };
in mkDerivation {
  buildInputs = [nixos-rebuild];
}

Nekroze avatar Mar 25 '20 00:03 Nekroze