swift: track version in a central sources.nix
This commit is contained in:
parent
0e08b082b8
commit
449e2f1b01
9 changed files with 87 additions and 129 deletions
|
@ -1,5 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, callPackage
|
||||
, cmake
|
||||
, coreutils
|
||||
, gnugrep
|
||||
|
@ -10,7 +11,6 @@
|
|||
, bintools
|
||||
, python3
|
||||
, git
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, makeWrapper
|
||||
, gnumake
|
||||
|
@ -43,43 +43,7 @@ let
|
|||
|
||||
inherit (stdenv) hostPlatform targetPlatform;
|
||||
|
||||
# The Swift toolchain script builds projects with separate repos. By convention, some of them share
|
||||
# the same version with the main Swift compiler project per release.
|
||||
version = "5.7";
|
||||
|
||||
fetchSwiftRelease = { repo, hash }:
|
||||
fetchFromGitHub {
|
||||
owner = "apple";
|
||||
inherit repo hash;
|
||||
rev = "swift-${version}-RELEASE";
|
||||
name = "${repo}-${version}-src";
|
||||
};
|
||||
|
||||
# Names in this set match the directory the source is unpacked to.
|
||||
sources = {
|
||||
cmark = fetchSwiftRelease {
|
||||
repo = "swift-cmark";
|
||||
hash = "sha256-f0BoTs4HYdx/aJ9HIGCWMalhl8PvClWD6R4QK3qSgAw=";
|
||||
};
|
||||
llvm-project = fetchSwiftRelease {
|
||||
repo = "llvm-project";
|
||||
hash = "sha256-uW6dEAFaDOlHXnq8lFYxrKNLRPEukauZJxX4UCpWpIY=";
|
||||
};
|
||||
swift = fetchSwiftRelease {
|
||||
repo = "swift";
|
||||
hash = "sha256-n8WVQYinAyIj4wmQnDhvPsH+t8ydANkGbjFJ6blfHOY=";
|
||||
};
|
||||
swift-experimental-string-processing = fetchSwiftRelease {
|
||||
repo = "swift-experimental-string-processing";
|
||||
hash = "sha256-Ar9fQWi8bYSvGErrS0SWrxIxwEwCjsYIZcWweZ8bV28=";
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (!stdenv.isDarwin) {
|
||||
swift-corelibs-libdispatch = fetchSwiftRelease {
|
||||
repo = "swift-corelibs-libdispatch";
|
||||
hash = "sha256-1qbXiC1k9+T+L6liqXKg6EZXqem6KEEx8OctuL4Kb2o=";
|
||||
};
|
||||
};
|
||||
sources = callPackage ../sources.nix { };
|
||||
|
||||
# Tools invoked by swift at run-time.
|
||||
runtimeDeps = lib.optionals stdenv.isDarwin [
|
||||
|
@ -207,7 +171,7 @@ let
|
|||
|
||||
in stdenv.mkDerivation {
|
||||
pname = "swift";
|
||||
inherit version;
|
||||
inherit (sources) version;
|
||||
|
||||
outputs = [ "out" "lib" "dev" "doc" "man" ];
|
||||
|
||||
|
@ -267,13 +231,19 @@ in stdenv.mkDerivation {
|
|||
# We setup custom build directories.
|
||||
dontUseCmakeBuildDir = true;
|
||||
|
||||
unpackPhase = ''
|
||||
unpackPhase = let
|
||||
copySource = repo: "cp -r ${sources.${repo}} ${repo}";
|
||||
in ''
|
||||
mkdir src
|
||||
cd src
|
||||
|
||||
${lib.concatStrings (lib.mapAttrsToList (dir: src: ''
|
||||
cp -r ${src} ${dir}
|
||||
'') sources)}
|
||||
${copySource "swift-cmark"}
|
||||
${copySource "llvm-project"}
|
||||
${copySource "swift"}
|
||||
${copySource "swift-experimental-string-processing"}
|
||||
${lib.optionalString
|
||||
(!stdenv.isDarwin)
|
||||
(copySource "swift-corelibs-libdispatch")}
|
||||
|
||||
chmod -R u+w .
|
||||
'';
|
||||
|
@ -410,7 +380,7 @@ in stdenv.mkDerivation {
|
|||
}
|
||||
|
||||
cmakeFlags="-GNinja"
|
||||
buildProject cmark
|
||||
buildProject swift-cmark
|
||||
|
||||
# Some notes:
|
||||
# - The Swift build just needs Clang.
|
||||
|
@ -439,8 +409,8 @@ in stdenv.mkDerivation {
|
|||
-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=ON
|
||||
-DLLVM_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/llvm
|
||||
-DClang_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/clang
|
||||
-DSWIFT_PATH_TO_CMARK_SOURCE=$SWIFT_SOURCE_ROOT/cmark
|
||||
-DSWIFT_PATH_TO_CMARK_BUILD=$SWIFT_BUILD_ROOT/cmark
|
||||
-DSWIFT_PATH_TO_CMARK_SOURCE=$SWIFT_SOURCE_ROOT/swift-cmark
|
||||
-DSWIFT_PATH_TO_CMARK_BUILD=$SWIFT_BUILD_ROOT/swift-cmark
|
||||
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=$SWIFT_SOURCE_ROOT/swift-corelibs-libdispatch
|
||||
-DEXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing
|
||||
-DSWIFT_INSTALL_COMPONENTS=${lib.concatStringsSep ";" swiftInstallComponents}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, callPackage
|
||||
, cmake
|
||||
, ninja
|
||||
, swift
|
||||
|
@ -10,17 +10,13 @@
|
|||
, curl
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
let
|
||||
sources = callPackage ../sources.nix { };
|
||||
in stdenv.mkDerivation {
|
||||
pname = "swift-corelibs-foundation";
|
||||
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-corelibs-foundation";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-6XUSC6759dcG24YapWicjRzUnmVVe0QPSsLEw4sQNjI=";
|
||||
};
|
||||
inherit (sources) version;
|
||||
src = sources.swift-corelibs-foundation;
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, callPackage
|
||||
, cmake
|
||||
, ninja
|
||||
, useSwift ? true, swift
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation {
|
||||
pname = "swift-corelibs-libdispatch";
|
||||
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-corelibs-libdispatch";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-1qbXiC1k9+T+L6liqXKg6EZXqem6KEEx8OctuL4Kb2o=";
|
||||
};
|
||||
inherit (sources) version;
|
||||
src = sources.swift-corelibs-libdispatch;
|
||||
|
||||
outputs = [ "out" "dev" "man" ];
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
, swift
|
||||
, swiftpm
|
||||
, Foundation
|
||||
|
@ -12,8 +11,8 @@
|
|||
, LocalAuthentication
|
||||
}:
|
||||
let
|
||||
# Generated by swiftpm2nix.
|
||||
generated = callPackage ./generated { };
|
||||
sources = callPackage ../sources.nix { };
|
||||
generated = callPackage ./generated { }; # Generated by swiftpm2nix.
|
||||
|
||||
# On Darwin, we only want ncurses in the linker search path, because headers
|
||||
# are part of libsystem. Adding its headers to the search path causes strange
|
||||
|
@ -21,17 +20,11 @@ let
|
|||
# TODO: Find a better way to prevent this conflict.
|
||||
ncursesInput = if stdenv.isDarwin then ncurses.out else ncurses;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation {
|
||||
pname = "sourcekit-lsp";
|
||||
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "sourcekit-lsp";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-uA3a+kAqI+XFzkDFEJ8XuRTgfYqacEuTsOU289Im+0Y=";
|
||||
};
|
||||
inherit (sources) version;
|
||||
src = sources.sourcekit-lsp;
|
||||
|
||||
nativeBuildInputs = [ swift swiftpm ];
|
||||
buildInputs = [
|
||||
|
|
33
pkgs/development/compilers/swift/sources.nix
Normal file
33
pkgs/development/compilers/swift/sources.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ lib, fetchFromGitHub }:
|
||||
|
||||
let
|
||||
|
||||
# These packages are all part of the Swift toolchain, and have a single
|
||||
# upstream version that should match. We also list the hashes here so a basic
|
||||
# version upgrade touches only this file.
|
||||
version = "5.7";
|
||||
hashes = {
|
||||
llvm-project = "sha256-uW6dEAFaDOlHXnq8lFYxrKNLRPEukauZJxX4UCpWpIY=";
|
||||
sourcekit-lsp = "sha256-uA3a+kAqI+XFzkDFEJ8XuRTgfYqacEuTsOU289Im+0Y=";
|
||||
swift = "sha256-n8WVQYinAyIj4wmQnDhvPsH+t8ydANkGbjFJ6blfHOY=";
|
||||
swift-cmark = "sha256-f0BoTs4HYdx/aJ9HIGCWMalhl8PvClWD6R4QK3qSgAw=";
|
||||
swift-corelibs-foundation = "sha256-6XUSC6759dcG24YapWicjRzUnmVVe0QPSsLEw4sQNjI=";
|
||||
swift-corelibs-libdispatch = "sha256-1qbXiC1k9+T+L6liqXKg6EZXqem6KEEx8OctuL4Kb2o=";
|
||||
swift-corelibs-xctest = "sha256-qLUO9/3tkJWorDMEHgHd8VC3ovLLq/UWXJWMtb6CMN0=";
|
||||
swift-docc = "sha256-WlXJMAnrlVPCM+iCIhG0Gyho76BsC2yVBEpX3m/WiIQ=";
|
||||
swift-docc-render-artifact = "sha256-ttdurN/K7OX+I4577jG3YGeRs+GLUTc7BiiEZGmFD+s=";
|
||||
swift-driver = "sha256-sk7XWXYR1MGPEeVxA6eA/vxhN6Gq16iD1RHpVstL3zE=";
|
||||
swift-experimental-string-processing = "sha256-Ar9fQWi8bYSvGErrS0SWrxIxwEwCjsYIZcWweZ8bV28=";
|
||||
swift-package-manager = "sha256-MZah+/XfeK46YamxwuE3Kiv+u5bj7VmjEh6ztDF+0j4=";
|
||||
};
|
||||
|
||||
# Create fetch derivations.
|
||||
sources = lib.mapAttrs (repo: hash: fetchFromGitHub {
|
||||
owner = "apple";
|
||||
inherit repo;
|
||||
rev = "swift-${version}-RELEASE";
|
||||
name = "${repo}-${version}-src";
|
||||
hash = hashes.${repo};
|
||||
}) hashes;
|
||||
|
||||
in sources // { inherit version; }
|
|
@ -1,7 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
, swift
|
||||
, swiftpm
|
||||
, Foundation
|
||||
|
@ -10,28 +9,17 @@
|
|||
, LocalAuthentication
|
||||
}:
|
||||
let
|
||||
# Generated by swiftpm2nix.
|
||||
generated = callPackage ./generated { };
|
||||
sources = callPackage ../sources.nix { };
|
||||
generated = callPackage ./generated { }; # Generated by swiftpm2nix.
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation {
|
||||
pname = "swift-docc";
|
||||
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-docc";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-WlXJMAnrlVPCM+iCIhG0Gyho76BsC2yVBEpX3m/WiIQ=";
|
||||
};
|
||||
inherit (sources) version;
|
||||
src = sources.swift-docc;
|
||||
# TODO: We could build this from `apple/swift-docc-render` source, but that
|
||||
# repository is not tagged.
|
||||
render-artifact = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-docc-render-artifact";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-ttdurN/K7OX+I4577jG3YGeRs+GLUTc7BiiEZGmFD+s=";
|
||||
};
|
||||
renderArtifact = sources.swift-docc-render-artifact;
|
||||
|
||||
nativeBuildInputs = [ swift swiftpm ];
|
||||
buildInputs = [ Foundation XCTest ]
|
||||
|
@ -47,7 +35,7 @@ stdenv.mkDerivation rec {
|
|||
binPath="$(swiftpmBinPath)"
|
||||
mkdir -p $out/bin $out/share/docc
|
||||
cp $binPath/docc $out/bin/
|
||||
ln -s ${render-artifact}/dist $out/share/docc/render
|
||||
ln -s $renderArtifact/dist $out/share/docc/render
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, swift
|
||||
, swiftpm
|
||||
|
@ -12,8 +11,8 @@
|
|||
, substituteAll
|
||||
}:
|
||||
let
|
||||
# Generated by swiftpm2nix.
|
||||
generated = callPackage ./generated { };
|
||||
sources = callPackage ../sources.nix { };
|
||||
generated = callPackage ./generated { }; # Generated by swiftpm2nix.
|
||||
|
||||
# On Darwin, we only want ncurses in the linker search path, because headers
|
||||
# are part of libsystem. Adding its headers to the search path causes strange
|
||||
|
@ -21,17 +20,11 @@ let
|
|||
# TODO: Find a better way to prevent this conflict.
|
||||
ncursesInput = if stdenv.isDarwin then ncurses.out else ncurses;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation {
|
||||
pname = "swift-driver";
|
||||
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-driver";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-sk7XWXYR1MGPEeVxA6eA/vxhN6Gq16iD1RHpVstL3zE=";
|
||||
};
|
||||
inherit (sources) version;
|
||||
src = sources.swift-driver;
|
||||
|
||||
nativeBuildInputs = [ swift swiftpm ];
|
||||
buildInputs = [
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{ lib
|
||||
, callPackage
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, ninja
|
||||
, git
|
||||
|
@ -25,16 +24,12 @@ let
|
|||
inherit (swift) swiftOs swiftModuleSubdir swiftStaticModuleSubdir;
|
||||
sharedLibraryExt = stdenv.hostPlatform.extensions.sharedLibrary;
|
||||
|
||||
sources = callPackage ../sources.nix { };
|
||||
|
||||
# Common attributes for the bootstrap swiftpm and the final swiftpm.
|
||||
commonAttrs = rec {
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-package-manager";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-MZah+/XfeK46YamxwuE3Kiv+u5bj7VmjEh6ztDF+0j4=";
|
||||
};
|
||||
commonAttrs = {
|
||||
inherit (sources) version;
|
||||
src = sources.swift-package-manager;
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
# Required at run-time for the host platform to build package manifests.
|
||||
propagatedBuildInputs = [ Foundation ];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, callPackage
|
||||
, cmake
|
||||
, ninja
|
||||
, swift
|
||||
|
@ -8,17 +8,13 @@
|
|||
, DarwinTools
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
let
|
||||
sources = callPackage ../sources.nix { };
|
||||
in stdenv.mkDerivation {
|
||||
pname = "swift-corelibs-xctest";
|
||||
|
||||
# Releases are made as part of the Swift toolchain, so versions should match.
|
||||
version = "5.7";
|
||||
src = fetchFromGitHub {
|
||||
owner = "apple";
|
||||
repo = "swift-corelibs-xctest";
|
||||
rev = "swift-${version}-RELEASE";
|
||||
hash = "sha256-qLUO9/3tkJWorDMEHgHd8VC3ovLLq/UWXJWMtb6CMN0=";
|
||||
};
|
||||
inherit (sources) version;
|
||||
src = sources.swift-corelibs-xctest;
|
||||
|
||||
outputs = [ "out" ];
|
||||
|
||||
|
|
Loading…
Reference in a new issue