Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a nix flake build for more plug and play experience #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ Alternatively, [vcpkg](https://github.com/Microsoft/vcpkg) can be used:
Alternatively, one can use the platform-dependent build system, for example `Make`:

* `make -C build`
### Nix (flakes)
With nix and flakes enabled:
* To build `nix build .`
* To build and run `nix run .`

### Arch Linux
* `cd ~`
* `git clone https://github.com/HackerPoet/MarbleMarcher.git`
Expand Down
42 changes: 42 additions & 0 deletions flake.lock

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

36 changes: 36 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
description = "MarbleMatcher";

inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
name = "MarbleMatcher";
inputs = with pkgs; [ eigen sfml cmake gnumake libGL ];
package = pkgs.stdenv.mkDerivation {
name = name;
src = self;
buildInputs = inputs;
buildPhase = ''
cmake -DCMAKE_CXX_FLAGS="-I/usr/local/include" .
cmake --build .
'';
installPhase = ''
mkdir -p $out
cp MarbleMarcher $out/
'';
};
in
{
defaultApp = {
type = "app";
program = "${package}/MarbleMarcher";
};
devShell = pkgs.mkShell { buildInputs = inputs; };
}
);
}