Created
January 22, 2024 17:50
-
-
Save p1xelHer0/1ac12f659ab38436a5cbaffe0a5f4d4a to your computer and use it in GitHub Desktop.
macOS Nix flake for https://hands-on-rust.com/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "dungeoncrawler"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/master"; | |
flake-utils.url = "github:numtide/flake-utils"; | |
rust-overlay.url = "github:oxalica/rust-overlay"; | |
}; | |
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: | |
flake-utils.lib.eachDefaultSystem (system: | |
let | |
overlays = [ (import rust-overlay) ]; | |
pkgs = import nixpkgs { | |
inherit system overlays; | |
}; | |
binName = "dungeoncrawl"; | |
inherit (pkgs.lib) optionals; | |
inherit (pkgs.stdenv) isDarwin; | |
inherit (pkgs.darwin.apple_sdk.frameworks) AppKit CoreVideo; | |
rustVersion = | |
pkgs.rust-bin.selectLatestNightlyWith | |
(toolchain: toolchain.default.override { | |
extensions = [ "rust-src" "rust-analyzer" "rustfmt" "clippy" ]; | |
}); | |
rustPlatform = pkgs.makeRustPlatform { | |
cargo = rustVersion; | |
rustc = rustVersion; | |
}; | |
buildInputs = with pkgs; [ ] ++ optionals isDarwin [ AppKit CoreVideo ]; | |
in | |
with pkgs; | |
{ | |
defaultPackage = | |
rustPlatform.buildRustPackage { | |
pname = binName; | |
version = "0.1.0"; | |
src = ./.; | |
cargoLock.lockFile = ./Cargo.lock; | |
inherit buildInputs; | |
nativeBuildInputs = [ ]; | |
postInstall = '' | |
cp -r resources $out/bin/ | |
''; | |
}; | |
devShells.default = mkShell { | |
inherit buildInputs; | |
nativeBuildInputs = [ | |
rustVersion | |
cargo-watch | |
cargo-nextest | |
]; | |
shellHook = '' | |
export CARGO_MANIFEST_DIR=$(pwd) | |
''; | |
}; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment