fimt/flake.nix

65 lines
1.6 KiB
Nix
Raw Normal View History

2024-03-16 23:32:58 +03:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, nixpkgs
, flake-utils
, rust-overlay
}:
2024-03-19 11:21:33 +03:00
let
inherit (builtins) fromTOML readFile substring;
cargoToml = fromTOML (readFile ./Cargo.toml);
version = "${cargoToml.package.version}+${substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}";
mkFimt = { lib, rustPlatform, ... }:
rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
inherit version;
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
doCheck = true;
};
in
{
overlays.fimt = final: prev: {
fimt = prev.callPackage mkFimt;
};
overlays.default = self.overlays.fimt;
}
//
2024-03-16 23:32:58 +03:00
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
2024-03-19 11:21:33 +03:00
fimt = pkgs.callPackage mkFimt { };
2024-03-16 23:32:58 +03:00
in
{
2024-03-19 11:21:33 +03:00
packages = {
inherit fimt;
default = fimt;
};
apps = let fimtApp = flake-utils.lib.mkApp { drv = fimt; }; in {
fimt = fimtApp;
default = fimtApp;
};
2024-03-16 23:32:58 +03:00
devShell = pkgs.mkShell {
nativeBuildInputs = [ ];
buildInputs = [
pkgs.rust-bin.stable.latest.default
];
packages = with pkgs; [
rust-analyzer
];
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
};
});
}