flake: setup build with rust-overlay and naersk

This commit is contained in:
Antoine Martin 2021-09-10 23:57:56 +02:00
parent fca836fe31
commit fbdb9e3a96
2 changed files with 100 additions and 15 deletions

View file

@ -15,13 +15,60 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"locked": {
"lastModified": 1623875721,
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1631004250,
"narHash": "sha256-LGh0CjAZwh13AVkTi9w9lITEC7x6bwSQyFViOZ6HyNo=",
"owner": "nix-community",
"repo": "naersk",
"rev": "08afb3d1dbfe016108b72e05b02ba0f6ecb3c8e1",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1630500761, "lastModified": 1631369477,
"narHash": "sha256-xjEjZro342lUPd5Z/fFwdAX1dMXXZ3tvPGqMpqs0U20=", "narHash": "sha256-IE6i3dZ5jFHpJXS+FawK2raPIfr9lPAI9FcgAsolLkg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6cc260cfd60f094500b79e279069b499806bf6d8", "rev": "98bfb51d00a2e5b94cf9aa5d56e7eaa82001387e",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1631229129,
"narHash": "sha256-PL9QDH9E1F7Qkj5sSOsMZqPF5MuQSVR4GMqOXt5WLq4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9fe2e640cc8540bacc4764892317f908d3562bc3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -31,10 +78,46 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1628186154,
"narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "06552b72346632b6943c8032e57e702ea12413bf",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1631326562,
"narHash": "sha256-Tg8e//Nb4FkOFMihg6rQ602aR3F60WJ0LSTqSzpGsQM=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b0d0959bbbfeb67573c01461e58593d35e7c524d",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
} }
} }
}, },

View file

@ -1,23 +1,29 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils, ... }: outputs = { self, nixpkgs, rust-overlay, naersk, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = import nixpkgs { inherit system; }; overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
myRust = pkgs.rust-bin.stable.latest.default;
naersk-lib = naersk.lib."${system}".override {
cargo = myRust;
rustc = myRust;
};
in in
{ {
defaultPackage = pkgs.rustPlatform.buildRustPackage { defaultPackage = naersk-lib.buildPackage {
pname = "prololo-reborn"; pname = "prololo-reborn";
version = "0.1.0"; version = "0.1.0";
src = self; src = self;
cargoSha256 = "sha256-dM3lNanFcm/9QggXgQ6MTjPxF57fxeKfR0lSXGv9bVY=";
meta = with pkgs.lib; { meta = with pkgs.lib; {
homepage = "https://github.com/prologin/prololo-reborn"; homepage = "https://github.com/prologin/prololo-reborn";
license = with licenses; [ mit asl20 ]; license = with licenses; [ mit asl20 ];
@ -34,20 +40,16 @@
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
cargo
clippy
nixpkgs-fmt nixpkgs-fmt
rust-analyzer rust-analyzer
rustPackages.clippy myRust
rustc
rustfmt
cmake cmake
openssl openssl
pkg-config pkg-config
]; ];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; RUST_SRC_PATH = pkgs.rust-bin.stable.latest.rust-std;
}; };
}); });
} }