Unverified Commit f3be6990 authored by Robert Schütz's avatar Robert Schütz Committed by GitHub
Browse files

Merge pull request #245426 from dotlambda/psitransfer-buildNpmPackage

psitransfer: use buildNpmPackage
parents e0d40b94 4fb0a77d
Loading
Loading
Loading
Loading
+42 −37
Original line number Diff line number Diff line
# To update package version:
#   1. Change version string in node-package.json and this file
#   2. Run `./generate.sh` to rebuild node dependencies with node2nix
#   3. Build this package `nix-build -A psitransfer`
#   4. Profit

{ stdenv
, pkgs
, lib
, nodejs_18
, fetchzip
{ lib
, buildNpmPackage
, fetchFromGitHub
}:

let
  nodejs = nodejs_18;

  nodePackages = import ./node-composition.nix {
    inherit pkgs nodejs;
    inherit (stdenv.hostPlatform) system;
  pname = "psitransfer";
  version = "2.1.2";
  src = fetchFromGitHub {
    owner = "psi-4ward";
    repo = "psitransfer";
    rev = "v${version}";
    hash = "sha256-dBAieXIwCEstR9m+6+2/OLPKo2qHynZ1t372Il0mkXk=";
  };
  app = buildNpmPackage {
    pname = "${pname}-app";
    inherit version src;

  psitransfer = lib.head (lib.attrValues nodePackages);
    npmDepsHash = "sha256-iCd+I/aTMwQqAMRHan3T191XNz4S3Cy6CDxSLIYY7IA=";

  combined = psitransfer.override rec {
    # version is not defined in source package.json
    # version must also be maintained in node-packages.json for node2nix
    version = "2.1.2";
    postPatch = ''
      # https://github.com/psi-4ward/psitransfer/pull/284
      touch public/app/.npmignore
      cd app
    '';

    # override node2nix package src to pull pre-built release of same version
    src = fetchzip {
      url = "https://github.com/psi-4ward/psitransfer/releases/download/v${version}/psitransfer-v${version}.tar.gz";
      sha256 = "mfldWTVmfcIRa+1g8YDnQqem5YmrFRfCxJoitWcXvns=";
      stripRoot = false;
    installPhase = ''
      cp -r ../public/app $out
    '';
  };
in buildNpmPackage {
  inherit pname version src;

  npmDepsHash = "sha256-H22T5IU8bjbsWhwhchDqppvYfcatbXSWqp6gdoek1Z8=";

    meta = with lib; {
  postPatch = ''
    rm -r public/app
    cp -r ${app} public/app
  '';

  dontBuild = true;

  meta = {
    homepage = "https://github.com/psi-4ward/psitransfer";
    description = "Simple open source self-hosted file sharing solution";
      license = licenses.bsd2;
      maintainers = with maintainers; [ hyshka ];
    };
    license = lib.licenses.bsd2;
    maintainers = with lib.maintainers; [ hyshka ];
  };
in
  combined
}
+0 −11
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix
set -euo pipefail

node2nix \
  --nodejs-18 \
  --input node-packages.json \
  --output node-packages.nix \
  --composition node-composition.nix \
  --node-env ../../development/node-packages/node-env.nix \
  ;
+0 −17
Original line number Diff line number Diff line
# This file has been generated by node2nix 1.11.1. Do not edit!

{pkgs ? import <nixpkgs> {
    inherit system;
  }, system ? builtins.currentSystem, nodejs ? pkgs.nodejs_18}:

let
  nodeEnv = import ../../development/node-packages/node-env.nix {
    inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
    inherit pkgs nodejs;
    libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
  };
in
import ./node-packages.nix {
  inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
  inherit nodeEnv;
}
+0 −3
Original line number Diff line number Diff line
[
  { "psitransfer": "git+https://github.com/psi-4ward/psitransfer#v2.1.2" }
]
+0 −1781

File deleted.

Preview size limit exceeded, changes collapsed.