forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / by-name / ha / halo / package.nix
blobff4a6ba444290b63c95f7f91accc43f97eb9f7f1
1 { lib
2 , stdenv
3 , fetchurl
4 , makeWrapper
5   # official jre size is 500MB, but temurin-jre-bin is 100MB.
6 , temurin-jre-bin
7 }:
8 stdenv.mkDerivation rec {
9   pname = "halo";
10   version = "2.20.5";
11   src = fetchurl {
12     url = "https://github.com/halo-dev/halo/releases/download/v${version}/halo-${version}.jar";
13     hash = "sha256-VGSSGc2caNO7+IK1ArqjZGz+LaHWZsaO68Jr06BCcfE=";
14   };
16   nativeBuildInputs = [
17     makeWrapper
18     temurin-jre-bin
19   ];
21   dontBuild = true;
22   dontConfigure = true;
24   unpackPhase = ''
25     cp $src halo.jar
26     # Extract the jar file.
27     # Because jar vs extract, jar startup time is 4s slower than extract.
28     java -Djarmode=tools -jar halo.jar extract --layers --launcher
29   '';
31   installPhase = ''
32     runHook preInstall
34     mkdir -p $out/share/halo
35     find halo -type d -empty -delete
36     for target in halo/*; do
37       cp -r $target/* $out/share/halo
38     done
40     # 'HALO_WORK_DIR'
41     # Set the working directory for halo, then plug-ins and other content will be stored in this directory.
42     # Note: that the '/' symbol is not required at the end of the path.
43     # default: /var/lib/halo
44     # 'JVM_OPTS'
45     # Note: 'apache.lucene' requires us to set HotspotVMOptions.
46     # You can override this via environment variables.
47     # default: -Xms256m -Xmx256m
48     # 'SPRING_CONFIG_LOCATION'
49     # Note: 'spring.config.location' is used to specify the configuration file location.
50     # Warning: This variable is based on "HALO_WORK_DIR", you do not need and should not set or override it.
51     mkdir -p $out/bin
52     makeWrapper ${temurin-jre-bin}/bin/java $out/bin/halo \
53       --chdir $out/share/halo \
54       --set-default HALO_WORK_DIR "/var/lib/halo" \
55       --set-default JVM_OPTS "-Xms256m -Xmx256m" \
56       --set SPRING_CONFIG_LOCATION "optional:classpath:/;optional:file:\`\$HALO_WORK_DIR\`/" \
57       --add-flags "-server \$JVM_OPTS" \
58       --add-flags "org.springframework.boot.loader.launch.JarLauncher"
60     runHook postInstall
61   '';
63   meta = {
64     homepage = "https://www.halo.run";
65     description = "Self-hosted dynamic blogging program";
66     maintainers = with lib.maintainers; [ yah ];
67     license = lib.licenses.gpl3Only;
68     platforms = [ "aarch64-linux" "x86_64-linux" ];
69     mainProgram = "halo";
70     sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
71   };