guile-goblins-rs/flake.nix

83 lines
2.7 KiB
Nix

{
description = "uhhhhh goblins?";
# references
# https://github.com/oxalica/rust-overlay
# https://hoverbear.org/blog/a-flake-for-your-crate/
# https://srid.ca/rust-nix
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
naersk.url = "github:nmattia/naersk";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, naersk, rust-overlay, flake-utils, ... }:
let
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
in (flake-utils.lib.eachDefaultSystem (system:
let
# overlay containing a package built from this repo's Cargo.toml
mypkgoverlay = final: prev: {
"${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; };
};
overlays = [ (import rust-overlay) mypkgoverlay ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
with pkgs;
{
devShells.default = mkShell {
buildInputs = [
openssl
pkg-config
guile_3_0
guile-fibers
autoconf
automake.out
(rust-bin.stable.latest.default.override {
extensions = ["rust-src"];
targets = [ ];
})
];
shellHook = ''
find_path_containing_file () {
find "$1" -type f -name "$2" -exec dirname "{}" \; -quit
}
# fibers. path containing fibers.scm
export GUILE_LOAD_PATH="$(find_path_containing_file ${pkgs.guile-fibers} fibers.scm):$GUILE_LOAD_PATH"
# gcrypt hash. path containing directory containing hash.scm
export GUILE_LOAD_PATH="$(dirname $(find_path_containing_file ${pkgs.guile-gcrypt} hash.scm)):$GUILE_LOAD_PATH"
# goblins itself. assume it's in a subdirectory of pwd named "guile-goblins"
# stopgap until i build goblins itself in nix and pull that in.
export GUILE_LOAD_PATH="$(pwd)/guile-goblins:$GUILE_LOAD_PATH"
export GUILE_LOAD_PATH="$(pwd)/guile-modules:$GUILE_LOAD_PATH"
alias repl="cargo run --example repl"
echo "run 'repl' to start a repl embedded in rust"
'';
};
packages = {
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
};
defaultPackage = (import nixpkgs {
inherit system overlays;
})."${cargoToml.package.name}";
}
))
//
(
#flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: {
({
nixosModule = (import ./modules self);
})
);
}