-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefault.nix
36 lines (34 loc) · 1.11 KB
/
default.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
{ lib, recurseIntoAttrs, fetchurl, runCommand, callPackage, overrides ? (self: super: {}) }:
let apps = (self:
let
appJson = version: builtins.fromJSON (builtins.readFile (./. + "/${version}.json"));
versions = (callPackage ./nc-versions.nix {}).n;
apps = builtins.listToAttrs (map (v: let
majorVer = lib.versions.major v;
in {
name = "nextcloud-${majorVer}";
value = recurseIntoAttrs (builtins.mapAttrs mkApp (appJson majorVer));
}) versions);
mkApp = name: value: runCommand "nc-app-${name}-${value.version}" {
src = fetchurl {
inherit (value) url hash;
};
inherit (value) version;
} /* sh */ ''
mkdir _unp
tar -xpf "$src" -C _unp
if [ $(find _unp -mindepth 1 -maxdepth 1 -type d | wc -l) != 1 ]; then
echo "error: zip file must contain a single directory"
exit 1
fi
mkdir -p $out
cp -R _unp/*/. $out/
if [ ! -f "$out/appinfo/info.xml" ]; then
echo "appinfo/info.xml doesn't exist in $out, aborting!"
exit 2
fi
'';
in
apps
);
in lib.fix' (lib.extends overrides apps)