Skip to content

Commit

Permalink
build: Add nix flake
Browse files Browse the repository at this point in the history
Nix is such an improved developer environment experience. I am planning
to also replace the current CI and update the documentation soon.

(temporarily disable static builds until the CI rework)
  • Loading branch information
javierhonduco committed Apr 21, 2024
1 parent fc31fb4 commit a9ea414
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
run: |
export RUSTFLAGS='-L /usr/lib/x86_64-linux-gnu'
cargo build
- name: Static build
run: |
just build
# - name: Static build
# run: |
# just build
lint:
name: Lint
runs-on: ubuntu-22.04
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn main() {
let skel = Path::new(RUBY_STACK_SKELETON);
match SkeletonBuilder::new()
.source(RUBY_STACK_SOURCE)
.clang_args("-Wextra -Wall -Werror")
.clang_args("-Wextra -Wall -Werror -Wno-unused-command-line-argument")
.build_and_generate(skel)
{
Ok(_) => {}
Expand All @@ -101,7 +101,7 @@ fn main() {
let skel = Path::new(FEATURES_SKELETON);
match SkeletonBuilder::new()
.source(FEATURES_SOURCE)
.clang_args("-Wextra -Wall -Werror")
.clang_args("-Wextra -Wall -Werror -Wno-unused-command-line-argument")
.build_and_generate(skel)
{
Ok(_) => {}
Expand Down
85 changes: 85 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ]
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
elfutils-without-zstd = pkgs.elfutils.overrideAttrs (attrs: {
configureFlags = attrs.configureFlags ++ [ "--without-zstd" ];
});
in
with pkgs;
{
formatter = pkgs.nixpkgs-fmt;

devShells.default = mkShell rec {
# https://discourse.nixos.org/t/how-to-add-pkg-config-file-to-a-nix-package/8264/4
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = [
rust-bin.stable.latest.default
llvmPackages_16.clang
# llvmPackages_16.clang-unwrapped https://github.com/NixOS/nixpkgs/issues/30670
llvmPackages_16.libcxx
llvmPackages_16.libclang
llvmPackages_16.lld
# Debugging
strace
gdb
# Native deps
glibc
glibc.static
elfutils-without-zstd
zlib.static
zlib.dev
openssl
# Other tools
cargo-edit
# snapshot testing plugin binary
cargo-insta
# ocamlPackages.magic-trace
];

LIBCLANG_PATH = lib.makeLibraryPath [ llvmPackages_16.libclang ];
LD_LIBRARY_PATH = lib.makeLibraryPath [ zlib.static elfutils-without-zstd ];
};
}
);
}

0 comments on commit a9ea414

Please sign in to comment.