-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcached-packages.nix
More file actions
58 lines (53 loc) · 1.85 KB
/
cached-packages.nix
File metadata and controls
58 lines (53 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ openwrtLib
, release
, target
, variant
# Manually specify packages' arch for OpenWRT<19 releases without profiles.json
, packagesArch ? throw "packagesArch must be given for OpenWRT<19 releases"
# Users may supply their own fresh hashes
, cachePath ? openwrtLib.getCachePath release
}:
let
raw = let
r = openwrtLib.getCachedRelease release cachePath;
t = r.targets.${target} or (throw "Target \"${target}\" does not exist in release \"${release}\"");
in
t.${variant} or (throw "Variant \"${variant}\" does not exist in target \"${target}\" of release \"${release}\"");
# Package manager: opkg or apk?
apk = openwrtLib.releaseAtLeast release "25";
# kmods have their own packages file
kmodsSeparate = openwrtLib.releaseAtLeast release "24";
# releases without profiles.json
noProfiles = openwrtLib.releaseOlder release "19";
profiles = raw.profiles.extract or null;
feeds = if noProfiles || !(raw ? packagesArch)
then import (cachePath + "/packages/${packagesArch}.nix")
else raw.feeds;
in {
inherit apk kmodsSeparate noProfiles profiles;
pkgExt = if apk then "apk" else "ipk";
# baseUrl = lib.removeSuffix "/sha256sums" raw.sha256sums.url;
inherit (raw) baseUrl;
imagebuilder = with raw.imagebuilder; {
inherit sha256;
name = filename;
url = "${raw.baseUrl}/${filename}";
};
} // (if kmodsSeparate then {
kmodPackages = {
inherit (raw.kmods.${profiles.kmods_target}) baseUrl sourceInfo packages;
inherit (raw) sha256sums;
prefix = "kmods/${profiles.kmods_target}/";
};
} else { }) // {
corePackages = {
inherit (raw.corePackages) baseUrl sourceInfo packages;
inherit (raw) sha256sums;
prefix = "packages/";
};
feeds = builtins.mapAttrs (feedName: feed: {
inherit (feed) baseUrl sourceInfo packages;
inherit (feeds) sha256sums;
prefix = "${feedName}/";
}) feeds.feeds;
}