dart: add fetchGitHashesScript (#461421)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
yq-go,
|
||||
_experimental-update-script-combinators,
|
||||
gitUpdater,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -26,7 +27,7 @@ flutter335.buildFlutterApplication {
|
||||
|
||||
sourceRoot = "${src.name}/app";
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
postInstall = ''
|
||||
cp -r linux/debian/usr/share $out/share
|
||||
@@ -43,14 +44,30 @@ flutter335.buildFlutterApplication {
|
||||
yq eval --output-format=json --prettyPrint $src/app/pubspec.lock > "$out"
|
||||
'';
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
(gitUpdater {
|
||||
ignoredVersions = ".*(rc|beta).*";
|
||||
rev-prefix = "v";
|
||||
})
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "butterfly.pubspecSource" ./pubspec.lock.json)
|
||||
(
|
||||
(gitUpdater {
|
||||
ignoredVersions = ".*(rc|beta).*";
|
||||
rev-prefix = "v";
|
||||
})
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "butterfly.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ flutter332.buildFlutterApplication {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
nativeBuildInputs = [ autoPatchelfHook ];
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -19,4 +19,5 @@ nix-update gopeed.libgopeed
|
||||
|
||||
curl --fail --silent https://raw.githubusercontent.com/GopeedLab/gopeed/${latestTag}/ui/flutter/pubspec.lock | yq eval --output-format=json --prettyPrint >$PACKAGE_DIR/pubspec.lock.json
|
||||
|
||||
$PACKAGE_DIR/update-gitHashes.py
|
||||
$(nix eval --file . dart.fetchGitHashesScript) --input $PACKAGE_DIR/pubspec.lock.json --output $PACKAGE_DIR/git-hashes.json
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
yq-go,
|
||||
_experimental-update-script-combinators,
|
||||
nix-update-script,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -27,7 +28,7 @@ flutter329.buildFlutterApplication {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
nativeBuildInputs = [
|
||||
copyDesktopItems
|
||||
@@ -74,7 +75,13 @@ flutter329.buildFlutterApplication {
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -11,9 +11,10 @@
|
||||
mpv-unwrapped,
|
||||
webkitgtk_4_1,
|
||||
_experimental-update-script-combinators,
|
||||
gitUpdater,
|
||||
nix-update-script,
|
||||
runCommand,
|
||||
yq-go,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -32,7 +33,7 @@ flutter338.buildFlutterApplication {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
customSourceBuilders = {
|
||||
# unofficial media_kit_libs_linux
|
||||
@@ -114,11 +115,22 @@ flutter338.buildFlutterApplication {
|
||||
yq eval --output-format=json --prettyPrint $src/pubspec.lock > "$out"
|
||||
'';
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
(gitUpdater { })
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "kazumi.pubspecSource" ./pubspec.lock.json)
|
||||
(nix-update-script { })
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "kazumi.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -117,7 +117,7 @@ flutter332.buildFlutterApplication {
|
||||
};
|
||||
};
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
nativeBuildInputs = [ copyDesktopItems ];
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -19,4 +19,4 @@ nix-update --subpackage rustDep mangayomi
|
||||
|
||||
curl -sL https://raw.githubusercontent.com/kodjodevf/mangayomi/${latestTag}/pubspec.lock | yq . >$PACKAGE_DIR/pubspec.lock.json
|
||||
|
||||
$PACKAGE_DIR/update-gitHashes.py
|
||||
$(nix eval --file . dart.fetchGitHashesScript) --input $PACKAGE_DIR/pubspec.lock.json --output $PACKAGE_DIR/git-hashes.json
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
runCommand,
|
||||
_experimental-update-script-combinators,
|
||||
yq,
|
||||
gitUpdater,
|
||||
nix-update-script,
|
||||
dart,
|
||||
}:
|
||||
|
||||
flutter335.buildFlutterApplication rec {
|
||||
@@ -32,7 +33,7 @@ flutter335.buildFlutterApplication rec {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
buildInputs = [
|
||||
alsa-lib
|
||||
@@ -59,11 +60,22 @@ flutter335.buildFlutterApplication rec {
|
||||
cat $src/pubspec.lock | yq > $out
|
||||
'';
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
(gitUpdater { rev-prefix = "v"; })
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "musicpod.pubspecSource" ./pubspec.lock.json)
|
||||
(nix-update-script { })
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "musicpod.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -17,6 +17,7 @@
|
||||
yq-go,
|
||||
_experimental-update-script-combinators,
|
||||
nix-update-script,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -75,7 +76,7 @@ flutter335.buildFlutterApplication {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
customSourceBuilders = {
|
||||
# unofficial media_kit_libs_linux
|
||||
@@ -166,7 +167,13 @@ flutter335.buildFlutterApplication {
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -81,7 +81,7 @@ flutter329.buildFlutterApplication rec {
|
||||
sourceRoot = "${src.name}/flutter";
|
||||
# curl https://raw.githubusercontent.com/rustdesk/rustdesk/1.4.1/flutter/pubspec.lock | yq > pubspec.lock.json
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
# Configure the Rust build
|
||||
cargoRoot = "..";
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
runCommand,
|
||||
yq-go,
|
||||
_experimental-update-script-combinators,
|
||||
gitUpdater,
|
||||
nix-update-script,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -36,7 +37,7 @@ flutter335.buildFlutterApplication {
|
||||
pname = "saber";
|
||||
inherit version src;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
@@ -83,11 +84,22 @@ flutter335.buildFlutterApplication {
|
||||
yq eval --output-format=json --prettyPrint $src/pubspec.lock > "$out"
|
||||
'';
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
(gitUpdater { rev-prefix = "v"; })
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "saber.pubspecSource" ./pubspec.lock.json)
|
||||
(nix-update-script { })
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "saber.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -8,7 +8,8 @@
|
||||
runCommand,
|
||||
yq-go,
|
||||
_experimental-update-script-combinators,
|
||||
gitUpdater,
|
||||
nix-update-script,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -27,7 +28,7 @@ flutter335.buildFlutterApplication {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
nativeBuildInputs = [
|
||||
copyDesktopItems
|
||||
@@ -69,11 +70,22 @@ flutter335.buildFlutterApplication {
|
||||
yq eval --output-format=json --prettyPrint $src/pubspec.lock > "$out"
|
||||
'';
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
(gitUpdater { rev-prefix = "v"; })
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "server-box.pubspecSource" ./pubspec.lock.json)
|
||||
(nix-update-script { })
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "server-box.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -12,6 +12,7 @@
|
||||
runCommand,
|
||||
sideswap,
|
||||
yq,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -31,7 +32,7 @@ flutter332.buildFlutterApplication rec {
|
||||
};
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
# Provide OpenGL and libsideswap_client.so for the Flutter application.
|
||||
extraWrapProgramArgs = ''
|
||||
@@ -87,19 +88,35 @@ flutter332.buildFlutterApplication rec {
|
||||
# Usage: nix-shell maintainers/scripts/update.nix --argstr package sideswap
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
# Update sideswap to new release.
|
||||
(gitUpdater { rev-prefix = "v"; })
|
||||
(
|
||||
(gitUpdater { rev-prefix = "v"; })
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
|
||||
# Update pubspec.lock.json file and related gitHashes attribute.
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "sideswap.pubspecSource" ./pubspec.lock.json)
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "sideswap.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
|
||||
# Update libsideswap-client sub-package.
|
||||
{
|
||||
command = [ ./update-libsideswap-client.sh ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -8,7 +8,8 @@
|
||||
runCommand,
|
||||
yq-go,
|
||||
_experimental-update-script-combinators,
|
||||
gitUpdater,
|
||||
nix-update-script,
|
||||
dart,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -27,7 +28,7 @@ flutter335.buildFlutterApplication {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
nativeBuildInputs = [ copyDesktopItems ];
|
||||
|
||||
@@ -70,11 +71,22 @@ flutter335.buildFlutterApplication {
|
||||
yq eval --output-format=json --prettyPrint $src/pubspec.lock > "$out"
|
||||
'';
|
||||
updateScript = _experimental-update-script-combinators.sequence [
|
||||
(gitUpdater { rev-prefix = "v"; })
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "venera.pubspecSource" ./pubspec.lock.json)
|
||||
(nix-update-script { })
|
||||
(
|
||||
(_experimental-update-script-combinators.copyAttrOutputToFile "venera.pubspecSource" ./pubspec.lock.json)
|
||||
// {
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
)
|
||||
{
|
||||
command = [ ./update-gitHashes.py ];
|
||||
supportedFeatures = [ "silent" ];
|
||||
command = [
|
||||
dart.fetchGitHashesScript
|
||||
"--input"
|
||||
./pubspec.lock.json
|
||||
"--output"
|
||||
./git-hashes.json
|
||||
];
|
||||
supportedFeatures = [ ];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -19,7 +19,7 @@ flutter332.buildFlutterApplication rec {
|
||||
|
||||
pubspecLock = lib.importJSON ./pubspec.lock.json;
|
||||
|
||||
gitHashes = lib.importJSON ./gitHashes.json;
|
||||
gitHashes = lib.importJSON ./git-hashes.json;
|
||||
|
||||
sourceRoot = "${src.name}/flutter/wind_send";
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
["nix-prefetch-git", "--url", url, "--rev", rev],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return json.loads(result.stdout)["hash"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
if not isinstance(desc, dict):
|
||||
continue
|
||||
url = desc.get("url")
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -29,4 +29,4 @@ flutter pub get
|
||||
yq . pubspec.lock >"$PACKAGE_DIR/pubspec.lock.json"
|
||||
popd
|
||||
rm -rf "$source"
|
||||
./update-gitHashes.py
|
||||
$(nix eval --file . dart.fetchGitHashesScript) --input $PACKAGE_DIR/pubspec.lock.json --output $PACKAGE_DIR/git-hashes.json
|
||||
|
||||
@@ -44,6 +44,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
versionCheckProgramArg = "--version";
|
||||
|
||||
passthru = {
|
||||
fetchGitHashesScript = ./fetch-git-hashes.py;
|
||||
updateScript = ./update.sh;
|
||||
tests = {
|
||||
testCreate = runCommand "dart-test-create" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
|
||||
|
||||
+19
-19
@@ -1,15 +1,11 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix-prefetch-git
|
||||
#! nix-shell -i python3 --packages python3 nix-prefetch-git
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
THIS_FOLDER = Path(__file__).parent.resolve()
|
||||
PUBSPEC_LOCK = THIS_FOLDER / "pubspec.lock.json"
|
||||
GIT_HASHES = THIS_FOLDER / "gitHashes.json"
|
||||
|
||||
|
||||
def fetch_git_hash(url: str, rev: str) -> str:
|
||||
result = subprocess.run(
|
||||
@@ -22,14 +18,18 @@ def fetch_git_hash(url: str, rev: str) -> str:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not PUBSPEC_LOCK.exists():
|
||||
sys.exit(1)
|
||||
try:
|
||||
data = json.loads(PUBSPEC_LOCK.read_text())
|
||||
except json.JSONDecodeError:
|
||||
sys.exit(1)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--input",
|
||||
type=Path,
|
||||
default=Path(__file__).parent.resolve() / "pubspec.lock.json",
|
||||
)
|
||||
parser.add_argument("-o", "--output", type=Path, default=None)
|
||||
args = parser.parse_args()
|
||||
output_file: Path | None = args.output
|
||||
output: dict[str, str] = {}
|
||||
for name, info in data.get("packages", {}).items():
|
||||
for name, info in json.loads(args.input.read_text()).get("packages", {}).items():
|
||||
if info.get("source") != "git":
|
||||
continue
|
||||
desc = info.get("description")
|
||||
@@ -39,12 +39,12 @@ def main() -> None:
|
||||
rev = desc.get("resolved-ref")
|
||||
if not (isinstance(url, str) and isinstance(rev, str)):
|
||||
continue
|
||||
try:
|
||||
package_hash = fetch_git_hash(url, rev)
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
output[name] = package_hash
|
||||
GIT_HASHES.write_text(json.dumps(output, indent=2) + "\n")
|
||||
output[name] = fetch_git_hash(url, rev)
|
||||
output_json = json.dumps(output, indent=2, sort_keys=True) + "\n"
|
||||
if output_file:
|
||||
output_file.write_text(output_json)
|
||||
else:
|
||||
print(output_json, end="")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Reference in New Issue
Block a user