nix-dev/flake.nix

102 lines
3.0 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs"
rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix
};
outputs = { self, nixpkgs, rust-overlay }:
let
# Overlays enable you to customize the Nixpkgs attribute set
rustExtensions = [ "rust-src" "rustfmt" "rust-analyzer" ];
overlays = [
# Makes a `rust-bin` attribute available in Nixpkgs
(import rust-overlay)
# Provides a `rustToolchain` attribute for Nixpkgs that we can use to
# create a Rust environment
(self: super: {
rustToolchain = super.rust-bin.stable.latest.default.override {
extensions = rustExtensions;
};
rustNightlyToolchain = super.rust-bin.nightly.latest.default.override {
extensions = rustExtensions;
};
})
];
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
];
# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; };
});
in
{
# Development environment output
devShells = forAllSystems ({ pkgs }: {
rust = pkgs.mkShell {
# The Nix packages provided in the environment
packages = (with pkgs; [
# The package provided by our custom overlay. Includes cargo, Clippy, cargo-fmt,
# rustdoc, rustfmt, and other tools.
rustToolchain
]);
};
rust-llvm = pkgs.mkShell {
# The Nix packages provided in the environment
packages = (with pkgs; [
# The package provided by our custom overlay. Includes cargo, Clippy, cargo-fmt,
# rustdoc, rustfmt, and other tools.
rustNightlyToolchain
python311
cmake
ninja
libffi
ccache
arcanist
]) ++ (with pkgs.llvmPackages_16; [
libllvm
clang
libclang
# This is the real lld package
bintools
]);
# Need this to fix rust-bindgen
LIBCLANG_PATH="${pkgs.llvmPackages_16.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${pkgs.llvmPackages_16.libclang.lib}/lib/clang/${nixpkgs.lib.getVersion pkgs.llvmPackages_16.clang}/include";
};
latex = pkgs.mkShell {
packages = (with pkgs; [
texlive.combined.scheme-full
tectonic
]);
};
python =
let
# Use Python 3.11
python = pkgs.python311;
in
pkgs.mkShell {
# The Nix packages provided in the environment
packages = [
# Python plus helper tools
(python.withPackages (ps: with ps; [
pip # The pip installer
]))
];
};
});
};
}