-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
103 lines (90 loc) · 2.42 KB
/
flake.nix
File metadata and controls
103 lines (90 loc) · 2.42 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
{
description = "rime";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
nixConfig = {
extra-trusted-public-keys = "rime.cachix.org-1:rC+wEyizw3QNPt5uvsSEme2s2sm7l7372ZIllGGxp8w=";
extra-substituters = "https://rime.cachix.org";
};
outputs =
{
self,
nixpkgs,
systems,
crane,
rust-overlay,
}:
let
pname = "rime";
version = builtins.readFile ./VERSION;
mkPkgs =
system:
import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
mkRime =
pkgs:
let
rustToolchain = pkgs.rust-bin.nightly.latest.minimal;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = craneLib.cleanCargoSource (craneLib.path ./.);
commonArgs = { inherit src pname version; };
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
overlay = final: prev: {
rime = mkRime (mkPkgs prev.stdenv.hostPlatform.system);
};
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in
{
packages = forEachSystem (system: rec {
default = mkRime (mkPkgs system);
rime = default;
});
apps = forEachSystem (system: rec {
default = {
program = "${mkRime (mkPkgs system)}/bin/rime";
type = "app";
};
rime = default;
});
overlays.default = overlay;
devShells = forEachSystem (
system:
let
pkgs = mkPkgs system;
rustToolchain = pkgs.rust-bin.nightly.latest.minimal.override {
extensions = [
"rust-src"
"rust-analyzer"
"clippy"
"rustfmt"
];
};
in
{
default = pkgs.mkShell {
packages = [
rustToolchain
pkgs.pkg-config
];
shellHook = ''
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"
'';
};
}
);
};
}