-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
48 lines (46 loc) · 1.43 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Credit to https://github.com/srid/rust-nix-template/blob/master/flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
rust-toolchain = pkgs.symlinkJoin {
name = "rust-toolchain";
paths = with pkgs; [
rustc
cargo
cargo-watch
rust-analyzer
rustfmt
];
};
in
rec {
# This builds the blog binary then runs it and collects the output. Once done it throws away the binary and
# shoves the newly created static site into the result.
packages.default = pkgs.rustPlatform.buildRustPackage {
name = "blog";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
postBuild = ''
./target/*/release/blog
'';
installPhase = ''
cp -r ./out $out
'';
};
overlays.default = packages.default;
# Rust dev environment
devShells.default = pkgs.mkShell {
shellHook = ''
# For rust-analyzer 'hover' tooltips to work.
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
'';
nativeBuildInputs = [ rust-toolchain ];
};
});
}