2023-12-01 06:15:57 -06:00
|
|
|
# Credit to https://github.com/srid/rust-nix-template/blob/master/flake.nix
|
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
2024-04-15 13:01:30 -05:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
self = {
|
|
|
|
flake = false;
|
|
|
|
type = "git";
|
|
|
|
url = "git+file:./.?submodules=1";
|
|
|
|
};
|
2023-12-01 06:15:57 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2024-04-15 13:01:30 -05:00
|
|
|
# src = builtins.fetchGit {
|
|
|
|
# url = ./.;
|
|
|
|
# # inherit (self) (rev or dirtyRev);
|
|
|
|
# rev = toString (self.rev or self.dirtyRev);
|
|
|
|
# # shallow = true;
|
|
|
|
# submodules = true;
|
|
|
|
# };
|
2023-12-01 06:15:57 -06:00
|
|
|
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";
|
2024-04-15 13:01:30 -05:00
|
|
|
src = "${self}";
|
2023-12-01 06:15:57 -06:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|