From 8ec7a6d539d02c9891260fc145bd4e40bdfc87e1 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Sat, 17 Oct 2026 17:48:26 +0200 Subject: [PATCH] Pin source-built AeroSpace fork with left Option bindings --- docs/README.md | 41 ++++ flake.lock | 18 ++ flake.nix | 10 + hosts/thegeneralist-mbp/aerospace.nix | 184 +++++++++--------- nixpkgs-overlay/aerospace/default.nix | 166 ++++++++++++++++ .../aerospace/dependency-hashes.nix | 7 + nixpkgs-overlay/aerospace/swift-toolchain.nix | 45 +++++ 7 files changed, 384 insertions(+), 87 deletions(-) create mode 100644 nixpkgs-overlay/aerospace/default.nix create mode 100644 nixpkgs-overlay/aerospace/dependency-hashes.nix create mode 100644 nixpkgs-overlay/aerospace/swift-toolchain.nix diff --git a/docs/README.md b/docs/README.md index dc1d1dc..b54b82e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -117,6 +117,47 @@ Hosts are automatically categorized based on naming conventions: - Names ending with `mbp` or containing `central-mbp` → Darwin - All others → NixOS +### Pinned AeroSpace fork + +`thegeneralist-mbp` builds [N1ark/AeroSpace at `d720311`](https://github.com/N1ark/AeroSpace/commit/d720311090f5922c10c5d9bfb62cbc7d8120e9fc) +from source for left/right modifier support. All Option-based bindings use `lalt`, +leaving right Option available for typing. Other modifiers and commands are unchanged. +Config version 2 explicitly lists persistent workspaces, preserving the workspace +set that version 1 inferred from the bindings. + +The build is defined in `nixpkgs-overlay/aerospace/`: + +- `aerospace-src` in `flake.nix` and `flake.lock` pins the complete source revision, including its prerequisite commits. +- `swift-toolchain.nix` pins the official Swift **6.4.0** installer and its hash, matching the source's `.swift-version`. +- The source's `Package.resolved` supplies Swift dependency versions/revisions; `dependency-hashes.nix` fixes their archive hashes. +- The existing nixpkgs lock pins Apple SDK **26.0**, the linker, native libraries, documentation/completion tools, and signer. +- Both executables are release builds from the fork. Only compiled icon assets are reused from nixpkgs' pinned official AeroSpace release. +- The app bundle is ad-hoc signed without a developer certificate or host keychain. No manually built artifact or installed Xcode is needed. + +Build the package without activating it: + +```bash +nix --extra-experimental-features pipe-operators build .#aerospace --no-link +``` + +Apply it through the existing Darwin service: + +```bash +sudo darwin-rebuild switch --flake .#thegeneralist-mbp \ + --option extra-experimental-features pipe-operators +``` + +Restart AeroSpace after updating if the CLI reports a client/server protocol mismatch: +the fork's CLI must be used with its matching app. macOS Accessibility approval +remains an OS-level action; a changed ad-hoc signature may require re-granting it. +Sided shortcuts do not work while Secure Input is enabled, including in password fields. +`lalt` matches left Option alone, not both Option keys held together. + +To update the fork, change the full commit in `inputs.aerospace-src.url`, then run +`nix flake update aerospace-src`. Review `Package.resolved` and `.swift-version` at +the new revision and update the dependency/toolchain hashes when they change. +The source stays pinned during ordinary `nix flake update` operations. + ## Module System ### Common Modules diff --git a/flake.lock b/flake.lock index 1f5caa6..b398627 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "aerospace-src": { + "flake": false, + "locked": { + "lastModified": 1791045489, + "narHash": "sha256-y7k81pR6/zsF32tHnhftAeALRHrOkfycB9U8vRO00wM=", + "owner": "N1ark", + "repo": "AeroSpace", + "rev": "d720311090f5922c10c5d9bfb62cbc7d8120e9fc", + "type": "github" + }, + "original": { + "owner": "N1ark", + "repo": "AeroSpace", + "rev": "d720311090f5922c10c5d9bfb62cbc7d8120e9fc", + "type": "github" + } + }, "agenix": { "inputs": { "darwin": [ @@ -507,6 +524,7 @@ }, "root": { "inputs": { + "aerospace-src": "aerospace-src", "agenix": "agenix", "fenix": "fenix", "ghostty": "ghostty", diff --git a/flake.nix b/flake.nix index dacc6ad..381c498 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + aerospace-src = { + url = "github:N1ark/AeroSpace/d720311090f5922c10c5d9bfb62cbc7d8120e9fc"; + flake = false; + }; + nix-homebrew.url = "github:zhaofengli/nix-homebrew"; homebrew-core = { url = "github:homebrew/homebrew-core"; @@ -92,6 +97,11 @@ # Darwin configurations for macOS hosts darwinConfigurations = hostConfigs.darwin or { }; + packages.aarch64-darwin.aerospace = + nixpkgs.legacyPackages.aarch64-darwin.callPackage ./nixpkgs-overlay/aerospace { + src = inputs.aerospace-src; + }; + # Development shells devShells = lib.genAttrs [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ] ( system: diff --git a/hosts/thegeneralist-mbp/aerospace.nix b/hosts/thegeneralist-mbp/aerospace.nix index 23576ff..8be0061 100644 --- a/hosts/thegeneralist-mbp/aerospace.nix +++ b/hosts/thegeneralist-mbp/aerospace.nix @@ -1,11 +1,21 @@ +{ inputs, pkgs, ... }: + { system.primaryUser = "thegeneralist"; - # TODO: explore this. - # Stuff below is temporary because MacOS' default window management is terrible. + # Left Option drives AeroSpace; right Option remains available for typing. services.aerospace = { enable = true; + package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.aerospace; settings = { + config-version = 2; + # Keep the workspaces that version 1 inferred from the bindings. + persistent-workspaces = [ + "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" + "A" "B" "C" "D" "E" "F" "G" "I" "M" "N" "O" + "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" + ]; + # Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization enable-normalization-flatten-containers = true; enable-normalization-opposite-orientation-for-nested-containers = true; @@ -80,14 +90,14 @@ # keypadMinus, keypadMultiply, keypadPlus # - Arrows. left, down, up, right - # All possible modifiers: cmd, alt, ctrl, shift + # Modifiers: cmd, alt, ctrl, shift; prefix l/r to restrict a side. # All possible commands: https://nikitabobko.github.io/AeroSpace/commands # See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget - # You can uncomment the following lines to open up terminal with alt + enter shortcut + # You can uncomment the following lines to open a terminal with left Option + Enter # (like in i3) - # alt-enter = '''exec-and-forget osascript -e ' + # lalt-enter = '''exec-and-forget osascript -e ' # tell application "Terminal" # do script # activate @@ -95,99 +105,99 @@ # ''' # See: https://nikitabobko.github.io/AeroSpace/commands#layout - alt-slash = "layout tiles horizontal vertical"; - alt-comma = "layout accordion horizontal vertical"; + lalt-slash = "layout tiles horizontal vertical"; + lalt-comma = "layout accordion horizontal vertical"; # See: https://nikitabobko.github.io/AeroSpace/commands#focus - alt-h = "focus left"; - alt-j = "focus down"; - alt-k = "focus up"; - alt-l = "focus right"; + lalt-h = "focus left"; + lalt-j = "focus down"; + lalt-k = "focus up"; + lalt-l = "focus right"; # See: https://nikitabobko.github.io/AeroSpace/commands#move - alt-shift-h = "move left"; - alt-shift-j = "move down"; - alt-shift-k = "move up"; - alt-shift-l = "move right"; + lalt-shift-h = "move left"; + lalt-shift-j = "move down"; + lalt-shift-k = "move up"; + lalt-shift-l = "move right"; # See: https://nikitabobko.github.io/AeroSpace/commands#resize - alt-minus = "resize smart -50"; - alt-equal = "resize smart +50"; + lalt-minus = "resize smart -50"; + lalt-equal = "resize smart +50"; # See: https://nikitabobko.github.io/AeroSpace/commands#workspace - alt-0 = "workspace 10"; - alt-1 = "workspace 1"; - alt-2 = "workspace 2"; - alt-3 = "workspace 3"; - alt-4 = "workspace 4"; - alt-5 = "workspace 5"; - alt-6 = "workspace 6"; - alt-7 = "workspace 7"; - alt-8 = "workspace 8"; - alt-9 = "workspace 9"; - alt-a = "workspace A"; # In your config, you can drop workspace bindings that you don't need - alt-b = "workspace B"; - alt-c = "workspace C"; - alt-d = "workspace D"; - alt-e = "workspace E"; - alt-f = "workspace F"; - alt-g = "workspace G"; - alt-i = "workspace I"; - alt-m = "workspace M"; - alt-n = "workspace N"; - alt-o = "workspace O"; - alt-p = "workspace P"; - alt-q = "workspace Q"; - alt-r = "workspace R"; - alt-s = "workspace S"; - alt-t = "workspace T"; - alt-u = "workspace U"; - alt-v = "workspace V"; - alt-w = "workspace W"; - alt-x = "workspace X"; - alt-y = "workspace Y"; - alt-z = "workspace Z"; + lalt-0 = "workspace 10"; + lalt-1 = "workspace 1"; + lalt-2 = "workspace 2"; + lalt-3 = "workspace 3"; + lalt-4 = "workspace 4"; + lalt-5 = "workspace 5"; + lalt-6 = "workspace 6"; + lalt-7 = "workspace 7"; + lalt-8 = "workspace 8"; + lalt-9 = "workspace 9"; + lalt-a = "workspace A"; # In your config, you can drop workspace bindings that you don't need + lalt-b = "workspace B"; + lalt-c = "workspace C"; + lalt-d = "workspace D"; + lalt-e = "workspace E"; + lalt-f = "workspace F"; + lalt-g = "workspace G"; + lalt-i = "workspace I"; + lalt-m = "workspace M"; + lalt-n = "workspace N"; + lalt-o = "workspace O"; + lalt-p = "workspace P"; + lalt-q = "workspace Q"; + lalt-r = "workspace R"; + lalt-s = "workspace S"; + lalt-t = "workspace T"; + lalt-u = "workspace U"; + lalt-v = "workspace V"; + lalt-w = "workspace W"; + lalt-x = "workspace X"; + lalt-y = "workspace Y"; + lalt-z = "workspace Z"; # See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace - alt-shift-1 = "move-node-to-workspace 1"; - alt-shift-2 = "move-node-to-workspace 2"; - alt-shift-3 = "move-node-to-workspace 3"; - alt-shift-4 = "move-node-to-workspace 4"; - alt-shift-5 = "move-node-to-workspace 5"; - alt-shift-6 = "move-node-to-workspace 6"; - alt-shift-7 = "move-node-to-workspace 7"; - alt-shift-8 = "move-node-to-workspace 8"; - alt-shift-9 = "move-node-to-workspace 9"; - alt-shift-a = "move-node-to-workspace A"; - alt-shift-b = "move-node-to-workspace B"; - alt-shift-c = "move-node-to-workspace C"; - alt-shift-d = "move-node-to-workspace D"; - alt-shift-e = "move-node-to-workspace E"; - alt-shift-f = "move-node-to-workspace F"; - alt-shift-g = "move-node-to-workspace G"; - alt-shift-i = "move-node-to-workspace I"; - alt-shift-m = "move-node-to-workspace M"; - alt-shift-n = "move-node-to-workspace N"; - alt-shift-o = "move-node-to-workspace O"; - alt-shift-p = "move-node-to-workspace P"; - alt-shift-q = "move-node-to-workspace Q"; - alt-shift-r = "move-node-to-workspace R"; - alt-shift-s = "move-node-to-workspace S"; - alt-shift-t = "move-node-to-workspace T"; - alt-shift-u = "move-node-to-workspace U"; - alt-shift-v = "move-node-to-workspace V"; - alt-shift-w = "move-node-to-workspace W"; - alt-shift-x = "move-node-to-workspace X"; - alt-shift-y = "move-node-to-workspace Y"; - alt-shift-z = "move-node-to-workspace Z"; + lalt-shift-1 = "move-node-to-workspace 1"; + lalt-shift-2 = "move-node-to-workspace 2"; + lalt-shift-3 = "move-node-to-workspace 3"; + lalt-shift-4 = "move-node-to-workspace 4"; + lalt-shift-5 = "move-node-to-workspace 5"; + lalt-shift-6 = "move-node-to-workspace 6"; + lalt-shift-7 = "move-node-to-workspace 7"; + lalt-shift-8 = "move-node-to-workspace 8"; + lalt-shift-9 = "move-node-to-workspace 9"; + lalt-shift-a = "move-node-to-workspace A"; + lalt-shift-b = "move-node-to-workspace B"; + lalt-shift-c = "move-node-to-workspace C"; + lalt-shift-d = "move-node-to-workspace D"; + lalt-shift-e = "move-node-to-workspace E"; + lalt-shift-f = "move-node-to-workspace F"; + lalt-shift-g = "move-node-to-workspace G"; + lalt-shift-i = "move-node-to-workspace I"; + lalt-shift-m = "move-node-to-workspace M"; + lalt-shift-n = "move-node-to-workspace N"; + lalt-shift-o = "move-node-to-workspace O"; + lalt-shift-p = "move-node-to-workspace P"; + lalt-shift-q = "move-node-to-workspace Q"; + lalt-shift-r = "move-node-to-workspace R"; + lalt-shift-s = "move-node-to-workspace S"; + lalt-shift-t = "move-node-to-workspace T"; + lalt-shift-u = "move-node-to-workspace U"; + lalt-shift-v = "move-node-to-workspace V"; + lalt-shift-w = "move-node-to-workspace W"; + lalt-shift-x = "move-node-to-workspace X"; + lalt-shift-y = "move-node-to-workspace Y"; + lalt-shift-z = "move-node-to-workspace Z"; # See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth - alt-tab = "workspace-back-and-forth"; + lalt-tab = "workspace-back-and-forth"; # See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor - alt-shift-tab = "move-workspace-to-monitor --wrap-around next"; + lalt-shift-tab = "move-workspace-to-monitor --wrap-around next"; # See: https://nikitabobko.github.io/AeroSpace/commands#mode - alt-shift-semicolon = "mode service"; + lalt-shift-semicolon = "mode service"; }; # 'service' binding mode declaration. @@ -201,10 +211,10 @@ # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 #s = ['layout sticky tiling', 'mode main'] - alt-shift-h = [ "join-with left" "mode main" ]; - alt-shift-j = [ "join-with down" "mode main" ]; - alt-shift-k = [ "join-with up" "mode main" ]; - alt-shift-l = [ "join-with right" "mode main" ]; + lalt-shift-h = [ "join-with left" "mode main" ]; + lalt-shift-j = [ "join-with down" "mode main" ]; + lalt-shift-k = [ "join-with up" "mode main" ]; + lalt-shift-l = [ "join-with right" "mode main" ]; down = "volume down"; up = "volume up"; diff --git a/nixpkgs-overlay/aerospace/default.nix b/nixpkgs-overlay/aerospace/default.nix new file mode 100644 index 0000000..aba3144 --- /dev/null +++ b/nixpkgs-overlay/aerospace/default.nix @@ -0,0 +1,166 @@ +{ + lib, + stdenv, + callPackage, + fetchFromGitHub, + apple-sdk_26, + aerospace, + asciidoctor, + complgen, + installShellFiles, + darwin, + rcodesign, + libcxx, + cups, + src, +}: +let + swift = callPackage ./swift-toolchain.nix { }; + pins = (builtins.fromJSON (builtins.readFile "${src}/Package.resolved")).pins; + hashes = import ./dependency-hashes.nix; + dependencies = map (pin: { + inherit (pin) identity; + source = fetchFromGitHub { + owner = builtins.elemAt (lib.splitString "/" pin.location) 3; + repo = lib.removeSuffix ".git" (lib.last (lib.splitString "/" pin.location)); + rev = pin.state.revision; + hash = hashes.${pin.identity}; + name = pin.identity; + }; + }) pins; + version = "0-unstable-${builtins.substring 0 8 src.lastModifiedDate}-${builtins.substring 0 7 src.rev}"; +in +stdenv.mkDerivation { + pname = "aerospace"; + inherit version src; + + nativeBuildInputs = [ swift asciidoctor complgen installShellFiles rcodesign ]; + # nixpkgs removes these system-library stubs from its Apple SDK. + buildInputs = [ apple-sdk_26 libcxx (lib.getLib cups) ]; + strictDeps = true; + dontConfigure = true; + + postPatch = '' + # Use the exact Package.resolved revisions, without SwiftPM network access. + mkdir -p .deps + ${lib.concatMapStringsSep "\n" (dep: '' + cp -R ${dep.source} .deps/${dep.identity} + chmod -R u+w .deps/${dep.identity} + '') dependencies} + substituteInPlace Package.swift \ + --replace-fail '.package(url: "https://github.com/InerziaSoft/ISSoundAdditions.git", exact: "2.0.1")' '.package(path: ".deps/issoundadditions")' \ + --replace-fail '.package(url: "https://github.com/dduan/TOMLDecoder", exact: "0.4.4")' '.package(path: ".deps/tomldecoder")' \ + --replace-fail '.package(url: "https://github.com/apple/swift-collections.git", exact: "1.3.0")' '.package(path: ".deps/swift-collections")' \ + --replace-fail '.package(url: "https://github.com/soffes/HotKey.git", exact: "0.2.1")' '.package(path: ".deps/hotkey")' + + # Upstream's generators use BSD sed and bootstrap tools from the network. + # Keep the generators, but use Nix's tools and skip their bootstrap setup. + substituteInPlace generate.sh --replace-fail ${lib.escapeShellArg "sed -i ''"} "sed -i" + substituteInPlace generate.sh script/generate-cmd-help.sh \ + --replace-fail 'source ./script/setup.sh' 'set -euo pipefail' + patchShebangs generate.sh script/generate-cmd-help.sh + bash ./generate.sh --ignore-xcodeproj --build-version ${lib.escapeShellArg version} + cat > Sources/Common/gitHashGenerated.swift <<'EOF' + public let gitHash = "${src.rev}" + public let gitShortHash = "${builtins.substring 0 7 src.rev}" + EOF + ''; + + buildPhase = '' + runHook preBuild + export HOME="$TMPDIR/home" + mkdir -p "$HOME" + export CFFIXED_USER_HOME="$HOME" + export MACOSX_DEPLOYMENT_TARGET=13.0 + export SDKROOT=${apple-sdk_26.sdkroot} + export SWIFT_EXEC=${swift}/usr/bin/swiftc + export LIBTOOL=${darwin.cctools}/bin/libtool + export CLANG_MODULE_CACHE_PATH="$TMPDIR/clang-module-cache" + export SWIFTPM_MODULECACHE_OVERRIDE="$TMPDIR/swift-module-cache" + # SwiftPM otherwise probes /usr/bin/xcrun for the manifest library's minos. + # The pinned libPackageDescription.dylib targets macOS 14; the app targets 13. + swiftFlags=( + --configuration release --disable-sandbox + --sdk "$SDKROOT" --jobs "$NIX_BUILD_CORES" + -Xbuild-tools-swiftc -target -Xbuild-tools-swiftc arm64-apple-macosx14.0 + -Xlinker -L${lib.getLib libcxx}/lib + -Xlinker -L${lib.getLib cups}/lib + ) + swift build "''${swiftFlags[@]}" --product aerospace + swift build "''${swiftFlags[@]}" --product AeroSpaceApp + binPath="$(swift build "''${swiftFlags[@]}" --show-bin-path)" + + asciidoctor -b manpage -D .man docs/aerospace*.adoc + mkdir -p .shell-completion + complgen --zsh .shell-completion/_aerospace grammar/commands-bnf-grammar.txt + complgen --fish .shell-completion/aerospace.fish grammar/commands-bnf-grammar.txt + complgen --bash .shell-completion/aerospace.bash grammar/commands-bnf-grammar.txt + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + app="$out/Applications/AeroSpace.app" + mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" "$out/bin" + install -m755 "$binPath/AeroSpaceApp" "$app/Contents/MacOS/AeroSpace" + install -m755 "$binPath/aerospace" "$out/bin/aerospace" + + # Only the precompiled artwork comes from nixpkgs' pinned official release. + # Both executables and the default config are built from the fork above. + cp ${aerospace}/Applications/AeroSpace.app/Contents/Resources/{AppIcon.icns,Assets.car} "$app/Contents/Resources/" + cp docs/config-examples/default-config.toml "$app/Contents/Resources/" + cat > "$app/Contents/Info.plist" <<'EOF' + + + + CFBundleDevelopmentRegionen + CFBundleExecutableAeroSpace + CFBundleIdentifierbobko.aerospace + CFBundleNameAeroSpace + CFBundlePackageTypeAPPL + CFBundleInfoDictionaryVersion6.0 + CFBundleShortVersionString${version} + CFBundleIconFileAppIcon + CFBundleIconNameAppIcon + LSMinimumSystemVersion13.0 + LSUIElement + + EOF + printf APPL'????' > "$app/Contents/PkgInfo" + installManPage .man/*.1 + installShellCompletion --cmd aerospace \ + --bash .shell-completion/aerospace.bash \ + --fish .shell-completion/aerospace.fish \ + --zsh .shell-completion/_aerospace + mkdir -p "$out/share/doc/aerospace" + cp LICENSE.txt "$out/share/doc/aerospace/" + cp -R legal "$out/share/doc/aerospace/" + runHook postInstall + ''; + + # Sign after fixups; no developer certificate or host keychain is needed. + postFixup = '' + # SwiftBuild embeds build-only compatibility paths. Runtime libraries use + # macOS or Nix install names; don't retain the compiler and SDK at runtime. + for binary in "$out/bin/aerospace" "$out/Applications/AeroSpace.app/Contents/MacOS/AeroSpace"; do + ${darwin.cctools}/bin/install_name_tool \ + -delete_rpath ${swift}/usr/lib/swift-6.2/macosx \ + -delete_rpath ${apple-sdk_26}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-6.2/macosx \ + "$binary" + done + rcodesign sign --config-file /dev/null --timestamp-url none \ + --binary-identifier aerospace "$out/bin/aerospace" + rcodesign sign --config-file /dev/null --timestamp-url none \ + --entitlements-xml-file ${src}/resources/AeroSpace.entitlements \ + "$out/Applications/AeroSpace.app" + ''; + + disallowedReferences = [ swift apple-sdk_26 ]; + + meta = aerospace.meta // { + homepage = "https://github.com/N1ark/AeroSpace"; + description = "AeroSpace with left/right modifier bindings"; + platforms = [ "aarch64-darwin" ]; + sourceProvenance = with lib.sourceTypes; [ fromSource binaryNativeCode ]; + }; +} diff --git a/nixpkgs-overlay/aerospace/dependency-hashes.nix b/nixpkgs-overlay/aerospace/dependency-hashes.nix new file mode 100644 index 0000000..e290907 --- /dev/null +++ b/nixpkgs-overlay/aerospace/dependency-hashes.nix @@ -0,0 +1,7 @@ +# Revisions and versions come from the pinned AeroSpace source's Package.resolved. +{ + hotkey = "sha256-t6HExQe+yXa951inZHfOILNsDrcFxNxPmrBhKtmL6eA="; + issoundadditions = "sha256-tCv5XtyMOq0ZOeNPaWXryTg57KsZCpyisc3NQziIQs0="; + swift-collections = "sha256-Bhfmf02JbmEdM1TFdM8UGxlouR8kr61WlU1uI2v67v8="; + tomldecoder = "sha256-YOR8nAp89zJOk2ZkmISfdzYJm6euuNrTJmOHcfpptco="; +} diff --git a/nixpkgs-overlay/aerospace/swift-toolchain.nix b/nixpkgs-overlay/aerospace/swift-toolchain.nix new file mode 100644 index 0000000..a81ce6c --- /dev/null +++ b/nixpkgs-overlay/aerospace/swift-toolchain.nix @@ -0,0 +1,45 @@ +{ + lib, + stdenvNoCC, + fetchurl, + xar, + cpio, + bintools, +}: +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "aerospace-swift-toolchain"; + # Matches .swift-version in the pinned AeroSpace source. + version = "6.4.0"; + + src = fetchurl { + url = "https://download.swift.org/swift-${finalAttrs.version}-release/xcode/swift-${finalAttrs.version}-RELEASE/swift-${finalAttrs.version}-RELEASE-osx.pkg"; + hash = "sha256-j9AxhbmP4n9UpUYxwkSd7PddW0Zs6ONKu9QUFBBjxqo="; + }; + + nativeBuildInputs = [ xar cpio ]; + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + # Preserve the toolchain's layout, relative dylib paths, and existing signatures. + dontFixup = true; + + installPhase = '' + runHook preInstall + xar -xf "$src" swift-${finalAttrs.version}-RELEASE-osx-package.pkg/Payload + mkdir -p "$out" + cd "$out" + gzip -dc "$NIX_BUILD_TOP/swift-${finalAttrs.version}-RELEASE-osx-package.pkg/Payload" | cpio -idm --quiet + # Use the pinned linker without Nix's C-driver default SDK flags. + ln -s ${bintools.bintools}/bin/ld usr/bin/ld + ln -s usr/bin bin + runHook postInstall + ''; + + meta = { + description = "Pinned Swift toolchain for building the AeroSpace fork"; + homepage = "https://www.swift.org/download/"; + license = lib.licenses.asl20; + platforms = [ "aarch64-darwin" ]; + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + }; +})