-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
cached-profiles.nix
45 lines (39 loc) · 1.24 KB
/
cached-profiles.nix
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
# To search through openwrt profiles we need the `sha256sums` and
# `profiles.json` files for all platforms locally. Therefore it makes
# sense to cache them given that we already update hashes daily.
{ pkgs ? import <nixpkgs> {}
}:
let
inherit (pkgs) lib;
inherit (import ./releases.nix { inherit pkgs; }) releases;
writeProfiles = release:
let
hashes = import ./hashes/${release}.nix;
profiles =
builtins.mapAttrs (target: variants:
lib.filterAttrs (_: profiles:
profiles != null
) (
builtins.mapAttrs (variant: h:
(import ./files.nix {
inherit pkgs release target variant;
inherit (h) sha256 feedsSha256;
}).profiles
) variants
)
) hashes.targets;
in pkgs.writeText "openwrt-cached-profiles-${release}.nix" (
lib.generators.toPretty {} profiles
);
in
pkgs.runCommand "openwrt-cached-profiles" {
passthru = lib.listToAttrs (map (release: {
name = builtins.replaceStrings [ "." ] [ "_" ] release;
value = writeProfiles release;
}) releases);
} ''
mkdir $out
${lib.concatMapStrings (release: ''
ln -s ${writeProfiles release} $out/${release}.nix
'') releases}
''