dotfiles/templates/rust/flake.nix

42 lines
1.4 KiB
Nix
Raw Normal View History

2022-12-27 04:51:32 +00:00
{
inputs = {
naersk.url = "github:nix-community/naersk/master";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
2022-12-28 02:14:29 +00:00
rust-overlay.url = "github:oxalica/rust-overlay";
2022-12-27 04:51:32 +00:00
};
outputs = { self, nixpkgs, utils, naersk, rust-overlay }:
utils.lib.eachDefaultSystem (system:
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
2023-01-10 15:30:52 +00:00
rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith
(
toolchain:
toolchain.default.override {
extensions = [ "rust-src" "rust-analyzer" "rust-docs" "clippy" "miri" ];
}
));
2022-12-27 04:51:32 +00:00
naersk-lib = pkgs.callPackage naersk { };
in
{
defaultPackage = naersk-lib.buildPackage ./.;
devShell = with pkgs; mkShell {
buildInputs = [
2023-01-10 15:30:52 +00:00
rust_pkgs
# rust's compiler is quite powerful enough to the point where
# a REPL is not really necessary.
# Rely on the compiler and bacon 99% of the time
# only use REPL if you need to explore/prototype
# In that case, might as well put the code into sandbox
pkgs.evcxr
pkgs.bacon
2022-12-27 04:51:32 +00:00
];
shellHook = ''
# nix flake update # is this even needed?
'';
};
});
}