summaryrefslogtreecommitdiff
path: root/nix/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/package.nix')
-rw-r--r--nix/package.nix60
1 files changed, 60 insertions, 0 deletions
diff --git a/nix/package.nix b/nix/package.nix
new file mode 100644
index 0000000..abb3129
--- /dev/null
+++ b/nix/package.nix
@@ -0,0 +1,60 @@
+{
+ lib,
+ rustPlatform,
+ self ? { },
+ lto ? true,
+ optimizeSize ? false,
+}:
+
+let
+ fs = lib.fileset;
+in
+
+rustPlatform.buildRustPackage {
+ pname = "chill-discord-bot";
+ version = (lib.importTOML ../Cargo.toml).package.version or "unknown";
+
+ src = fs.toSource {
+ root = ../.;
+ fileset = fs.intersection (fs.gitTracked ../.) (
+ lib.fileset.unions [
+ ../src
+ ../Cargo.toml
+ ../Cargo.lock
+ ]
+ );
+ };
+
+ cargoLock.lockFile = ../Cargo.lock;
+
+ # `-C panic="abort"` breaks checks
+ doCheck = !optimizeSize;
+
+ RUSTFLAGS =
+ lib.optionals lto [
+ "-C"
+ "embed-bitcode=yes"
+ "-C"
+ "lto=thin"
+ ]
+ ++ lib.optionals optimizeSize [
+ "-C"
+ "codegen-units=1"
+ "-C"
+ "opt-level=s"
+ "-C"
+ "panic=abort"
+ "-C"
+ "strip=symbols"
+ ];
+
+ GIT_SHA = self.shortRev or self.dirtyShortRev or "unknown";
+
+ meta = {
+ description = "funni bot";
+ homepage = "https://github.com/getchoo/chill";
+ license = lib.licenses.mit;
+ maintainers = with lib.maintainers; [ getchoo ];
+ mainProgram = "chill";
+ };
+}