chore: Add package output to nix flake

This commit is contained in:
Patrick Auernig 2024-11-28 01:06:49 +01:00
parent 99e7d3895a
commit 9447de3f74
2 changed files with 34 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target
/result
.direnv

View File

@ -15,18 +15,51 @@
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
lib = nixpkgs.lib;
rust = pkgs.rust-bin;
rustToolchain = rust.fromRustupToolchainFile ./rust-toolchain.toml;
rustNightlyToolchain = rust.selectLatestNightlyWith (t: t.minimal.override {
extensions = [ "rustfmt" ];
});
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
buildTools = [
rustToolchain
rustNightlyToolchain
];
manifest = lib.importTOML ./Cargo.toml;
packageName = manifest.package.name;
packageVersion = manifest.package.version;
package = rustPlatform.buildRustPackage {
nativeBuildInputs = buildTools;
pname = packageName;
version = packageVersion;
src = lib.cleanSource ./.;
verbose = true;
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};
meta = {
mainProgram = packageName;
};
};
in {
packages = {
default = package;
${packageName} = package;
};
devShells.default = pkgs.mkShell {
name = "projtool";