teutat3s
f19ee88860
manually invoke sticker-pack from the devshell to upload stickers to matrix, to avoid leaking the access token from config.json to the nix store. Nixify SigStickers https://github.com/FHPythonUtils/SigStickers and dependency https://github.com/signalstickers/signalstickers-client to download Signal stickers
75 lines
1.6 KiB
Nix
75 lines
1.6 KiB
Nix
{
|
|
lib,
|
|
maunium-stickerpicker,
|
|
stickerpicker-tools,
|
|
fetchers,
|
|
|
|
callPackage,
|
|
stdenvNoCC,
|
|
writeText,
|
|
|
|
cacert,
|
|
...
|
|
}:
|
|
{
|
|
homeserver ? "https://matrix.org",
|
|
userId,
|
|
packs,
|
|
hash ? "",
|
|
sha256 ? ""
|
|
}:
|
|
with lib;
|
|
if !(all builtins.isAttrs packs) then
|
|
throw "createStickerPack: not all packs are attrsets"
|
|
else if !(all (x: x ? "type") packs) then
|
|
throw ''createStickerPack: Not all packs have the "type" attribute''
|
|
else if !(all (x: builtins.isString x.type) packs) then
|
|
throw ''createStickerPack: Not all packs have a "type" attribute of type string''
|
|
else let
|
|
invalidTypes = filter (x: !(fetchers ? "${x.type}-build")) packs;
|
|
in if invalidTypes != [ ] then throw ''
|
|
createStickerPack: Not all packs have a valid "type" attribute.
|
|
|
|
The following types does not exist:
|
|
${concatStringsSep "\n" (map (x: " ${x.type}") invalidTypes)}
|
|
''
|
|
else let
|
|
stickerDownloadInstructions = pipe packs [
|
|
(map (x: fetchers."${x.type}-build" x))
|
|
(concatStringsSep "\n")
|
|
];
|
|
|
|
stickerDownloadDependencies = pipe packs [
|
|
(map (x: fetchers."${x.type}-deps"))
|
|
builtins.concatLists
|
|
];
|
|
in stdenvNoCC.mkDerivation {
|
|
name = "stickerpicker";
|
|
src = maunium-stickerpicker;
|
|
|
|
outputHashAlgo = if hash != "" then null else "sha256";
|
|
outputHashMode = "recursive";
|
|
outputHash = if hash != "" then
|
|
hash
|
|
else if sha256 != "" then
|
|
sha256
|
|
else
|
|
fakeSha256;
|
|
|
|
buildInputs = [
|
|
stickerpicker-tools
|
|
cacert
|
|
] ++ stickerDownloadDependencies;
|
|
|
|
buildPhase = ''
|
|
mkdir images
|
|
IMG_DIR="$(pwd)/images"
|
|
|
|
${stickerDownloadInstructions}
|
|
'';
|
|
|
|
installPhase = ''
|
|
cp -r . $out
|
|
'';
|
|
}
|