Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,27 @@ easy:
More complex modifications to the `prek` wrapper are possible too,
refer to our [wrapper module provider](https://birdeehub.github.io/nix-wrapper-modules/modules/default.html)
for details.

### Updating the Dart/Flutter SDK versions

The Dart and Flutter SDKs are pinned centrally in
[`nix/dart/sdk-versions.nix`](nix/dart/sdk-versions.nix), so that the
DevShell and CI always use identical toolchain binaries. This file is
generated — do not edit it by hand.

To bump the pins, run:

```console
$ nix run .#updateSdkVersions # latest stable of both
$ nix run .#updateSdkVersions -- --dart X.Y.Z # pin a specific Dart version
$ nix run .#updateSdkVersions -- --flutter X.Y.Z # pin a specific Flutter version
```

This fetches the requested (or latest stable) versions, prefetches the
SDK archives for every supported platform, records their SHA256 hashes,
and rewrites `sdk-versions.nix`. Review and commit the result.

The versions are resolved from the official release-metadata endpoints
that the Dart and Flutter tooling itself uses
(`dart-archive/.../latest/VERSION` and
`flutter_infra_release/releases/releases_linux.json`).
6 changes: 4 additions & 2 deletions nix/dart/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
lib,
importApply,
...
}:
}@args:
importingFlake: {
imports = [ ];
imports = [
(importApply ./sdk.nix args)
];

options.perSystem = flake-parts-lib.mkPerSystemOption ({
options.famedly.standards.dart.projects = lib.mkOption {
Expand Down
78 changes: 78 additions & 0 deletions nix/dart/packages/dart-sdk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Dart SDK derivation with a pinned version from nix/dart/sdk-versions.nix.
# Structurally identical to nixpkgs' dart/default.nix, but version and
# hashes come from our central pin so that DevShell and CI use the same binary.
{
lib,
stdenv,
fetchurl,
unzip,
sdkVersions,
}:

let
v = sdkVersions.dart;
inherit (stdenv.hostPlatform) system;

platforms = {
x86_64-linux = "linux-x64";
aarch64-linux = "linux-arm64";
x86_64-darwin = "macos-x64";
aarch64-darwin = "macos-arm64";
};

archiveName =
platforms.${system}
or (throw "famedly-dart-sdk: unsupported system ${system}; supported: ${lib.concatStringsSep ", " (lib.attrNames platforms)}");

hash = v.hashes.${system} or (throw "famedly-dart-sdk: no hash for ${system}");
in
stdenv.mkDerivation {
pname = "famedly-dart-sdk";
inherit (v) version;

src = fetchurl {
url = "https://storage.googleapis.com/dart-archive/channels/stable/release/${v.version}/sdk/dartsdk-${archiveName}-release.zip";
inherit hash;
};

nativeBuildInputs = [ unzip ];

installPhase = ''
runHook preInstall
rm -f LICENSE README revision
cp -R . $out
runHook postInstall
'';

# Patch ELF interpreters on Linux so binaries work outside the Nix sandbox.
postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
find $out/bin -type f -executable | while read f; do
if patchelf --print-interpreter "$f" >/dev/null 2>&1; then
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${lib.makeLibraryPath [ (lib.getLib stdenv.cc.cc) ]}" \
"$f"
fi
done
'';

dontStrip = true;

meta = {
description = "Dart SDK ${v.version} (Famedly-pinned)";
homepage = "https://dart.dev";
changelog = "https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md";
mainProgram = "dart";
platforms = lib.attrNames platforms;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.bsd3;
maintainers = [
{
name = "Famedly GmbH";
email = "info@famedly.com";
github = "famedly";
githubId = 46558835;
}
];
};
}
103 changes: 103 additions & 0 deletions nix/dart/packages/flutter-sdk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Flutter SDK derivation with a pinned version from nix/dart/sdk-versions.nix.
# Flutter stable does not publish Linux arm64 binaries — aarch64-linux is
# therefore not supported.
{
lib,
stdenv,
fetchurl,
autoPatchelfHook,
bash,
curl,
git,
unzip,
xz,
fontconfig,
gtk3,
libGL,
libepoxy,
pango,
glib,
sdkVersions,
}:

let
v = sdkVersions.flutter;
inherit (stdenv.hostPlatform) system;

archives = {
x86_64-linux = {
url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${v.version}-stable.tar.xz";
hash = v.hashes.x86_64-linux;
};
x86_64-darwin = {
url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_${v.version}-stable.zip";
hash = v.hashes.x86_64-darwin;
};
aarch64-darwin = {
url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_${v.version}-stable.zip";
hash = v.hashes.aarch64-darwin;
};
};

archive =
archives.${system}
or (throw "famedly-flutter-sdk: unsupported system ${system}; supported: ${lib.concatStringsSep ", " (lib.attrNames archives)}");
in
stdenv.mkDerivation {
pname = "famedly-flutter-sdk";
inherit (v) version;

src = fetchurl { inherit (archive) url hash; };

nativeBuildInputs = [
unzip
]
++ lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
xz
];

buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
bash
curl
git
fontconfig
gtk3
libGL
libepoxy
pango
glib
];

installPhase = ''
runHook preInstall
mkdir -p $out
cp -R . $out/flutter
# Symlink binaries for PATH
mkdir -p $out/bin
ln -s $out/flutter/bin/flutter $out/bin/flutter
ln -s $out/flutter/bin/dart $out/bin/dart
runHook postInstall
'';

dontStrip = true;
dontBuild = true;

meta = {
description = "Flutter SDK ${v.version} (Famedly-pinned)";
homepage = "https://flutter.dev";
changelog = "https://github.com/flutter/flutter/blob/main/CHANGELOG.md";
mainProgram = "flutter";
platforms = lib.attrNames archives;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.bsd3;
maintainers = [
{
name = "Famedly GmbH";
email = "info@famedly.com";
github = "famedly";
githubId = 46558835;
}
];
};
}
Loading