Skip to content

Commit f83aa88

Browse files
committed
filter package results in python script
1 parent d5954f3 commit f83aa88

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
drvs = pkgs.lib.mapAttrs (_: pkg: { inherit (pkg) drvPath version isLocal; }) purenix-pkgs.prelude.package-set;
4343
in
4444
{
45-
hello = drvs;
45+
inherit drvs;
4646
packages = purenix-pkgs // { inherit all-packages package-set; };
4747
apps = { };
4848
devShells = {

package-set.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python success.py | jq 'to_entries | map(select(.value.success==true)) | map({key: .key, value: .value.derivation.version}) | from_entries'
1+
python success.py | jq .

success.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import json
22
import subprocess
33
import sys
4+
from datetime import datetime
5+
import argparse
6+
7+
parser = argparse.ArgumentParser()
8+
parser.add_argument('--system', type=str, default='x86_64-linux')
9+
args = parser.parse_args()
410

511
with open("flake.lock", "r") as f:
612
lockfile = json.load(f)
713
locked = lockfile['nodes']['purenix-base']['locked']
814
repo = f'https://github.com/{locked["owner"]}/{locked["repo"]}.git'
915
ref = locked["rev"]
10-
result = subprocess.Popen(["nix", "eval", ".#hello.x86_64-linux", "--json"], stdout=subprocess.PIPE).stdout.read()
16+
result = subprocess.Popen(["nix", "eval", f".#drvs.{args.system}", "--json"], stdout=subprocess.PIPE).stdout.read()
1117
package_set = json.loads(result)
1218
derivations = list(p['drvPath'] for p in package_set.values())
1319
build_results = subprocess.Popen(["nix-build-results"] + derivations, stdout=subprocess.PIPE).stdout.read()
@@ -19,5 +25,12 @@ def update_version(name, value, subdir):
1925
return value | {'version': {'git': repo, 'ref': ref, 'subdir': subdir}}
2026
else:
2127
return value
22-
final = {k: res[v['drvPath']] | {"derivation": update_version(k, v, f'purescript-{k}')} for k, v in package_set.items()}
23-
print(json.dumps(final))
28+
named = {k: res[v['drvPath']] | {"derivation": update_version(k, v, f'purescript-{k}')} for k, v in package_set.items()}
29+
final = {k: v['derivation']['version'] for k, v in named.items() if v['success'] == True}
30+
today = datetime.today().strftime('%Y-%m-%d')
31+
output = {
32+
'packages': final,
33+
'compiler': '0.15.7',
34+
'published': today,
35+
}
36+
print(json.dumps(output))

0 commit comments

Comments
 (0)