Skip to content

Commit

Permalink
Add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
slotThe authored and x86y committed Nov 29, 2023
1 parent 4ffb197 commit aeba6b0
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ A native and a cross platform guide for BQN array programming language.
> cargo run --release
```

Alternatively, a nix flake is provided:

``` console
$ git clone https://github.com/x86y/beacon
$ cd beacon
$ nix run # Alternatively: nix develop -c cargo run --release
```

## Windows instructions
```sh
> git clone https://github.com/x86y/beacon
Expand Down
82 changes: 82 additions & 0 deletions flake.lock

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

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { nixpkgs, flake-utils, crane, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };

buildInputs = with pkgs; [
cbqn
xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;

beacon = crane.lib.${system}.buildPackage {
inherit buildInputs;
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(pkgs.lib.hasInfix "/src/" path)
|| (crane.lib.${system}.filterCargoSources path type);
};
};
in
with pkgs; {

# nix build, nix run, …
packages = {
inherit beacon;
default = pkgs.symlinkJoin {
name = "beacon";
paths = [ beacon ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/beacon \
--prefix LD_LIBRARY_PATH : "${LD_LIBRARY_PATH}"
'';
cargoExtraArgs = "--release";
};
};

# nix develop
devShells.default = mkShell {
inherit LD_LIBRARY_PATH;
buildInputs = buildInputs ++ [ cargo rustc rust-analyzer ];
};
}
);
}

0 comments on commit aeba6b0

Please sign in to comment.