diff --git a/README.md b/README.md index d672b8eff..270f9f4a7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/default.nix b/nix/default.nix similarity index 100% rename from default.nix rename to nix/default.nix diff --git a/flake.lock b/nix/flake.lock similarity index 100% rename from flake.lock rename to nix/flake.lock diff --git a/flake.nix b/nix/flake.nix similarity index 90% rename from flake.nix rename to nix/flake.nix index b91b3367f..af69e8939 100644 --- a/flake.nix +++ b/nix/flake.nix @@ -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); @@ -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 ]; diff --git a/shell.nix b/nix/shell.nix similarity index 100% rename from shell.nix rename to nix/shell.nix