Loading pkgs/build-support/dart/build-dart-application/hooks/dart-config-hook.sh +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ dartConfigHook() { echo "Installing dependencies" mkdir -p .dart_tool cp "$packageConfig" .dart_tool/package_config.json chmod u+w .dart_tool/package_config.json @python3@ @workspacePackageConfigScript@ chmod u-w .dart_tool/package_config.json @python3@ @packageGraphScript@ > .dart_tool/package_graph.json packagePath() { Loading pkgs/build-support/dart/build-dart-application/hooks/default.nix +1 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ substitutions.jq = "${jq}/bin/jq"; substitutions.python3 = lib.getExe (python3.withPackages (ps: with ps; [ pyyaml ])); substitutions.packageGraphScript = ../../pub2nix/package-graph.py; substitutions.workspacePackageConfigScript = ../workspace-package-config.py; } ./dart-config-hook.sh; dartBuildHook = makeSetupHook { name = "dart-build-hook"; Loading pkgs/build-support/dart/build-dart-application/workspace-package-config.py 0 → 100644 +42 −0 Original line number Diff line number Diff line import json import re from pathlib import Path import yaml def main() -> None: with Path("pubspec.yaml").open("r", encoding="utf-8") as f: pubspec = yaml.load(f, Loader=yaml.CSafeLoader) if not pubspec.get("workspace"): return with Path(".dart_tool/package_config.json").open("r", encoding="utf-8") as f: package_config = json.load(f) for package_path in pubspec.get("workspace", []): with (Path(package_path) / "pubspec.yaml").open("r", encoding="utf-8") as f: package_pubspec = yaml.load(f, Loader=yaml.CSafeLoader) m = re.match( r"^[ \t]*(\^|>=|>)?[ \t]*([0-9]+\.[0-9]+)\.[0-9]+.*$", package_pubspec.get("environment", {}).get("sdk", ""), ) if m: languageVersion = m.group(2) elif package_pubspec.get("environment", {}).get("sdk") == "any": languageVersion = "null" else: languageVersion = "2.7" if not any( pkg["name"] == package_pubspec["name"] for pkg in package_config["packages"] ): package_config["packages"].append({ "name": package_pubspec["name"], "rootUri": Path(package_path).resolve().as_uri(), "packageUri": "lib/", "languageVersion": languageVersion, }) with Path(".dart_tool/package_config.json").open("w", encoding="utf-8") as f: json.dump(package_config, f, sort_keys=True, indent=4) if __name__ == "__main__": main() pkgs/by-name/me/melos/add-generic-main.patch +2 −2 Original line number Diff line number Diff line diff --git a/bin/melos.dart b/bin/melos.dart index 0db7013..218276f 100644 --- a/bin/melos.dart +++ b/bin/melos.dart --- a/packages/melos/bin/melos.dart +++ b/packages/melos/bin/melos.dart @@ -1,11 +1,37 @@ +import 'dart:io'; import 'package:cli_launcher/cli_launcher.dart'; Loading pkgs/by-name/me/melos/package.nix +3 −5 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ buildDartApplication { pname = "melos"; inherit version src; sourceRoot = "${src.name}/packages/melos"; patches = [ # This patch (created a melos 6.1.0) modify the method melos use to find path to the root of the projects. # It is needed because when melos is in the nixstore, it break it and fail to find the projects root with melos.yaml Loading @@ -28,12 +26,12 @@ buildDartApplication { # hard code the path to the melos templates preBuild = '' substituteInPlace lib/src/common/utils.dart \ substituteInPlace packages/melos/lib/src/common/utils.dart \ --replace-fail "final melosPackageFileUri = await Isolate.resolvePackageUri(melosPackageUri);" "return \"$out\";" substituteInPlace lib/src/common/utils.dart \ substituteInPlace packages/melos/lib/src/common/utils.dart \ --replace-fail "return p.normalize('\''${melosPackageFileUri!.toFilePath()}/../..');" " " mkdir --parents $out cp --recursive templates $out/ cp --recursive packages/melos/templates $out/ ''; meta = { Loading Loading
pkgs/build-support/dart/build-dart-application/hooks/dart-config-hook.sh +3 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,9 @@ dartConfigHook() { echo "Installing dependencies" mkdir -p .dart_tool cp "$packageConfig" .dart_tool/package_config.json chmod u+w .dart_tool/package_config.json @python3@ @workspacePackageConfigScript@ chmod u-w .dart_tool/package_config.json @python3@ @packageGraphScript@ > .dart_tool/package_graph.json packagePath() { Loading
pkgs/build-support/dart/build-dart-application/hooks/default.nix +1 −0 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ substitutions.jq = "${jq}/bin/jq"; substitutions.python3 = lib.getExe (python3.withPackages (ps: with ps; [ pyyaml ])); substitutions.packageGraphScript = ../../pub2nix/package-graph.py; substitutions.workspacePackageConfigScript = ../workspace-package-config.py; } ./dart-config-hook.sh; dartBuildHook = makeSetupHook { name = "dart-build-hook"; Loading
pkgs/build-support/dart/build-dart-application/workspace-package-config.py 0 → 100644 +42 −0 Original line number Diff line number Diff line import json import re from pathlib import Path import yaml def main() -> None: with Path("pubspec.yaml").open("r", encoding="utf-8") as f: pubspec = yaml.load(f, Loader=yaml.CSafeLoader) if not pubspec.get("workspace"): return with Path(".dart_tool/package_config.json").open("r", encoding="utf-8") as f: package_config = json.load(f) for package_path in pubspec.get("workspace", []): with (Path(package_path) / "pubspec.yaml").open("r", encoding="utf-8") as f: package_pubspec = yaml.load(f, Loader=yaml.CSafeLoader) m = re.match( r"^[ \t]*(\^|>=|>)?[ \t]*([0-9]+\.[0-9]+)\.[0-9]+.*$", package_pubspec.get("environment", {}).get("sdk", ""), ) if m: languageVersion = m.group(2) elif package_pubspec.get("environment", {}).get("sdk") == "any": languageVersion = "null" else: languageVersion = "2.7" if not any( pkg["name"] == package_pubspec["name"] for pkg in package_config["packages"] ): package_config["packages"].append({ "name": package_pubspec["name"], "rootUri": Path(package_path).resolve().as_uri(), "packageUri": "lib/", "languageVersion": languageVersion, }) with Path(".dart_tool/package_config.json").open("w", encoding="utf-8") as f: json.dump(package_config, f, sort_keys=True, indent=4) if __name__ == "__main__": main()
pkgs/by-name/me/melos/add-generic-main.patch +2 −2 Original line number Diff line number Diff line diff --git a/bin/melos.dart b/bin/melos.dart index 0db7013..218276f 100644 --- a/bin/melos.dart +++ b/bin/melos.dart --- a/packages/melos/bin/melos.dart +++ b/packages/melos/bin/melos.dart @@ -1,11 +1,37 @@ +import 'dart:io'; import 'package:cli_launcher/cli_launcher.dart'; Loading
pkgs/by-name/me/melos/package.nix +3 −5 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ buildDartApplication { pname = "melos"; inherit version src; sourceRoot = "${src.name}/packages/melos"; patches = [ # This patch (created a melos 6.1.0) modify the method melos use to find path to the root of the projects. # It is needed because when melos is in the nixstore, it break it and fail to find the projects root with melos.yaml Loading @@ -28,12 +26,12 @@ buildDartApplication { # hard code the path to the melos templates preBuild = '' substituteInPlace lib/src/common/utils.dart \ substituteInPlace packages/melos/lib/src/common/utils.dart \ --replace-fail "final melosPackageFileUri = await Isolate.resolvePackageUri(melosPackageUri);" "return \"$out\";" substituteInPlace lib/src/common/utils.dart \ substituteInPlace packages/melos/lib/src/common/utils.dart \ --replace-fail "return p.normalize('\''${melosPackageFileUri!.toFilePath()}/../..');" " " mkdir --parents $out cp --recursive templates $out/ cp --recursive packages/melos/templates $out/ ''; meta = { Loading