-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefault.nix
78 lines (65 loc) · 1.81 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
pkgs ? let
lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
nixpkgs = fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
sha256 = lock.narHash;
};
in
import nixpkgs {overlays = [];},
...
}: let
manifest = pkgs.lib.importJSON ./package.json;
exec = pkgs.writeShellScript "${manifest.name}-start.sh" ''
# Change working directory to script
cd "$(dirname "$0")/../lib"
${pkgs.lib.getExe pkgs.nodejs} ./server.js
'';
in
# pkgs.stdenv.mkDerivation {
pkgs.buildNpmPackage {
pname = manifest.name;
version = manifest.version;
src = ./.;
npmDepsHash = "sha256-QZ2orsvo9mx6wNsdvwc67u3vXr6/nhH7vFoE+ViarKE=";
installPhase = ''
# Create output directory
mkdir -p $out
# Copy standalone as library
cp -R ./.next/standalone $out/lib
# Copy static contents
if [ -d "./.next/static" ]; then
cp -R ./.next/static $out/lib/.next/static
fi
# Copy public assets
if [ -d "./public" ]; then
cp -R ./public $out/lib/public
fi
# Create executable directory
mkdir -p $out/bin
# Copy shell script to executables
cp -r ${exec} $out/bin/${manifest.name}-start
'';
nativeBuildInputs = with pkgs; [
# Typescript
nodejs
pnpm
corepack
# Hail the Nix
nixd
statix
alejandra
];
buildInputs = with pkgs; [
openssl
vips
];
meta = with pkgs.lib; {
homepage = "https://floss.uz";
mainProgram = "${manifest.name}-start";
description = "Website of Floss Uzbekistan community";
license = with licenses; [cc-by-40];
platforms = with platforms; linux ++ darwin;
maintainers = with maintainers; [orzklv];
};
}