Add Nix flake (#73)

This commit is contained in:
Benjamin Große 2023-03-24 10:32:14 +00:00 committed by Ulyssa
parent 274234ce4c
commit 463d46b8ab
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64
3 changed files with 139 additions and 0 deletions

39
flake.nix Normal file
View file

@ -0,0 +1,39 @@
{
description = "iamb";
nixConfig.bash-prompt = "\[nix-develop\]$ ";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
# We only need the nightly overlay in the devShell because .rs files are formatted with nightly.
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustNightly = pkgs.rust-bin.nightly."2023-03-17".default;
in
with pkgs;
{
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "iamb";
version = "0.0.7";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ pkgs.openssl pkgs.pkgconfig ];
buildInputs = [ pkgs.openssl ];
};
devShell = mkShell {
buildInputs = [
(rustNightly.override { extensions = [ "rust-src" ]; })
pkg-config
cargo-tarpaulin
rust-analyzer
rustfmt
];
};
});
}