Skip to content

Commit

Permalink
chore: Add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
leo91000 committed Jan 27, 2024
1 parent 781dc9d commit 005565b
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
80 changes: 80 additions & 0 deletions flake.lock

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

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
};

outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
perSystem = { config, self', pkgs, lib, system, ... }:
let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
nonRustDeps = [
pkgs.libiconv
];
rust-toolchain = pkgs.symlinkJoin {
name = "rust-toolchain";
paths = [ pkgs.rustc pkgs.cargo pkgs.cargo-watch pkgs.rustPlatform.rustcSrc ];
};
in
{
# Rust package
packages.default = pkgs.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};

# Rust dev environment
devShells.default = pkgs.mkShell {
shellHook = ''
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
'';
buildInputs = nonRustDeps;
nativeBuildInputs = with pkgs; [
just
rust-toolchain
];
RUST_BACKTRACE = 1;
};
};
};
}

0 comments on commit 005565b

Please sign in to comment.