From 9a491acf374b86c297ef269a098e1d20f7e3d6df Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Tue, 19 Mar 2024 11:21:33 +0300 Subject: [PATCH] nix: add overlays, packages, apps --- flake.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/flake.nix b/flake.nix index 24cd548..3ffa299 100644 --- a/flake.nix +++ b/flake.nix @@ -11,12 +11,45 @@ , flake-utils , rust-overlay }: + 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; + } + // flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; + fimt = pkgs.callPackage mkFimt { }; in { + packages = { + inherit fimt; + default = fimt; + }; + apps = let fimtApp = flake-utils.lib.mkApp { drv = fimt; }; in { + fimt = fimtApp; + default = fimtApp; + }; devShell = pkgs.mkShell { nativeBuildInputs = [ ]; buildInputs = [