Unverified Commit b56cca17 authored by Arne Keller's avatar Arne Keller Committed by GitHub
Browse files

opengist: 1.9.1 -> 1.10.0 , use writableTmpDirAsHomeHook and finalAttrs pattern (#397960)

parents 940cd49d 30d504d0
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -7,24 +7,28 @@
  moreutils,
  jq,
  git,
  writableTmpDirAsHomeHook,
}:
let
  # finalAttrs when 🥺 (buildGoModule does not support them)
  # https://github.com/NixOS/nixpkgs/issues/273815
  version = "1.9.1";

buildGoModule (finalAttrs: {
  pname = "opengist";

  version = "1.10.0";

  src = fetchFromGitHub {
    owner = "thomiceli";
    repo = "opengist";
    tag = "v${version}";
    hash = "sha256-Zjn38OGnDtgD2OfIhgUxWo0Cx+ZmNv6UjJanASbjiYU=";
    tag = "v${finalAttrs.version}";
    hash = "sha256-cSPKtcD1V+WTSCkgi8eKhGbtW+WdCoetbiSrNvEVRW4=";
  };

  frontend = buildNpmPackage {
    pname = "opengist-frontend";
    inherit version src;
    inherit (finalAttrs) version src;

    # npm complains of "invalid package". shrug. we can give it a version.
    postPatch = ''
      ${lib.getExe jq} '.version = "${version}"' package.json | ${lib.getExe' moreutils "sponge"} package.json
      ${lib.getExe jq} '.version = "${finalAttrs.version}"' package.json | ${lib.getExe' moreutils "sponge"} package.json
    '';

    # copy pasta from the Makefile upstream, seems to be a workaround of sass
@@ -41,41 +45,37 @@ let

    npmDepsHash = "sha256-Uh+oXd//G/lPAMXRxijjEOpQNmeXK/XCIU7DJN3ujaY=";
  };
in
buildGoModule {
  pname = "opengist";
  inherit version src;
  vendorHash = "sha256-aqfr3yGyTXDtZDU8d1lbWWvFfY4fo6/PsSDwpiDtM90=";

  vendorHash = "sha256-m2f9+PEMjVhlXs7b1neEWO0VY1fQSfe+T1aNEdtML28=";

  tags = [ "fs_embed" ];

  ldflags = [
    "-s"
    "-X github.com/thomiceli/opengist/internal/config.OpengistVersion=v${version}"
    "-X github.com/thomiceli/opengist/internal/config.OpengistVersion=v${finalAttrs.version}"
  ];

  # required for tests
  nativeCheckInputs = [
    git
    writableTmpDirAsHomeHook
  ];

  # required for tests to not try to write into $HOME and fail
  preCheck = ''
    export OG_OPENGIST_HOME=$(mktemp -d)
  '';

  doCheck = !stdenv.hostPlatform.isDarwin;

  checkPhase = ''
    runHook preCheck

    make test

    runHook postCheck
  '';

  postPatch = ''
    cp -R ${frontend}/public/{manifest.json,assets} public/
    cp -R ${finalAttrs.frontend}/public/{manifest.json,assets} public/
  '';

  passthru = {
    inherit frontend;
    inherit (finalAttrs) frontend;
    updateScript = ./update.sh;
  };

@@ -83,9 +83,9 @@ buildGoModule {
    description = "Self-hosted pastebin powered by Git";
    homepage = "https://github.com/thomiceli/opengist";
    license = lib.licenses.agpl3Only;
    changelog = "https://github.com/thomiceli/opengist/blob/${src.tag}/CHANGELOG.md";
    changelog = "https://github.com/thomiceli/opengist/blob/v${finalAttrs.version}/CHANGELOG.md";
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ phanirithvij ];
    mainProgram = "opengist";
  };
}
})