-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflake.nix
More file actions
149 lines (145 loc) · 4.1 KB
/
flake.nix
File metadata and controls
149 lines (145 loc) · 4.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
description = "Linquebot's nix flake";
nixConfig = {
experimental-features = [
"nix-command"
"flakes"
];
extra-substituters = [
"https://nix-community.cachix.org"
"https://beiyanyunyi.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"beiyanyunyi.cachix.org-1:iCC1rwPPRGilc/0OS7Im2mP6karfpptTCnqn9sPtwls="
];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
};
outputs =
{
nixpkgs,
flake-utils,
rust-overlay,
crane,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [
(import rust-overlay)
];
pkgs = import nixpkgs {
inherit system overlays;
};
craneLib = (crane.mkLib pkgs).overrideToolchain (
p: p.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal)
);
in
rec {
devShells.default =
with pkgs;
mkShell {
buildInputs = [
cmake
openssl
graphviz
(rust-bin.selectLatestNightlyWith (
toolchain:
toolchain.default.override {
extensions = [
"rust-src"
"clippy-preview"
];
}
))
];
};
packages.default =
with pkgs;
let
jsonFilter = path: _type: builtins.match ".*json$" path != null;
jsonOrCargo = path: type: (jsonFilter path type) || (craneLib.filterCargoSources path type);
in
craneLib.buildPackage {
src = lib.cleanSourceWith {
src = ./.;
filter = jsonOrCargo;
name = "source";
};
# Add extra inputs here or any other derivation settings
# doCheck = true;
buildInputs = [
pkg-config
cmake
]
++ lib.optionals stdenvNoCC.hostPlatform.isLinux [
openssl
];
nativeBuildInputs = [ makeWrapper ];
CI = "true";
stdenv = p: p.clangStdenv;
LIBCLANG_PATH = "${libclang.lib}/lib";
postInstall = ''
wrapProgram $out/bin/linquebot_rs --prefix PATH : ${lib.makeBinPath [ graphviz ]}
'';
meta.mainProgram = "linquebot_rs";
};
packages.dockerSupports =
with pkgs;
let
fonts-conf = makeFontsConf {
fontDirectories = [
twemoji-color-font
noto-fonts-cjk-sans
noto-fonts
];
};
in
stdenvNoCC.mkDerivation {
name = "linquebot_rs-docker-supports";
dontUnpack = true;
buildInputs = [
fontconfig
];
installPhase = ''
runHook preInstall
mkdir -p $out/etc/fonts/conf.d $out/var
mkdir -m 1777 $out/tmp
cp ${fonts-conf} $out/etc/fonts/conf.d/99-nix.conf
runHook postInstall
'';
};
packages.dockerImage =
with pkgs;
dockerTools.buildLayeredImage {
name = "ghcr.io/lhcfl/linquebot_rs";
tag = "latest";
contents = [
# coreutils
dockerTools.caCertificates
dockerTools.usrBinEnv
# dockerTools.binSh
# strace
packages.dockerSupports
];
config = {
Cmd = [
"${lib.meta.getExe packages.default}"
];
WorkingDir = "/app";
StopSignal = "SIGINT";
};
created = "now";
};
}
);
}