nixide/flake.nix

177 lines
4.6 KiB
Nix
Raw Normal View History

2026-03-13 13:26:07 +10:00
{
2026-03-20 11:36:12 +10:00
description = "rust wrapper for libnix";
2026-03-13 13:26:07 +10:00
inputs = {
2026-04-02 23:38:12 +10:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
2026-03-13 13:26:07 +10:00
systems.url = "github:nix-systems/default";
2026-03-29 14:50:56 +10:00
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
2026-03-13 13:26:07 +10:00
};
outputs = {
self,
nixpkgs,
...
} @ inputs: let
systems = import inputs.systems;
mkPkgs = system: repo:
import repo {
inherit system;
allowUnfree = false;
allowBroken = false;
overlays = builtins.attrValues self.overlays or {};
2026-03-31 08:12:25 +10:00
# config.replaceStdenv = {pkgs}: with pkgs; llvmPackages_21.stdenv;
2026-03-13 13:26:07 +10:00
};
forAllSystems = f:
nixpkgs.lib.genAttrs systems (system:
f rec {
inherit system;
inherit (pkgs) lib;
pkgs = mkPkgs system nixpkgs;
});
in {
2026-03-29 14:50:56 +10:00
overlays = {
default = self: super: {
libclang = super.llvmPackages_21.libclang;
};
fenix = inputs.fenix.overlays.default;
2026-03-13 13:26:07 +10:00
};
devShells = forAllSystems (
{
pkgs,
lib,
...
}: {
2026-03-13 23:20:38 +10:00
default = let
2026-04-02 23:38:12 +10:00
nixForBindings = pkgs.nixVersions.nix_2_34;
2026-03-13 23:20:38 +10:00
inherit (pkgs.rustc) llvmPackages;
in
pkgs.mkShell rec {
name = "nixide";
shell = "${pkgs.bash}/bin/bash";
strictDeps = true;
# packages we need at runtime
packages = with pkgs; [
rustc
llvmPackages.lld
2026-03-31 08:12:25 +10:00
llvmPackages.lldb
# lldb
2026-03-13 23:20:38 +10:00
cargo
2026-03-13 23:40:48 +10:00
cargo-c
2026-03-13 23:20:38 +10:00
cargo-llvm-cov
cargo-nextest
2026-03-31 08:12:25 +10:00
clang # DEBUG
clang-tools # DEBUG
libcxx
2026-03-13 23:20:38 +10:00
rust-analyzer-unwrapped
(rustfmt.override {asNightly = true;})
clippy
taplo
];
# packages we need at build time
nativeBuildInputs = with pkgs; [
pkg-config
glibc.dev
nixForBindings.dev
rustPlatform.bindgenHook
];
# packages we link against
buildInputs = with pkgs; [
stdenv.cc
2026-03-29 14:50:56 +10:00
nixForBindings
];
env = let
inherit (llvmPackages) llvm libclang;
in {
LD_LIBRARY_PATH = builtins.toString (lib.makeLibraryPath buildInputs);
LIBCLANG_PATH = "${libclang.lib}/lib";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
BINDGEN_EXTRA_CLANG_ARGS = "--sysroot=${pkgs.glibc.dev}";
# `cargo-llvm-cov` reads these environment variables to find these binaries,
# which are needed to run the tests
LLVM_COV = "${llvm}/bin/llvm-cov";
LLVM_PROFDATA = "${llvm}/bin/llvm-profdata";
};
};
nightly = let
2026-04-02 23:38:12 +10:00
nixForBindings = pkgs.nixVersions.nix_2_34;
2026-03-29 14:50:56 +10:00
inherit (pkgs.rustc) llvmPackages;
in
pkgs.mkShell rec {
name = "nixide";
shell = "${pkgs.bash}/bin/bash";
strictDeps = true;
# packages we need at runtime
packages = with pkgs; [
llvmPackages.lld
lldb
(pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
rust-analyzer-nightly
# cargo-c
# cargo-llvm-cov
# cargo-nextest
];
# packages we need at build time
nativeBuildInputs = with pkgs; [
pkg-config
glibc.dev
nixForBindings.dev
rustPlatform.bindgenHook
];
# packages we link against
buildInputs = with pkgs; [
stdenv.cc
2026-03-13 23:20:38 +10:00
nixForBindings
];
env = let
inherit (llvmPackages) llvm libclang;
in {
2026-03-14 02:39:27 +10:00
LD_LIBRARY_PATH = builtins.toString (lib.makeLibraryPath buildInputs);
2026-03-13 23:20:38 +10:00
LIBCLANG_PATH = "${libclang.lib}/lib";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
BINDGEN_EXTRA_CLANG_ARGS = "--sysroot=${pkgs.glibc.dev}";
# `cargo-llvm-cov` reads these environment variables to find these binaries,
# which are needed to run the tests
LLVM_COV = "${llvm}/bin/llvm-cov";
LLVM_PROFDATA = "${llvm}/bin/llvm-profdata";
};
};
2026-03-13 13:26:07 +10:00
}
);
};
}