nix: add flake
This commit is contained in:
parent
3ebb457d5a
commit
3c6091106f
@ -1,2 +1,3 @@
|
||||
README.md
|
||||
Cargo.toml
|
||||
flake.nix
|
||||
|
34
flake.nix
Normal file
34
flake.nix
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
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:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.$${system};
|
||||
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
formatter = treefmtEval.config.build.wrapper;
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user