-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should speed up the identifyProfiles call for users who do not want to download sha256sums and profiles.json for all platforms.
- Loading branch information
Showing
26 changed files
with
951,078 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# 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; | ||
|
||
# Only OpenWrt >= 19.07.4 contains profiles.json files | ||
releases = | ||
builtins.filter (release: | ||
builtins.compareVersions release "19.07.4" >= 0 | ||
) ( | ||
map (builtins.replaceStrings [ ".nix" ] [ "" ]) ( | ||
builtins.filter (lib.hasSuffix ".nix") ( | ||
builtins.attrNames (builtins.readDir ./hashes) | ||
) | ||
) | ||
); | ||
|
||
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} | ||
'' |
Oops, something went wrong.