Added fetchfirefoxaddon
This commit is contained in:
parent
eedee46f2f
commit
397597f731
@ -35,9 +35,13 @@ let
|
|||||||
, cfg ? config.${browserName} or {}
|
, cfg ? config.${browserName} or {}
|
||||||
|
|
||||||
## Following options are needed for extra prefs & policies
|
## Following options are needed for extra prefs & policies
|
||||||
|
# For more information about anti tracking (german website)
|
||||||
|
# vist https://wiki.kairaven.de/open/app/firefo
|
||||||
, extraPrefs ? ""
|
, extraPrefs ? ""
|
||||||
|
# For more information about policies visit
|
||||||
|
# https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
|
||||||
, extraPolicies ? {}
|
, extraPolicies ? {}
|
||||||
, firefoxLibName ? "firefox"
|
, firefoxLibName ? "firefox" # Important for tor package or the like
|
||||||
, extraExtensions ? [ ]
|
, extraExtensions ? [ ]
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -98,37 +102,10 @@ let
|
|||||||
(builtins.toJSON enterprisePolicies);
|
(builtins.toJSON enterprisePolicies);
|
||||||
|
|
||||||
extensions = builtins.map (a:
|
extensions = builtins.map (a:
|
||||||
if ! (builtins.hasAttr "name" a) || ! (builtins.isString a.name) then
|
if ! (builtins.hasAttr "extid" a) then
|
||||||
throw "Firefox addon needs a name attribute"
|
throw "extraExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
|
||||||
else if ! (builtins.hasAttr "url" a) || ! (builtins.isString a.url) then
|
else
|
||||||
throw "Addon ${a.pname} needs an url"
|
a
|
||||||
else if ! (builtins.hasAttr "sha256" a) || ! (builtins.isString a.sha256) then
|
|
||||||
throw "Addon ${a.pname} needs an sha256 checksum"
|
|
||||||
else stdenv.mkDerivation rec {
|
|
||||||
pname = a.name;
|
|
||||||
version = "1.0";
|
|
||||||
src = fetchurl {
|
|
||||||
url = a.url;
|
|
||||||
sha256 = a.sha256;
|
|
||||||
};
|
|
||||||
|
|
||||||
phases = [ "buildPhase" ];
|
|
||||||
|
|
||||||
extid = "${a.sha256}@${a.name}";
|
|
||||||
|
|
||||||
buildInputs = [ zip unzip jq ];
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
UUID="${extid}"
|
|
||||||
mkdir -p "$out/$UUID"
|
|
||||||
unzip -q ${src} -d "$out/$UUID"
|
|
||||||
NEW_MANIFEST=$(jq '. + {"applications": { "gecko": { "id": "${extid}" }}, "browser_specific_settings":{"gecko":{"id": "${extid}"}}}' "$out/$UUID/manifest.json")
|
|
||||||
echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
|
|
||||||
cd "$out/$UUID"
|
|
||||||
zip -r -q -FS "$out/$UUID.xpi" *
|
|
||||||
rm -r "$out/$UUID"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
) extraExtensions;
|
) extraExtensions;
|
||||||
|
|
||||||
enterprisePolicies =
|
enterprisePolicies =
|
||||||
|
38
pkgs/build-support/fetchfirefoxaddon/default.nix
Normal file
38
pkgs/build-support/fetchfirefoxaddon/default.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
|
||||||
|
let
|
||||||
|
|
||||||
|
in
|
||||||
|
{ name,
|
||||||
|
url,
|
||||||
|
sha256,
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
|
||||||
|
inherit name;
|
||||||
|
extid = "${sha256}@${name}";
|
||||||
|
passthru = {
|
||||||
|
exitd=extid;
|
||||||
|
};
|
||||||
|
|
||||||
|
builder = writeScript "xpibuilder" ''
|
||||||
|
source $stdenv/setup
|
||||||
|
|
||||||
|
header "firefox addon $name into $out"
|
||||||
|
|
||||||
|
UUID="${extid}"
|
||||||
|
mkdir -p "$out/$UUID"
|
||||||
|
unzip -q ${src} -d "$out/$UUID"
|
||||||
|
NEW_MANIFEST=$(jq '. + {"applications": { "gecko": { "id": "${extid}" }}, "browser_specific_settings":{"gecko":{"id": "${extid}"}}}' "$out/$UUID/manifest.json")
|
||||||
|
echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
|
||||||
|
cd "$out/$UUID"
|
||||||
|
zip -r -q -FS "$out/$UUID.xpi" *
|
||||||
|
rm -r "$out/$UUID"
|
||||||
|
'';
|
||||||
|
src = fetchurl {
|
||||||
|
url = url;
|
||||||
|
sha256 = sha256;
|
||||||
|
};
|
||||||
|
nativeBuildInputs = [ coreutils unzip zip jq ];
|
||||||
|
}
|
||||||
|
|
@ -365,6 +365,8 @@ in
|
|||||||
|
|
||||||
fetchhg = callPackage ../build-support/fetchhg { };
|
fetchhg = callPackage ../build-support/fetchhg { };
|
||||||
|
|
||||||
|
fetchfirefoxaddon = callPackage ../build-support/fetchfirefoxaddon {};
|
||||||
|
|
||||||
# `fetchurl' downloads a file from the network.
|
# `fetchurl' downloads a file from the network.
|
||||||
fetchurl = if stdenv.buildPlatform != stdenv.hostPlatform
|
fetchurl = if stdenv.buildPlatform != stdenv.hostPlatform
|
||||||
then buildPackages.fetchurl # No need to do special overrides twice,
|
then buildPackages.fetchurl # No need to do special overrides twice,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user