-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Nix build and dev-shell support via Nix flakes
- Loading branch information
Showing
4 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
description = "Fornjot is an early-stage project to create a next-generation, code-first CAD application"; | ||
inputs = { | ||
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; | ||
nixpkgs.url = "github:NixOS/nixpkgs"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
rust-overlay = { url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; }; }; | ||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs = { | ||
nixpkgs.follows = "nixpkgs"; | ||
flake-compat.follows = "flake-compat"; | ||
flake-utils.follows = "flake-utils"; | ||
}; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; }; | ||
rustToolchain = pkgs.rust-bin.fromRustupToolchain ( | ||
# extend toolchain with rust-analyzer for better IDE support | ||
let toolchainToml = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain; in | ||
{ | ||
channel = toolchainToml.channel; | ||
components = toolchainToml.components ++ [ "rust-analyzer" ]; | ||
} | ||
); | ||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; | ||
# Only keeps assets in crates/ (currently shaders and fonts) | ||
assetsFilter = path: _type: (builtins.match ".*(:?wgsl|ttf)$" path) != null; | ||
filter = path: type: (assetsFilter path type) || (craneLib.filterCargoSources path type); | ||
buildInputs = with pkgs; [ | ||
pkg-config | ||
fontconfig | ||
cmake | ||
wayland | ||
libGL | ||
xorg.libX11 | ||
xorg.libXcursor | ||
xorg.libXi | ||
xorg.libXrandr | ||
]; | ||
|
||
fornjot = craneLib.buildPackage { | ||
pname = "fj-app"; | ||
src = nixpkgs.lib.cleanSourceWith { src = ./.; inherit filter; }; | ||
inherit buildInputs; | ||
}; | ||
|
||
wrappedFornjot = pkgs.symlinkJoin { | ||
name = "fj-app"; | ||
paths = [ fornjot ]; | ||
|
||
buildInputs = [ pkgs.makeWrapper ]; | ||
|
||
postBuild = '' | ||
wrapProgram $out/bin/fj-app \ | ||
--prefix LD_LIBRARY_PATH : ${nixpkgs.lib.makeLibraryPath [ pkgs.vulkan-loader ]} | ||
''; | ||
}; | ||
in | ||
{ | ||
checks = { inherit fornjot; }; | ||
|
||
packages.default = wrappedFornjot; | ||
|
||
apps.default = flake-utils.lib.mkApp { drv = wrappedFornjot; }; | ||
|
||
devShells.default = pkgs.mkShell { | ||
inputsFrom = builtins.attrValues self.checks; | ||
|
||
inherit buildInputs; | ||
nativeBuildInputs = [ rustToolchain ]; | ||
|
||
LD_LIBRARY_PATH = "${nixpkgs.lib.makeLibraryPath [ pkgs.vulkan-loader ]}"; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).shellNix |