-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
100 lines (83 loc) · 2.16 KB
/
default.nix
File metadata and controls
100 lines (83 loc) · 2.16 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
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 data
manifest = pkgs.lib.importJSON ./package.json;
# All source codes
source = ./.;
# Executable
exec = pkgs.writeShellScript "${manifest.name}-start.sh" ''
# Change working directory to script
cd "$(dirname "$0")/../lib"
# Start the stadalone server
${pkgs.lib.getExe pkgs.nodejs} ./server.js
'';
in
pkgs.stdenv.mkDerivation {
pname = manifest.name;
version = manifest.version;
src = source;
nativeBuildInputs = with pkgs; [
nodejs_22
pnpmConfigHook
pnpm
typescript
vips
];
preBuild = ''
cp "${
pkgs.google-fonts.override { fonts = [ "Inter" ]; }
}/share/fonts/truetype/Inter[opsz,wght].ttf" ./src/app/Inter.ttf
'';
buildPhase = ''
# Build the package
pnpm build
'';
installPhase = ''
# Create output directory
mkdir -p $out
cat ./next.config.ts
ls -la ./.next
# Copy standalone as library
cp -r ./.next/standalone $out/lib
# Create filler folders
mkdir -p $out/lib/.next
# 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
'';
pnpmDeps = pkgs.fetchPnpmDeps {
pname = manifest.name;
version = manifest.version;
src = source;
fetcherVersion = 3;
hash = "sha256-8Dkm2OIvJhzQb5ExfqmwCggpVeveySniZ55+bwpfeDw=";
};
meta = with pkgs.lib; {
homepage = "https://uchar.uz";
mainProgram = "${manifest.name}-start";
description = "Website of Uchar";
license = with licenses; [ cc-by-40 ];
platforms = with platforms; linux ++ darwin;
maintainers = with maintainers; [ orzklv ];
};
}