nixos-config/pkgs/watcharr/default.nix

64 lines
1.4 KiB
Nix

{ lib
, pkgs
, buildGoModule
, fetchFromGitHub
, buildNpmPackage
, nixosTests
, caddy
, testers
, installShellFiles
, stdenv
}:
let
version = "1.39.0";
src = fetchFromGitHub {
owner = "sbondCo";
repo = "Watcharr";
rev = "v${version}";
sha256 = "sha256-40XLYc1ub2Qzf8r9g+Ay8Y8CAHYU+P9CI60heLAuQkE=";
};
frontend = buildNpmPackage {
pname = "watcharr-ui";
inherit version src;
npmDepsHash = "sha256-sigkeK1bLbZfOU8756yLt5avqnOJWC4t4TnV6EvFTPY=";
installPhase = ''
cp -r build $out
cp package.json package-lock.json $out
cd $out && npm ci --omit=dev
'';
};
in
buildGoModule {
pname = "watcharr";
inherit version;
src = src + "/server";
vendorHash = "sha256-vmroCetQc1Ix65B2Br33lyWt0FwGeQXMoD5fLinQg28=";
# Inject frontend assets into go embed
prePatch = ''
# rm -rf ui
# ln -s ${frontend} ui
substituteInPlace watcharr.go \
--replace-fail ui/index.js ${frontend}/index.js
'';
buildInputs = [ pkgs.makeWrapper ];
postFixup = ''
wrapProgram "$out/bin/Watcharr" --prefix PATH : "${lib.makeBinPath [ pkgs.nodejs ]}"
'';
meta = with lib; {
homepage = "https://watcharr.app/";
description = "Open source, self-hostable watched list for all your content with user authentication, modern and clean UI and a very simple setup";
license = licenses.asl20;
# mainProgram = "caddy";
maintainers = with maintainers; [ nyanloutre ];
};
}