summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-04-04 23:23:28 -0400
committerseth <[email protected]>2023-04-05 20:34:12 -0400
commit65d0b7a553f718b1ba34799e604ceb07c062af61 (patch)
tree9a6b1c78aa6e79c2201ba124b536a05231b0ae20 /flake.nix
parented076bbd6fc22b32ea353ae6bd3cac79d039719a (diff)
rewrite in rust :)
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix87
1 files changed, 61 insertions, 26 deletions
diff --git a/flake.nix b/flake.nix
index 2f84f29..8da5e70 100644
--- a/flake.nix
+++ b/flake.nix
@@ -7,13 +7,8 @@
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
- inputs.flake-compat.follows = "flake-compat";
inputs.flake-utils.follows = "flake-utils";
};
- flake-compat = {
- url = "github:edolstra/flake-compat";
- flake = false;
- };
flake-utils.url = "github:numtide/flake-utils";
};
@@ -25,27 +20,55 @@
...
}: let
version = "0.0.1";
- supportedSystems = with flake-utils.lib.system; [x86_64-linux x86_64-darwin aarch64-linux aarch64-darwin];
+ 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 =
+ packages = let
+ inherit (pkgs.lib) maintainers licenses;
+ inherit (pkgs.dockerTools) buildLayeredImage caCertificates;
+ inherit (pkgs.rustPlatform) buildRustPackage;
+ in
rec {
- teawiebot = with pkgs;
- python39Packages.buildPythonPackage {
- pname = "teawiebot";
- inherit version;
- src = ./.;
- format = "flit";
- propagatedBuildInputs = with pkgs.python39Packages; [hatchling discordpy requests];
+ 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 = with pkgs.dockerTools;
+ };
+ container = let
+ bot = teawiebot.overrideAttrs (prev: {
+ RUSTFLAGS = prev.RUSTFLAGS + " -C opt-level=s";
+ });
+ in
buildLayeredImage {
name = "teawiebot";
tag = "latest";
contents = [caCertificates];
- config.Cmd = ["${teawiebot}/bin/teawiebot"];
+ config.Cmd = ["${bot}/bin/teawiebot"];
};
}
// {default = self.packages.${system}.teawiebot;};
@@ -54,23 +77,35 @@
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
- isort.enable = true;
- pylint.enable = true;
- yapf = {
- enable = true;
- name = "yapf";
- entry = "${pkgs.python39Packages.yapf}/bin/yapf -i";
- types = ["file" "python"];
- };
+ actionlint.enable = true;
+ alejandra.enable = true;
+ cargo-check.enable = true;
+ deadnix.enable = true;
+ rustfmt.enable = true;
+ statix.enable = true;
};
};
};
- devShells = with pkgs; {
+ devShells = let
+ inherit (pkgs) mkShell;
+ in {
default = mkShell {
- packages = with pkgs.python39Packages; [python39 discordpy flit pylint requests toml yapf];
+ 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;
});
}