-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflake.nix
More file actions
132 lines (118 loc) · 4.04 KB
/
Copy pathflake.nix
File metadata and controls
132 lines (118 loc) · 4.04 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
description = "Paiagram development flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
# We pull in the nightly rustfmt specifically to get access to unstable formatting features
# like `imports_granularity` while keeping the rest of our toolchain completely stable.
nightlyRustfmt = pkgs.rust-bin.nightly.latest.rustfmt;
wasm-bindgen-cli-custom = pkgs.rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.122";
src = pkgs.fetchCrate {
inherit pname version;
hash = "sha256-vO4RSxi/sMWxmsEs3GuljdMfIRSu75A+Q+c5wgYToRU=";
};
cargoHash = "sha256-Inup6vvJSG5ghNyeDPyZbfZo4d0LsMG2OJfStoaeDBs=";
doCheck = false;
};
runtimeLibs = with pkgs; [
vulkan-loader
libX11
libXcursor
libXi
libXrandr
libxkbcommon
wayland
libGL
libudev-zero
alsa-lib
dbus
];
sarasaUiSrc = pkgs.fetchurl {
url = "https://github.com/be5invis/Sarasa-Gothic/releases/download/v1.0.33/SarasaUiSC-TTF-1.0.33.7z";
hash = "sha256-2OT2xqTY4Xm2BYTsQihUYt2fxW4LtZD9GHjrTGNM8oE=";
};
diaProSrc = pkgs.fetchurl {
url = "https://github.com/ButTaiwan/diapro/releases/download/v1.200/DiaProV1200.zip";
hash = "sha256-VSr0PU0szuP2mOVmx+0Dz7vKV/wShrysE21lVKbyGu0=";
};
# for building the application
# cargoToml = fromTOML (builtins.readFile ./Cargo.toml);
in
{
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "paiagram";
version = "0.1.3"; # keep it hardcoded until nix supports toml v1.1
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoLock.outputHashes = {
"paiagram-oudia-0.1.2" = "sha256-njaXWjL5xqbZ2fyfDVWZ+egU4ljYawuvXxR93whnV3E=";
};
nativeBuildInputs = with pkgs; [
mold
pkg-config
makeWrapper
];
buildInputs = runtimeLibs ++ [ pkgs.openssl ];
postPatch = ''
mkdir -p crates/paiagram/assets/fonts
${pkgs.p7zip}/bin/7z x ${sarasaUiSrc} -ocrates/paiagram/assets/fonts -y
${pkgs.p7zip}/bin/7z x ${diaProSrc} -ocrates/paiagram/assets/fonts -y
'';
postInstall = ''
wrapProgram $out/bin/paiagram \
--prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath (runtimeLibs ++ [ pkgs.stdenv.cc.cc ])}"
'';
};
devShells.default =
with pkgs;
mkShell {
buildInputs = [
rustToolchain
pkg-config
openssl # TODO: remove this
wasm-bindgen-cli-custom
just
wget
p7zip
binaryen
cargo-about
cargo-shear
cargo-expand
gitui
]
++ runtimeLibs
++ [
mold
clang
stdenv.cc.cc
];
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (runtimeLibs ++ [ stdenv.cc.cc ]);
# Prepend nightly rustfmt to the PATH so that `cargo fmt` and `rust-analyzer`
# pick it up instead of the stable one.
shellHook = ''
export PATH="${nightlyRustfmt}/bin:$PATH"
'';
};
}
);
}