Add support for deploying to a Mac (nix-darwin) #34

Closed
opened 2022-10-27 16:10:12 +00:00 by srid · 7 comments
srid commented 2022-10-27 16:10:12 +00:00 (Migrated from github.com)

I'd like the ability to deploy to a remote Mac machine (say, a Mac mini server) from another Mac machine (say, a Macbook). nixinate is currently hardcoded to deploy nixosConfigurations.foo using nixos-rebuild. To support macOS, we simply want to be able to deploy darwinConfigurations.foo using darwin-rebuild; everything else would more or less remain the same. Here's a demonstration of what this looks like without nixinate:

      apps.aarch64-darwin.deploy-macmini = {
        type = "app";
        program =
          let
            host = "user@192.52.31.40";
            machine = "myhost";
            pkgs = inputs.nixpkgs.legacyPackages.aarch64-darwin;
          in
          (pkgs.writeShellApplication {
            name = "deploy-to-mac";
            text = ''
              set -x
              nix copy ${self} --to ssh://${host}
              ssh -t ${host} "darwin-rebuild switch --flake ${self}#${machine}"
            '';
          }) + "/bin/deploy-to-mac";
      };
I'd like the ability to deploy to a remote Mac machine (say, a Mac mini server) from another Mac machine (say, a Macbook). nixinate is currently hardcoded to deploy `nixosConfigurations.foo` using `nixos-rebuild`. To support macOS, we simply want to be able to deploy `darwinConfigurations.foo` using `darwin-rebuild`; everything else would more or less remain the same. Here's a demonstration of what this looks like without nixinate: ```nix apps.aarch64-darwin.deploy-macmini = { type = "app"; program = let host = "user@192.52.31.40"; machine = "myhost"; pkgs = inputs.nixpkgs.legacyPackages.aarch64-darwin; in (pkgs.writeShellApplication { name = "deploy-to-mac"; text = '' set -x nix copy ${self} --to ssh://${host} ssh -t ${host} "darwin-rebuild switch --flake ${self}#${machine}" ''; }) + "/bin/deploy-to-mac"; }; ```
srid commented 2022-10-27 16:23:53 +00:00 (Migrated from github.com)

Better,

''
nix copy ${self} --to ssh://${host}
nix copy ${self.darwinConfigurations.${machine}.system} --to ssh://${host}
ssh -t ${host} "${self.darwinConfigurations.${machine}.system}/sw/bin/darwin-rebuild switch --flake ${self}#${machine}"
'';
Better, ```nix '' nix copy ${self} --to ssh://${host} nix copy ${self.darwinConfigurations.${machine}.system} --to ssh://${host} ssh -t ${host} "${self.darwinConfigurations.${machine}.system}/sw/bin/darwin-rebuild switch --flake ${self}#${machine}" ''; ```
MatthewCroughan commented 2022-10-27 17:27:51 +00:00 (Migrated from github.com)

Buy me a Mac, and I'll do it. I may remove macOS from the supported system until I own the hardware.

Avoid running nix copy multiple times. Anyone using password protected keys, such as a Yubikey, will have to type in their credentials once each time you perform a nix copy.

Buy me a Mac, and I'll do it. I may remove macOS from the supported system until I own the hardware. Avoid running `nix copy` multiple times. Anyone using password protected keys, such as a Yubikey, will have to type in their credentials once each time you perform a `nix copy`.
Fresheyeball commented 2022-11-28 18:18:16 +00:00 (Migrated from github.com)

@MatthewCroughan feel free to use the Mac in our data center

@MatthewCroughan feel free to use the Mac in our data center
MatthewCroughan commented 2022-11-28 18:25:29 +00:00 (Migrated from github.com)

@Fresheyeball Sorry. I cannot test or develop on a remote Mac, since purity cannot be guaranteed. I also would not have control over the HCI agent that runs on it. If I'm going to develop this at all, I need a real Mac locally. I can probably do x86_64-darwin in a VM myself though. What if I want to change the Base OS version in order to test it? I can't do that with the data center Mac. It is not sufficient.

@Fresheyeball Sorry. I cannot test or develop on a remote Mac, since purity cannot be guaranteed. I also would not have control over the HCI agent that runs on it. If I'm going to develop this at all, I need a real Mac locally. I can probably do x86_64-darwin in a VM myself though. What if I want to change the Base OS version in order to test it? I can't do that with the data center Mac. It is not sufficient.
Fresheyeball commented 2022-11-28 18:38:55 +00:00 (Migrated from github.com)

I think it's sufficient to get some support. Maybe not everything, but you are welcome to it regardless, and I do think it's enough for this one issue.

I think it's sufficient to get some support. Maybe not everything, but you are welcome to it regardless, and I do think it's enough for this one issue.
MatthewCroughan commented 2022-11-28 18:44:49 +00:00 (Migrated from github.com)

I won't add features that I can't test into Nixinate. See the full integration test I have for Nixinate here, I wouldn't be able to replicate this on Darwin. https://github.com/MatthewCroughan/nixinate/tree/master/tests

I won't add features that I can't test into Nixinate. See the full integration test I have for Nixinate here, I wouldn't be able to replicate this on Darwin. https://github.com/MatthewCroughan/nixinate/tree/master/tests

Closed due to fork migration, feel free to reopen.

Closed due to fork migration, feel free to reopen.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tristan/nixinate#34
No description provided.