117 lines
2.8 KiB
Nix
117 lines
2.8 KiB
Nix
{
|
|
description = "Paws thingy";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
crane.url = "github:ipetkov/crane";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
crane,
|
|
flake-utils,
|
|
rust-overlay,
|
|
...
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
overlays = [ (import rust-overlay) ];
|
|
inherit system;
|
|
};
|
|
inherit (pkgs) lib;
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain (
|
|
p:
|
|
p.rust-bin.nightly.latest.default.override {
|
|
extensions = [
|
|
"rust-src"
|
|
"rust-analyzer"
|
|
];
|
|
}
|
|
);
|
|
|
|
commonArgs = {
|
|
# inherit (craneLib.crateNameFromCargoToml { cargoToml = ./crates/client/Cargo.toml; }) version;
|
|
src =
|
|
let
|
|
# Only keeps markdown files
|
|
htmlFilter = path: _type: builtins.match ".*html$" path != null;
|
|
htmlOrCargo = path: type: (htmlFilter path type) || (craneLib.filterCargoSources path type);
|
|
in
|
|
lib.cleanSourceWith {
|
|
src = ./.;
|
|
filter = htmlOrCargo;
|
|
name = "source"; # Be reproducible, regardless of the directory name
|
|
}
|
|
|
|
;
|
|
strictDeps = true;
|
|
doCheck = false;
|
|
};
|
|
cargoArtifacts = craneLib.buildDepsOnly (commonArgs);
|
|
|
|
server = craneLib.buildPackage (
|
|
commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
postInstall = ''
|
|
${pkgs.upx}/bin/upx --lzma --best $out/bin/server
|
|
'';
|
|
}
|
|
);
|
|
|
|
server-docker = pkgs.dockerTools.buildLayeredImage {
|
|
contents = [
|
|
server
|
|
pkgs.bash
|
|
pkgs.coreutils
|
|
];
|
|
name = "deadlockmm-backend";
|
|
config = {
|
|
Cmd = [
|
|
"${server}/bin/server"
|
|
];
|
|
};
|
|
};
|
|
|
|
in
|
|
rec {
|
|
checks = {
|
|
inherit server;
|
|
|
|
};
|
|
packages = {
|
|
default = server;
|
|
inherit
|
|
server
|
|
server-docker
|
|
;
|
|
docker_push = import ./deploy.nix {
|
|
inherit pkgs;
|
|
inherit server-docker;
|
|
};
|
|
};
|
|
devShells.default = craneLib.devShell rec {
|
|
checks = self.checks.${system};
|
|
packages = [
|
|
pkgs.cargo-watch
|
|
pkgs.mold
|
|
pkgs.llvmPackages.clang
|
|
];
|
|
RUSTFLAGS = "-Clinker=clang -Clink-arg=-fuse-ld=mold";
|
|
};
|
|
}
|
|
);
|
|
}
|