Add flake.nix to SRI #1344
Replies: 7 comments 10 replies
-
as a nix user, I find this idea quite interesting, but I feel this requires a bit more brainstorming first and foremost, we cannot force any SRI contributors to start using nix... it has a steep learning curve and it can actually slow down productivity for those who are not used to it therefore, it's very important to have the following restrictions in mind:
second, the original proposal feels very broad and generic, and a few questions come to mind:
again, as a nix user I like the idea and I'm not opposing it but overall if we were to go in this direction, it's important to have a solid rationale! |
Beta Was this translation helpful? Give feedback.
-
@Georges760 I see you liked this issue, and you also mentioned you use a can you share your why are you using it? which problems are you solving? |
Beta Was this translation helpful? Give feedback.
-
Of course, here is my shell.nix : { pkgs ? import <nixpkgs> {} }:
let
overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml));
libPath = with pkgs; lib.makeLibraryPath [
# load external libraries that you need in your rust project here
];
in
pkgs.mkShell rec {
buildInputs = with pkgs; [
clang
cmake
openssl
# Replace llvmPackages with llvmPackages_X, where X is the latest LLVM version (at the time of writing, 16)
llvmPackages.bintools
pkg-config
rustup
];
RUSTC_VERSION = overrides.toolchain.channel;
# https://github.com/rust-lang/rust-bindgen#environment-variables
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
shellHook = ''
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
'';
# Add precompiled library to rustc search path
RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
# add libraries here (e.g. pkgs.libvmi)
]);
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
LD_LIBRARY_PATH = libPath;
# Add glibc, clang, glib, and other headers to bindgen search path
BINDGEN_EXTRA_CLANG_ARGS =
# Includes normal include path
(builtins.map (a: ''-I"${a}/include"'') [
# add dev libraries here (e.g. pkgs.libvmi.dev)
pkgs.glibc.dev
])
# Includes with special directory paths
++ [
''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
''-I"${pkgs.glib.dev}/include/glib-2.0"''
''-I${pkgs.glib.out}/lib/glib-2.0/include/''
];
} It is a little bit messy, as I am on NixOS for few month only, and still learning it. |
Beta Was this translation helpful? Give feedback.
-
may I ask why are you using nix? what kind of problems it solved for you while working on SRI? |
Beta Was this translation helpful? Give feedback.
-
I was bored to lose (again) my whole ubuntu system at a "dist-upgrade", so wanted to test NixOS. I kind of like it now, begining was difficult (like Rust) but once everything is running, it is very convenient to maintain. |
Beta Was this translation helpful? Give feedback.
-
another relevant point is that using nixOS is not a pre-requisite for using nix it can still be installed into regular linux distributions and macOS nixOS is simply an entire linux distribution based on this tool |
Beta Was this translation helpful? Give feedback.
-
my rant above actually made me realize something that is kind of adjacent to this discussion: do we want to maintain the legacy Guix things on the SRI repo? here's a quick search for
|
Beta Was this translation helpful? Give feedback.
-
Add a
flake.nix
file to the repository to standardize and simplify the development environment setup using Nix flakes. This will ensure consistent dependency management, reproducible builds, and alignment across different systems and contributors. By introducingflake.nix
, we can provide a unified configuration for tools, Rust toolchains, and any project-specific dependencies, streamlining the onboarding process and minimizing environment-related issues. The flake should define the required Rust version (aligned withrust-toolchain.toml
) and any additional tools or components needed for development, testing, and CI pipelines.Beta Was this translation helpful? Give feedback.
All reactions