rust: change default rust flake
This commit is contained in:
parent
f72dd6a30e
commit
413d8a9925
1 changed files with 43 additions and 16 deletions
|
@ -1,31 +1,58 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, utils }:
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
utils.lib.eachDefaultSystem (system:
|
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
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
|
# FIXME: rename hello
|
||||||
|
hello = pkgs.callPackage mkHello { };
|
||||||
in
|
in
|
||||||
rec {
|
{
|
||||||
packages.default = pkgs.rustPlatform.buildRustPackage {
|
packages = {
|
||||||
inherit (cargoToml.package) name version;
|
inherit hello;
|
||||||
src = nixpkgs.lib.cleanSource ./.;
|
default = hello;
|
||||||
doCheck = true;
|
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
apps.default = utils.lib.mkApp {
|
# FIXME: rename hello app with program path
|
||||||
inherit (cargoToml.package) name;
|
apps.hello = {
|
||||||
drv = packages.default;
|
type = "app";
|
||||||
|
program = "${hello}/bin/hello";
|
||||||
};
|
};
|
||||||
|
apps.default = self.apps.${system}.hello;
|
||||||
|
|
||||||
devShell = with pkgs; mkShell {
|
devShell = pkgs.mkShell {
|
||||||
packages = [ cargo rustc rustfmt clippy rust-analyzer ];
|
packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ];
|
||||||
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue