forked from Rockbox/rockbox
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
118 lines (100 loc) · 3.35 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
description = "Rockbox Zig project flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
zig2nix.url = "github:Cloudef/zig2nix";
};
outputs = { zig2nix, nixpkgs, ... }: let
flake-utils = zig2nix.inputs.flake-utils;
in (flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib;
# Zig flake helper
# Check the flake.nix in zig2nix project for more options:
# <https://github.com/Cloudef/zig2nix/blob/master/flake.nix>
env = zig2nix.outputs.zig-env.${system} { zig = pkgs.zig; };
system-triple = env.lib.zigTripleFromString system;
in with builtins; with env.lib; with env.pkgs.lib; rec {
# nix build .#target.{zig-target}
# e.g. nix build .#target.x86_64-linux-gnu
packages.target = genAttrs allTargetTriples (target: env.packageForTarget target ({
src = cleanSource ./.;
nativeBuildInputs = with env.pkgs; [];
buildInputs = with env.pkgsForTarget target; [
pkgs.zig
pkgs.SDL_compat
pkgs.freetype
pkgs.gnumake
pkgs.pkg-config
pkgs.gcc
pkgs.zlib
pkgs.cargo
pkgs.rustc
pkgs.protobuf
pkgs.buf
pkgs.libunwind
];
# Smaller binaries and avoids shipping glibc.
zigPreferMusl = false;
# This disables LD_LIBRARY_PATH mangling, binary patching etc...
# The package won't be usable inside nix.
zigDisableWrap = false;
} // optionalAttrs (!pathExists ./build.zig.zon) {
pname = "rockbox-zig";
version = "0.1.0";
}));
# nix build .
packages.default = packages.target.${system-triple}.override {
# Prefer nix friendly settings.
zigPreferMusl = false;
zigDisableWrap = false;
};
# For bundling with nix bundle for running outside of nix
# example: https://github.com/ralismark/nix-appimage
apps.bundle.target = genAttrs allTargetTriples (target: let
pkg = packages.target.${target};
in {
type = "app";
program = "${pkg}/bin/default";
});
# default bundle
apps.bundle.default = apps.bundle.target.${system-triple};
# nix run .
apps.default = env.app [] "zig build run -- \"$@\"";
# nix run .#build
apps.build = env.app [] "zig build \"$@\"";
# nix run .#test
apps.test = env.app [] "zig build test -- \"$@\"";
# nix run .#docs
apps.docs = env.app [] "zig build docs -- \"$@\"";
# nix run .#deps
apps.deps = env.showExternalDeps;
# nix run .#zon2json
apps.zon2json = env.app [env.zon2json] "zon2json \"$@\"";
# nix run .#zon2json-lock
apps.zon2json-lock = env.app [env.zon2json-lock] "zon2json-lock \"$@\"";
# nix run .#zon2nix
apps.zon2nix = env.app [env.zon2nix] "zon2nix \"$@\"";
# nix develop
devShells.default = env.mkShell {
nativeBuildInputs = with env.pkgs; [
pkgs.zig
pkgs.SDL_compat
pkgs.freetype
pkgs.gnumake
pkgs.pkg-config
pkgs.gcc
pkgs.zlib
pkgs.cargo
pkgs.rustc
pkgs.protobuf
pkgs.buf
pkgs.libunwind
pkgs.evans
pkgs.grpcurl
];
};
}));
}