-
Notifications
You must be signed in to change notification settings - Fork 21
/
flake.nix
92 lines (73 loc) · 2.57 KB
/
flake.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
description = "AresRPG nix flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
inputLock = (builtins.fromJSON (builtins.readFile ./package-lock.json));
rewriteDep = package: package //
(if package ? resolved then {
resolved = "file://${pkgs.fetchurl {
url = package.resolved;
outputHashAlgo = builtins.elemAt (builtins.split "-" package.integrity) 0;
outputHash = builtins.elemAt (builtins.split "-" package.integrity) 2;
}}";
} else {}) //
(if package ? dependencies then {
dependencies = rewriteDeps package.dependencies;
} else {});
rewriteDeps = dependencies: builtins.mapAttrs (name: rewriteDep) dependencies;
outputLock = builtins.toJSON ({ lockfileVersion = 2; dependencies = rewriteDeps inputLock.dependencies; });
# TODO: remove when flakes support submodules
floor1 = pkgs.fetchFromGitHub {
owner = "aresrpg";
repo = "floor1";
rev = "644a2e4206343ef6e989ccbb28c62a4d0a5d5fb0";
sha256 = "WuKsDHpWmgJlqNCQ9Z5V75P5AF1w3cOIDbuMxQ/EGaw=";
};
aresrpg = pkgs.stdenv.mkDerivation {
name = "aresrpg";
nativeBuildInputs = [ pkgs.nodejs-16_x ];
src = ./.;
passAsFile = [ "packageLock" ];
packageLock = outputLock;
NO_UPDATE_NOTIFIER = true;
installPhase = ''
cp --no-preserve=mode -r $src $out
cd $out
cp $packageLockPath package-lock.json
ln -s ${floor1} world/floor1
npm ci --production
'';
};
in
{
devShell = pkgs.mkShell {
buildInputs = [
pkgs.nodejs-16_x
pkgs.libuuid
pkgs.cairo
pkgs.pango
pkgs.libjpeg
pkgs.giflib
pkgs.librsvg
pkgs.python3
pkgs.pkg-config
];
};
dockerImage = pkgs.dockerTools.buildImage {
name = "aresrpg";
tag = "latest";
config = {
Cmd = [ "${pkgs.nodejs-16_x}/bin/node" "${aresrpg}/src/index.js" ];
ExposedPorts = {
"25565/tcp" = {};
};
};
};
}
);
}