push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
{ callPackage }:
{
readPubspecLock = callPackage ./pubspec-lock.nix { };
generatePackageConfig = callPackage ./package-config.nix { };
}

View File

@@ -0,0 +1,76 @@
{
lib,
runCommand,
jq,
yq,
}:
{
pname ? null,
# A list of dependency package names.
dependencies,
# An attribute set of package names to sources.
dependencySources,
}:
let
packages = lib.genAttrs dependencies (dependency: rec {
src = dependencySources.${dependency};
inherit (src) packageRoot;
});
in
(runCommand "${lib.optionalString (pname != null) "${pname}-"}package-config.json" {
inherit packages;
nativeBuildInputs = [
jq
yq
];
__structuredAttrs = true;
})
''
declare -A packageSources
declare -A packageRoots
while IFS=',' read -r name src packageRoot; do
packageSources["$name"]="$src"
packageRoots["$name"]="$packageRoot"
done < <(jq -r '.packages | to_entries | map("\(.key),\(.value.src),\(.value.packageRoot)") | .[]' "$NIX_ATTRS_JSON_FILE")
for package in "''${!packageSources[@]}"; do
pubspec="$(realpath --logical "''${packageSources["$package"]}/''${packageRoots["$package"]}/pubspec.yaml")"
if [ ! -e "$pubspec" ]; then
echo >&2 "The package sources for $package are missing. Is the following path inside the source derivation?"
echo >&2 "Source path: $pubspec"
exit 1
fi
languageConstraint="$(yq -r .environment.sdk "$pubspec")"
if [[ "$languageConstraint" =~ ^[[:space:]]*(\^|>=|>)?[[:space:]]*([[:digit:]]+\.[[:digit:]]+)\.[[:digit:]]+.*$ ]]; then
languageVersionJson="\"''${BASH_REMATCH[2]}\""
elif [ "$languageConstraint" = 'any' ]; then
languageVersionJson='null'
else
# https://github.com/dart-lang/pub/blob/68dc2f547d0a264955c1fa551fa0a0e158046494/lib/src/language_version.dart#L106C35-L106C35
languageVersionJson='"2.7"'
fi
jq --null-input \
--arg name "$package" \
--arg path "''${packageSources["$package"]}/''${packageRoots["$package"]}" \
--argjson languageVersion "$languageVersionJson" \
'{
name: $name,
rootUri: "file://\($path)",
packageUri: "lib/",
languageVersion: $languageVersion,
}'
done | jq > "$out" --slurp '{
configVersion: 2,
generator: "nixpkgs",
packages: .,
}'
''

View File

@@ -0,0 +1,54 @@
"""
https://github.com/dart-lang/pub/issues/4522
This script generates a package_graph.json file.
"""
import json
import os
from pathlib import Path
from urllib.parse import unquote, urlparse
import yaml
def get_package(pubspec_path: Path, dev_dependencies: bool = False):
with pubspec_path.open("r", encoding="utf-8") as f:
pubspec = yaml.load(f, Loader=yaml.CSafeLoader)
package = {
"name": pubspec["name"],
"version": pubspec.get("version") or "0.0.0",
"dependencies": list(pubspec.get("dependencies") or {}),
}
if dev_dependencies:
package["devDependencies"] = list(pubspec.get("dev_dependencies") or {})
return package
def main() -> None:
package_config_file_path = Path(os.environ["packageConfig"]) # noqa: SIM112
with package_config_file_path.open("r", encoding="utf-8") as f:
package_config = json.load(f)
package_graph = []
root_package = get_package(Path("pubspec.yaml"), dev_dependencies=True)
for data in package_config.get("packages", []):
if data["name"] == root_package["name"] or data["rootUri"] == "flutter_gen":
continue
package_graph.append(
get_package(Path(unquote(urlparse(data["rootUri"]).path)) / "pubspec.yaml")
)
package_graph.append(root_package)
print(
json.dumps(
{
"roots": [root_package["name"]],
"packages": package_graph,
"configVersion": 1,
},
indent=2,
ensure_ascii=False,
)
)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,174 @@
{
lib,
callPackage,
fetchurl,
fetchgit,
runCommand,
}:
{
# The source directory of the package.
src,
# The package subdirectory within src.
# Useful if the package references sibling packages with relative paths.
packageRoot ? ".",
# The pubspec.lock file, in attribute set form.
pubspecLock,
# Hashes for Git dependencies.
# Pub does not record these itself, so they must be manually provided.
gitHashes ? { },
# Functions to generate SDK package sources.
# The function names should match the SDK names, and the package name is given as an argument.
sdkSourceBuilders ? { },
# Functions that create custom package source derivations.
#
# The function names should match the package names, and the package version,
# source, and source files are given in an attribute set argument.
#
# The passthru of the source derivation should be propagated.
customSourceBuilders ? { },
}:
let
dependencyVersions = builtins.mapAttrs (name: details: details.version) pubspecLock.packages;
dependencyTypes = {
"direct main" = "main";
"direct dev" = "dev";
"direct overridden" = "overridden";
"transitive" = "transitive";
};
dependencies = lib.foldlAttrs (
dependencies: name: details:
dependencies
// {
${dependencyTypes.${details.dependency}} =
dependencies.${dependencyTypes.${details.dependency}}
++ [ name ];
}
) (lib.genAttrs (builtins.attrValues dependencyTypes) (dependencyType: [ ])) pubspecLock.packages;
# fetchTarball fails with "tarball contains an unexpected number of top-level files". This is a workaround.
# https://discourse.nixos.org/t/fetchtarball-with-multiple-top-level-directories-fails/20556
mkHostedDependencySource =
name: details:
let
archive = fetchurl {
name = "pub-${name}-${details.version}.tar.gz";
url = "${details.description.url}/packages/${details.description.name}/versions/${details.version}.tar.gz";
sha256 = details.description.sha256;
};
in
runCommand "pub-${name}-${details.version}" { passthru.packageRoot = "."; } ''
mkdir -p "$out"
tar xf '${archive}' -C "$out"
'';
mkGitDependencySource =
name: details:
(fetchgit {
name = "pub-${name}-${details.version}";
url = details.description.url;
rev = details.description.resolved-ref;
hash =
gitHashes.${name}
or (throw "A Git hash is required for ${name}! Set to an empty string to obtain it.");
}).overrideAttrs
(
{
passthru ? { },
...
}:
{
passthru = passthru // {
packageRoot = details.description.path;
};
}
);
mkPathDependencySource =
name: details:
assert lib.assertMsg details.description.relative
"Only relative paths are supported - ${name} has an absolue path!";
(
if lib.isDerivation src then
src
else
(runCommand "pub-${name}-${details.version}" { } ''cp -r '${src}' "$out"'')
).overrideAttrs
(
{
passthru ? { },
...
}:
{
passthru = passthru // {
packageRoot = "${packageRoot}/${details.description.path}";
};
}
);
mkSdkDependencySource =
name: details:
(sdkSourceBuilders.${details.description}
or (throw "No SDK source builder has been given for ${details.description}!")
)
name;
addDependencySourceUtils =
dependencySource: details:
dependencySource.overrideAttrs (
{ passthru, ... }:
{
passthru = passthru // {
inherit (details) version;
};
}
);
sourceBuilders =
callPackage ../../../development/compilers/dart/package-source-builders { } // customSourceBuilders;
dependencySources = lib.filterAttrs (name: src: src != null) (
builtins.mapAttrs (
name: details:
(sourceBuilders.${name} or ({ src, ... }: src)) {
inherit (details) version source;
src = (
(addDependencySourceUtils (
(
{
"hosted" = mkHostedDependencySource;
"git" = mkGitDependencySource;
"path" = mkPathDependencySource;
"sdk" = mkSdkDependencySource;
}
.${details.source}
name
)
details
))
details
);
}
) pubspecLock.packages
);
in
{
inherit
# An attribute set of dependency categories to package name lists.
dependencies
# An attribute set of package names to their versions.
dependencyVersions
# An attribute set of package names to their sources.
dependencySources
;
}