This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
90 lines (77 loc) · 2.27 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
{
description = "ex-markdown";
inputs.fenix = {
url = github:nix-community/fenix;
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
outputs = {
self,
nixpkgs,
flake-utils,
fenix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib beamPackages libiconv;
mixNixDeps = import ./mix.nix {inherit beamPackages lib;};
src = ./.;
rustToolchain = fenix.packages.${system}.stable.toolchain;
nativePackage =
(pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
})
.buildRustPackage {
# TODO: parse Cargo.toml.
pname = "comrak_rustler";
version = "0.1.5";
src = ./native/comrak_rustler;
cargoLock = {
lockFile = ./native/comrak_rustler/Cargo.lock;
outputHashes = {
"comrak-0.20.0" = "sha256-ohYxmOR34NqfXyhxcYO7KBdmElEF2WasxlTEDgr/ygA=";
};
};
};
in rec {
formatter = pkgs.alejandra;
packages.default =
(beamPackages.buildMix rec {
# TODO: as above? Should these versions stay in step?
name = "markdown";
version = "0.1.5";
inherit src;
patchPhase = ''
mkdir -p priv/native
find ${nativePackage}
cp ${nativePackage}/lib/libcomrak_rustler.* priv/native/libcomrak_rustler.so
export MARKDOWN_NATIVE_SKIP_COMPILATION="1"
'';
beamDeps = with mixNixDeps; [jason rustler html_entities];
doInstallCheck = true;
installCheckPhase = ''
mix test --no-deps-check
'';
})
.overrideAttrs (prev: {
LC_ALL = "en_US.UTF-8";
# buildMix clobbers the input passthru entirely.
passthru =
prev.passthru
// {
inherit src rustToolchain nativePackage;
};
});
devShells.default = packages.default.overrideAttrs (prev: {
nativeBuildInputs =
prev.nativeBuildInputs
++ [
rustToolchain
# onig_sys
libiconv
];
});
});
}