Skip to content

Commit

Permalink
Merge pull request #1203 from Philipp-M/nix-flakes-readme-sub-dir
Browse files Browse the repository at this point in the history
Nix flakes readme sub dir
  • Loading branch information
hannobraun authored Oct 11, 2022
2 parents e51a3fc + d204524 commit 856a93b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ To install Fornjot itself, you have the following options:

While the Fornjot application is a graphical application that opens a window and displays a 3D view of your model, it can currently only be started from the command-line. The instructions below assume that you have the Fornjot application installed somewhere on your path, under the name `fj-app`.

#### Via Nix

There's a Nix [flake](https://nixos.wiki/wiki/Flakes) in the subdirectory `./nix` which contains a devshell environment (via `nix develop` or `nix-shell`) and the package `fj-app`.
It can be run/tested with a [flake enabled](https://nixos.wiki/wiki/Flakes#Enable_flakes) nix via `nix run github:hannobraun/Fornjot?dir=nix` or with legacy nix in the directory `./nix`, `nix-build`.

### Defining models

Models are Rust libraries that depend on the [`fj`](https://crates.io/crates/fj) library, which they use to define the geometry. Furthermore, they need to be built as a dynamic library. Just use the examples in the [`models/`](models) directory as a template to define your own.
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 5 additions & 3 deletions flake.nix → nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
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
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;
version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).workspace.package.version;
# 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);
Expand All @@ -45,12 +46,13 @@

fornjot = craneLib.buildPackage {
pname = "fj-app";
src = nixpkgs.lib.cleanSourceWith { src = ./.; inherit filter; };
inherit buildInputs;
src = nixpkgs.lib.cleanSourceWith { src = ../.; inherit filter; };
inherit buildInputs version;
};

wrappedFornjot = pkgs.symlinkJoin {
name = "fj-app";
inherit version;
paths = [ fornjot ];

buildInputs = [ pkgs.makeWrapper ];
Expand Down
File renamed without changes.

0 comments on commit 856a93b

Please sign in to comment.