在 Mac 上成为快乐的 Nixer

  • Pareto Security Linux Support and Automated Tests: Recently shipped Linux support and built automated tests by setting up different Virtual Machines with various distros and mis-configurations. Used NixOS Integration Tests for Debian, Ubuntu, Fedora and NixOS itself.

    • Nix natively on macOS: Installed Nix using the Determinate Systems installer as the official installer has no uninstall support. Found the Setting up Nix on macOS post helpful. Used nix-darwin to control macOS settings with a single file. Configured it on GitHub at zupo/dotfiles.
    • Linux Builder: As macOS is a different architecture than NixOS, used the Linux Builder provided by nix-darwin. Enabled it by adding nix.linux-builder.enable = true; to darwin-configuration.nix and verified it with sudo launchctl list org.nixos.linux-builder. Followed performance optimizations.
    • NixOS Tests on macOS: Installed and ran NixOS Integration Tests using the Linux Builder. Used Interactive Mode to debug when tests failed by building the test driver with nix -L build github:tfc/nixos-integration-test-example#default.driverInteractive and starting it with ./result/bin/nixos-test-driver --keep-vm-state. SSHed into the VMs for debugging. Read the extensive NixOS Integration Tests blog post.
    • Troubleshooting: When getting strange errors, tried upgrading to the latest nixpkgs, adding nix.linux-builder.ephemeral.enable = true, manually accepting SSH host keys after reinstalling nix-darwin, and checking if the test was using the correct pkgs..
    • NixOS in a Virtual Machine: Used UTM to run a full-fledged NixOS. Installed UTM and downloaded the 64-bit ARM Minimal ISO image. Followed NixOS manual steps for partitioning and installation. Configured SSH access by adding services.openssh.enable = true; and services.openssh.permitRootLogin = "yes"; to /etc/nixos/configuration.nix. Got the IP address with ifconfig and SSHed into the VM. Enabled Nix features for NixOS Tests and added nix.settings.experimental-features = [ "nix-command" "flakes" ]; to /etc/nixos/configuration.nix. Used nested virtualization for better performance on M3 CPU or newer Macs and Rosetta for x86 virtualization. Integrated VS Code with the VM by adding (fetchTarball "https://github.com/nix-community/nixos-vscode-server/tarball/master") to imports and installing the Remote - SSH extension. Fixed Could not start dynamically linked executable error by adding services.vscode-server.enableFHS = true;.
阅读 17
0 条评论