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

MacOS Runner Nix Integration for Platform-Specific Build #1

Open
CMCDragonkai opened this issue May 21, 2022 · 2 comments
Open

MacOS Runner Nix Integration for Platform-Specific Build #1

CMCDragonkai opened this issue May 21, 2022 · 2 comments
Labels
development Standard development r&d:polykey:supporting activity Supporting core activity

Comments

@CMCDragonkai
Copy link
Member

CMCDragonkai commented May 21, 2022

Specification

The Homebrew system that is currently being used to install our packages. It is taking quite some time even with all the caching.

This is partly because the node version we want and the homebrew formula that is available isn't already available on the macos VM.

Homebrew ends up installing alot of other dependencies, and although it's not that much, it's quite a bit slower than Nix.

So that means a job that takes 3 minutes on our Linux runner, is now taking 23 minutes on our macos runner on gitlab.

Now I'm tried installing Nix on macos on the M1 mac mini. There are some notes to consider.

  1. The installation process requires sudo, thankfully both Gitlab and Github have passwordless sudo for their mac runers.
  2. Therefore sudo sh <(curl -L https://nixos.org/nix/install) should be sufficient to ensure an unattended installation. However this is not confirmed (it has to do a bunch of disk manipulation too to get /nix/store up and running). Otherwise look at the installation script to see what env variables or flags must be set: https://github.com/NixOS/nix/blob/master/scripts/install-darwin-multi-user.sh
  3. The installation changes /etc/bashrc and /etc/zshrc. In order to ensure you can get everything Nix provides on-path, you need to source their script. . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'.
  4. While homebrew is slow. Nix has to install alot of things to get setup on our project, and not everything is compatible. On my first setup of TypeScript-Demo-Lib, I had to download 250 MiB worth of packages, and 1 GiB unpacked. Even then things like multiStdenv isn't compatible, and node2nix currently has a derivation that is limited to x86_64-linux. I'm pretty sure node2nix is incorrect, the derivation has no requirement on x86_64-linux (https://github.com/svanderburg/node2nix/blob/68f5735f9a56737e3fedceb182705985e3ab8799/nix/node-env.nix#L212). There's also some potential configuration required in ~/.config/nixpkgs/config.nix to allow packages that is considered "deprecated".

Since it has to do so much and also compile packages, I'm not confident that using Nix will be appreciably faster than homebrew. It may be marginally faster since with our private Nix cache, any compiled packages will end up there.

Trying to ensure compatibility between the darwin-arm64 and linux-x64 is going to be difficult, and it most likely will require us to replace node2nix with our own nix system that understands javascript/typescript properly.

BTW, it turns out that the nix installation on MacOS doesn't use NIX_PATH. This is because the nix on mac is not a "nixos", it's just a Mac with the nix program.

It seems that the best solution would to have our own Mac runners with the appropriate setup already done. We can contribute to this project: https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/macstadium/orka/-/tree/main to get Nix into it. This means continuing to use gitlab runners within the gitlab platform.

Even GitHub actions would have similar problems.

At any-case, I was not successful in running a nix-shell atm due to node2nix.

Additional context

Tasks

  1. ...
  2. ...
  3. ...
@CMCDragonkai CMCDragonkai added the development Standard development label May 21, 2022
@CMCDragonkai CMCDragonkai changed the title MacOS Nix Integration MacOS Runner Nix Integration for Platform-Specific Build May 21, 2022
@CMCDragonkai CMCDragonkai added r&d:polykey:core activity 1 Secret Vault Sharing and Secret History Management r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy r&d:polykey:core activity 2 Cross Platform Cryptography for JavaScript Platforms r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices and removed r&d:polykey:core activity 1 Secret Vault Sharing and Secret History Management r&d:polykey:core activity 3 Peer to Peer Federated Hierarchy r&d:polykey:core activity 2 Cross Platform Cryptography for JavaScript Platforms r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices labels Jul 23, 2022
@CMCDragonkai CMCDragonkai added the r&d:polykey:supporting activity Supporting core activity label Jul 10, 2023
@CMCDragonkai
Copy link
Member Author

@CMCDragonkai
Copy link
Member Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development r&d:polykey:supporting activity Supporting core activity
Development

No branches or pull requests

1 participant