Skip to content

Commit

Permalink
chore: add flake.nix
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Feb 29, 2024
1 parent 1285951 commit c9ba180
Show file tree
Hide file tree
Showing 3 changed files with 3,599 additions and 0 deletions.
111 changes: 111 additions & 0 deletions flake.lock

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

71 changes: 71 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
inputs.fenix = {
inputs.nixpkgs.follows = "nixpkgs";
url = github:nix-community/fenix;
};
inputs.rust-manifest = {
flake = false;
url = "https://static.rust-lang.org/dist/2024-02-29/channel-rust-nightly.toml";
};
inputs.flake-utils.url = github:numtide/flake-utils;
description = "runa - wayland compositor toolkit";

outputs = { self, nixpkgs, fenix, flake-utils, ... } @ inputs: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ fenix.overlays.default ]; };
rust-toolchain = (pkgs.fenix.fromManifestFile inputs.rust-manifest).withComponents [
"rustfmt"
"rust-src"
"clippy"
"rustc"
"cargo"
];
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-toolchain;
rustc = rust-toolchain;
};
in
with pkgs; {
packages = rec {
crescent = rustPlatform.buildRustPackage rec {
pname = "crescent";
version = "0.1.0";
src = ./.;
buildInputs = [ libxkbcommon ];
postUnpack = ''
echo $(pwd)
ls $sourceRoot/runa-wayland-protocols/spec
cp -v ${cargoLock.lockFile} $sourceRoot/Cargo.lock
'';
cargoLock.lockFile = ./nix/Cargo.lock;
LIBCLANG_PATH = lib.makeLibraryPath [ llvmPackages_17.libclang.lib ];
BINDGEN_EXTRA_CLANG_ARGS =
# Includes with normal include path
(builtins.map (a: ''-I"${a}/include"'') [
linuxHeaders
]) ++ [
''-isystem "${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${lib.versions.major pkgs.llvmPackages_latest.libclang.version}/include"''
''-isystem "${glibc.dev}/include"''
];
};
default = crescent;
};
devShells.default = mkShell {
nativeBuildInputs = [ pkg-config cmake rust-toolchain ];
buildInputs = [ libxkbcommon ];
shellHook = ''
export LD_LIBRARY_PATH="${lib.makeLibraryPath [ libglvnd vulkan-loader ]}:$LD_LIBRARY_PATH"
'';
LIBCLANG_PATH = lib.makeLibraryPath [ llvmPackages_17.libclang.lib ];

BINDGEN_EXTRA_CLANG_ARGS =
# Includes with normal include path
(builtins.map (a: ''-I"${a}/include"'') [
linuxHeaders
]) ++ [
''-isystem "${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${lib.versions.major pkgs.llvmPackages_latest.libclang.version}/include"''
''-isystem "${glibc.dev}/include"''
];
};
});
}
Loading

0 comments on commit c9ba180

Please sign in to comment.