64 lines
1.6 KiB
Nix
64 lines
1.6 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs =
|
|
{ nixpkgs
|
|
, flake-utils
|
|
, ...
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
};
|
|
# Place all toolchain components in a single directory for IntelliJ
|
|
rust-toolchain = pkgs.symlinkJoin {
|
|
name = "rust-toolchain";
|
|
paths = with pkgs; [
|
|
rustc
|
|
cargo
|
|
rustPlatform.rustcSrc
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
libiconv
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
];
|
|
};
|
|
in
|
|
{
|
|
devShells.default = pkgs.mkShell {
|
|
name = "reddit-magnet";
|
|
buildInputs = with pkgs; [
|
|
cargo
|
|
cargo-edit
|
|
cargo-machete
|
|
cargo-release
|
|
cargo-sort
|
|
diesel-cli
|
|
git-cliff
|
|
openssl
|
|
pkg-config
|
|
rustc
|
|
rust-toolchain
|
|
sqlite
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
libiconv
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
];
|
|
RUST_BACKTRACE = 1;
|
|
|
|
# Copy rust-toolchain to project directory for easy use in IntelliJ
|
|
shellHook = ''
|
|
if [ -L ./.rust-toolchain ] && [ "$(readlink ./.rust-toolchain)" = "${rust-toolchain}" ]; then
|
|
echo "Rust toolchain symlink is already correct."
|
|
else
|
|
rm -f ./.rust-toolchain
|
|
ln -s ${rust-toolchain} ./.rust-toolchain
|
|
echo "Rust toolchain symlink updated."
|
|
fi
|
|
'';
|
|
};
|
|
});
|
|
}
|