From da29459c2dbacda5bf64178a38dada0a6fd78789 Mon Sep 17 00:00:00 2001 From: dz Date: Sun, 26 Jul 2026 18:51:18 -0300 Subject: [PATCH] Add Nix development shell with macOS 12 compatibility --- flake.lock | 44 ++++++++++++++++++++++++++++++++++++ flake.nix | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..a8a93f6a --- /dev/null +++ b/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1785002762, + "narHash": "sha256-Y0BbgB3BLLHEUK88g4oSp3DerIx7rCX0iwICKJcY7/c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f7a2e428f5d71c47a5a938a3c5ad7138bb291093", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-legacy": { + "locked": { + "lastModified": 1767313136, + "narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ac62194c3917d5f474c1a844b6fd6da2db95077d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-legacy": "nixpkgs-legacy" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..16477b5b --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + description = "Development shell for building IVPN Desktop on Apple Silicon"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + inputs.nixpkgs-legacy.url = "github:NixOS/nixpkgs/nixos-25.05"; # old libresolv needed by the macOS 12 SDK + + outputs = + { nixpkgs, nixpkgs-legacy, ... }: + let + # for now test on darwin only, can add linux too + system = "aarch64-darwin"; + pkgs = import nixpkgs { inherit system; }; + legacyPkgs = import nixpkgs-legacy { inherit system; }; + macosSdk = legacyPkgs.apple-sdk_12; + archTarget = { + aarch64-darwin = "arm64"; + }.${system}; + goToolchain = pkgs.go_1_26; + nodeToolchain = pkgs.nodejs_22; + + buildCli = pkgs.writeShellScriptBin "build-cli" ''exec ./cli/References/macOS/build.sh "$@"''; + buildDaemon = pkgs.writeShellScriptBin "build-daemon" ''exec ./daemon/References/macOS/scripts/build-all.sh -wifi "$@"''; + # Using nixpkgs#rcodesign + # requires an upstream change adding an explicit ad-hoc signing mode + # so skip for now until basic merged + buildApp = pkgs.writeShellScriptBin "build-app" ''exec ./ui/References/macOS/build.sh "$@"''; + + in + { + devShells.${system}.default = pkgs.mkShell { + env = { + ARCH_TARGET = archTarget; + IVPN_BUILD_SKIP_PROMPT = "1"; + }; + + shellHook = '' + # exact version as used by this repo + # no need to install xcode or xcode-select + export DEVELOPER_DIR="${macosSdk}" + export MACOSX_DEPLOYMENT_TARGET="12.0" + export SDKROOT="${macosSdk.sdkroot}" + export NIX_LDFLAGS="''${NIX_LDFLAGS//"-L${pkgs.darwin.libresolv}/lib"/"-L${legacyPkgs.darwin.libresolv}/lib"}" + ''; + + packages = with pkgs; [ + autoconf + automake + buildApp + buildCli + buildDaemon + cacert + cmake + curl + git + goToolchain + gnumake + libtool + ninja + nodeToolchain + pam + perl + pkg-config + ]; + }; + }; +}