rust-binary-template/flake.nix

38 lines
1.2 KiB
Nix
Raw Normal View History

2024-04-29 21:20:48 +01:00
{
description = "A flake for building ${REPO_NAME}.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, treefmt-nix, ... }@inputs:
2024-04-29 21:44:06 +01:00
(flake-utils.lib.eachSystem
(with flake-utils.lib.system; [ x86_64-linux aarch64-darwin ])
(system: { checks.builds = self.packages.$${system}.default; })
// flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.$${system};
2024-04-29 21:20:48 +01:00
2024-04-29 21:44:06 +01:00
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
2024-04-29 21:20:48 +01:00
2024-04-29 21:44:06 +01:00
treefmtEval = treefmt-nix.lib.evalModule pkgs (pkgs: {
projectRootFile = "flake.nix";
programs.rustfmt.enable = true;
programs.nixfmt.enable = true;
});
in {
packages.default = pkgs.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
2024-04-29 21:20:48 +01:00
2024-04-29 21:44:06 +01:00
formatter = treefmtEval.config.build.wrapper;
}));
2024-04-29 21:20:48 +01:00
}