rust: change default rust flake

This commit is contained in:
Dmitriy Pleshevskiy 2022-10-20 13:22:58 +03:00
parent f72dd6a30e
commit 413d8a9925
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215

View file

@ -1,31 +1,58 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
outputs = { self, nixpkgs, flake-utils }:
let
inherit (builtins) fromTOML readFile substring;
cargoToml = fromTOML (readFile ./Cargo.toml);
version = "${cargoToml.package.version}+${substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}";
# FIXME: rename mkHello
mkHello = { lib, rustPlatform, ... }:
rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
inherit version;
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
doCheck = true;
};
in
{
# FIXME: rename hello overlay with package name
overlays.hello = final: prev: {
hello = prev.callPackage mkHello;
};
overlays.default = self.overlays.hello;
}
//
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
# FIXME: rename hello
hello = pkgs.callPackage mkHello { };
in
rec {
packages.default = pkgs.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = nixpkgs.lib.cleanSource ./.;
doCheck = true;
cargoLock.lockFile = ./Cargo.lock;
{
packages = {
inherit hello;
default = hello;
};
apps.default = utils.lib.mkApp {
inherit (cargoToml.package) name;
drv = packages.default;
# FIXME: rename hello app with program path
apps.hello = {
type = "app";
program = "${hello}/bin/hello";
};
apps.default = self.apps.${system}.hello;
devShell = with pkgs; mkShell {
packages = [ cargo rustc rustfmt clippy rust-analyzer ];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
devShell = pkgs.mkShell {
packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
};
});
}