-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflake.nix
69 lines (58 loc) · 1.99 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) lib stdenv;
# Major Node.js version.
nodejs = pkgs.nodejs_20;
corepack = pkgs.corepack.override {
inherit nodejs;
};
# Packages required to build the `canvas` npm package.
nativeCanvasDeps = with pkgs; [ python3 pkg-config ];
canvasDeps = with pkgs; (
[ pixman cairo pango libjpeg ]
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks;
[ CoreText xcbuild ]
)
);
# Import and amend the app build from yarn-plugin-nixify.
package = pkgs.callPackage ./yarn-project.nix
{
inherit nodejs;
}
{
src = ./.;
overrideAttrs = old: {
buildPhase = "yarn build";
checkPhase = "yarn test";
doCheck = true;
};
overrideCanvasAttrs = old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ nativeCanvasDeps;
buildInputs = (old.buildInputs or [ ]) ++ canvasDeps;
env = lib.optionalAttrs (stdenv.isDarwin && stdenv.isx86_64) {
NIX_CFLAGS_COMPILE = "-D__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__=101300";
};
};
};
in
{
# For `nix build`
packages.default = package;
# For `nix develop`
devShells.default = pkgs.mkShell {
nativeBuildInputs = nativeCanvasDeps;
buildInputs = (with pkgs; [ postgresql nixpkgs-fmt ])
++ canvasDeps
++ [ nodejs corepack ];
};
# For `nix flake check`
checks.default = import ./functional-test/run.nix package pkgs;
});
}