blob: 8da5e70e9e34221968172026ad30e9fc0b23e0d1 (
plain)
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
|
{
description = "teawie moment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
pre-commit-hooks,
flake-utils,
...
}: let
version = "0.0.1";
supportedSystems = with flake-utils.lib.system; [
x86_64-linux
x86_64-darwin
aarch64-linux
aarch64-darwin
];
in
flake-utils.lib.eachSystem supportedSystems (system: let
pkgs = import nixpkgs {inherit system;};
in {
packages = let
inherit (pkgs.lib) maintainers licenses;
inherit (pkgs.dockerTools) buildLayeredImage caCertificates;
inherit (pkgs.rustPlatform) buildRustPackage;
in
rec {
teawiebot = buildRustPackage {
pname = "teawiebot";
inherit version;
src = ./.;
RUSTFLAGS = "-C lto=thin -C embed-bitcode=yes";
cargoSha256 = "sha256-TQThvhD2psA5+VGSMl3+dBOs8K33Fs5q42RovXnYYhY=";
buildInputs = with pkgs; [
openssl.dev
];
nativeBuildInputs = with pkgs; [
pkg-config
];
meta = {
description = "funni bot";
homepage = "https://github.com/getchoo/teawiebot";
license = licenses.mit;
maintainers = with maintainers; [getchoo];
};
};
container = let
bot = teawiebot.overrideAttrs (prev: {
RUSTFLAGS = prev.RUSTFLAGS + " -C opt-level=s";
});
in
buildLayeredImage {
name = "teawiebot";
tag = "latest";
contents = [caCertificates];
config.Cmd = ["${bot}/bin/teawiebot"];
};
}
// {default = self.packages.${system}.teawiebot;};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
actionlint.enable = true;
alejandra.enable = true;
cargo-check.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
statix.enable = true;
};
};
};
devShells = let
inherit (pkgs) mkShell;
in {
default = mkShell {
packages = with pkgs; [
actionlint
alejandra
cargo
clippy
deadnix
openssl.dev
pkg-config
rustfmt
statix
];
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
};
formatter = pkgs.alejandra;
});
}
|