mirror of
https://github.com/faas-rs/faasd-in-rust.git
synced 2025-06-09 00:06:47 +00:00
nix build available!
This commit is contained in:
parent
167954eaa7
commit
d98cfd6289
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
/target
|
/target
|
||||||
.direnv/*
|
.direnv/*
|
||||||
|
result
|
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -243,17 +243,6 @@ version = "1.0.95"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "app"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"actix-web",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"service",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-stream"
|
name = "async-stream"
|
||||||
version = "0.3.6"
|
version = "0.3.6"
|
||||||
@ -589,6 +578,17 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "faas-rs"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"actix-web",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"service",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "app"
|
name = "faas-rs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
36
flake.lock
generated
36
flake.lock
generated
@ -1,5 +1,20 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1739936662,
|
||||||
|
"narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
@ -34,24 +49,9 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1736320768,
|
|
||||||
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "4bc9c909d9ac828a039f288cf872d16d38185db8",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
@ -59,7 +59,9 @@
|
|||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740104932,
|
"lastModified": 1740104932,
|
||||||
|
98
flake.nix
98
flake.nix
@ -3,49 +3,85 @@
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
crane.url = "github:ipetkov/crane";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
|
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
|
# reference: https://crane.dev/examples/quick-start-workspace.html
|
||||||
overlays = [ (import rust-overlay) ];
|
overlays = [ (import rust-overlay) ];
|
||||||
pkgs = import nixpkgs { inherit system overlays; };
|
pkgs = import nixpkgs { inherit system overlays; };
|
||||||
rustChannel = pkgs.rust-bin.nightly.latest;
|
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
|
rustToolchainFor = p: p.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
|
||||||
|
extensions = [ "rust-src" ];
|
||||||
|
});
|
||||||
|
|
||||||
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchainFor;
|
||||||
|
src = craneLib.cleanCargoSource ./.;
|
||||||
|
|
||||||
|
commonArgs = {
|
||||||
|
inherit src;
|
||||||
|
strictDeps = true;
|
||||||
|
# Add additional build inputs here
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
openssl
|
||||||
|
protobuf
|
||||||
|
];
|
||||||
|
};
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||||
|
|
||||||
|
individualCrateArgs = commonArgs // {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSetForCrate = crate: lib.fileset.toSource {
|
||||||
|
root = ./.;
|
||||||
|
fileset = lib.fileset.unions [
|
||||||
|
./Cargo.toml
|
||||||
|
./Cargo.lock
|
||||||
|
(craneLib.fileset.commonCargoSources ./app)
|
||||||
|
(craneLib.fileset.commonCargoSources ./service)
|
||||||
|
(craneLib.fileset.commonCargoSources crate)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
faas-rs-crate = craneLib.buildPackage ( individualCrateArgs // {
|
||||||
|
pname = "faas-rs";
|
||||||
|
cargoExtraArgs = "--bin faas-rs";
|
||||||
|
src = fileSetForCrate ./app;
|
||||||
|
});
|
||||||
in
|
in
|
||||||
with pkgs;
|
with pkgs;
|
||||||
{
|
{
|
||||||
devShells.default = mkShell {
|
checks = { inherit faas-rs-crate; };
|
||||||
buildInputs = [
|
|
||||||
openssl
|
packages.default = faas-rs-crate;
|
||||||
pkg-config
|
|
||||||
protobuf
|
devShells.default = craneLib.devShell {
|
||||||
containerd
|
checks = self.checks.${system};
|
||||||
runc
|
|
||||||
(rustChannel.default.override {
|
inputsFrom = [ faas-rs-crate ];
|
||||||
extensions = [ "rust-src" ];
|
|
||||||
})
|
packages = [
|
||||||
|
pkgs.cargo-hakari
|
||||||
|
pkgs.containerd
|
||||||
|
pkgs.runc
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
defaultPackage = stdenv.mkDerivation {
|
|
||||||
name = "faas-rs-${rustChannel._version}";
|
|
||||||
src = ./.; # 当前项目目录作为源码
|
|
||||||
buildInputs = [
|
|
||||||
openssl
|
|
||||||
pkg-config
|
|
||||||
protobuf
|
|
||||||
rustChannel.rustc # Rust 编译器
|
|
||||||
rustChannel.cargo # Cargo 工具
|
|
||||||
];
|
|
||||||
buildPhase = ''
|
|
||||||
cargo build --release
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cp target/release/* $out/bin
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user