Skip to content

Commit

Permalink
Add support files for development with Nix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reisen committed Sep 6, 2022
1 parent 7484d48 commit 7b5985f
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
# will have compiled files and executables
/target/

# Generated by Nix
# will contain the output of `nix build`
result

# These are backup files generated by rustfmt
**/*.rs.bk
81 changes: 81 additions & 0 deletions flake.lock

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

58 changes: 58 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Note:
#
# This file provides a Flake for Nix/NixOs users. It allows users to
# build or work with the project without having to worry about which
# dependencies are required. It is not required to build the project
# and can be ignored by users who do not use Nix/NixOs.
#
# See README for instructions on building the project.
#
#
# Usage:
#
# ```bash
# $ nix build # Build
# $ nix develop # Instant Dev Environment
# $ nix run . -- <args...> # Run pyth-agent without installing.
# ```
#
# You can still run `nix-shell` if you prefer to not use flakes.

{
description = "Pyth Agent";
nixConfig.bash-prompt = "\[nix@pyth-agent\]$ ";
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.fenix.url = "github:nix-community/fenix";
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";

outputs =
{ self
, nixpkgs
, fenix
, flake-utils
}:

# Generate a Flake Configuration for each supported system.
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
shell = import ./shell.nix { inherit pkgs; };
rust = pkgs.makeRustPlatform {
inherit (fenix.packages.${system}.minimal)
rustc
cargo;
};

in
{
devShells.default = shell;
packages.default = rust.buildRustPackage {
pname = "pyth-agent";
version = "0.0.1";
src = ./.;
cargoLock = { lockFile = ./Cargo.lock; };
};
}
);
}
17 changes: 17 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ pkgs ? import <nixpkgs> {}
, ...
}:

with pkgs; mkShell {
buildInputs = [
clang
llvmPackages.libclang
openssl
pkgconfig
rustup
];

shellHook = ''
export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib";
'';
}

0 comments on commit 7b5985f

Please sign in to comment.