nix-dev/flake.nix

102 lines
3.0 KiB
Nix
Raw Permalink Normal View History

2023-07-01 14:00:43 +02:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs"
rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix
};
2023-07-01 14:04:16 +02:00
outputs = { self, nixpkgs, rust-overlay }:
2023-07-01 14:00:43 +02:00
let
# Overlays enable you to customize the Nixpkgs attribute set
2023-07-21 20:07:17 +02:00
rustExtensions = [ "rust-src" "rustfmt" "rust-analyzer" ];
2023-07-01 14:00:43 +02:00
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: {
2023-07-04 20:31:05 +02:00
rustToolchain = super.rust-bin.stable.latest.default.override {
2023-07-21 20:07:17 +02:00
extensions = rustExtensions;
};
rustNightlyToolchain = super.rust-bin.nightly.latest.default.override {
extensions = rustExtensions;
2023-07-04 20:31:05 +02:00
};
2023-07-01 14:00:43 +02:00
})
];
# 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
]);
};
2023-07-02 18:12:42 +02:00
2023-07-04 20:31:05 +02:00
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.
2023-07-21 20:07:17 +02:00
rustNightlyToolchain
2023-07-04 20:31:05 +02:00
python311
cmake
ninja
libffi
2023-07-08 14:53:44 +02:00
ccache
2023-07-21 20:07:17 +02:00
arcanist
2023-07-04 20:31:05 +02:00
]) ++ (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";
};
2023-07-02 18:12:42 +02:00
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
]))
];
};
2023-07-01 14:00:43 +02:00
});
};
}