place scaffolding that enables cargo and nix builds

This commit is contained in:
Colin 2023-04-01 14:28:46 +00:00
parent 8930e45926
commit 92c20821dc
6 changed files with 130 additions and 1 deletions

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "billbot"
version = "0.1.0"

8
Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "billbot"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -2,7 +2,7 @@
_To :b:reserve and prötec_
This will be a [Matrix](https://matrix.org) bot used to track
This will be a [Matrix][matrix] bot used to track
informal debts between some (small) group of individuals.
its goals are (in order of importance):
@ -42,3 +42,35 @@ below is an example of how this bot might work:
> @user:host paid @other:host $NNN.MM
- maybe state the remaining position?
> @user:host now owes $other:host $X.YY
## Development/Hacking
this project is built with [cargo][cargo], the [Rust][rust] package manager. simply run:
```sh
$ cargo build
$ ./target/debug/billbot
```
it can also be built with [nix][nix]:
```sh
$ nix build
$ ./result/bin/billbot
```
a nix development environment (i.e. access to the correct toolchain) can be entered like so:
```sh
$ nix develop
```
after which ordinary cargo commands can be used:
```sh
nix-shell> cargo build
nix-shell> ./target/debug/billbot
```
[matrix]: https://matrix.org
[cargo]: https://doc.rust-lang.org/cargo
[rust]: https://rust-lang.org
[nix]: https://nixos.org

42
flake.lock Normal file
View File

@ -0,0 +1,42 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1678901627,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1680122840,
"narHash": "sha256-zCQ/9iFHzCW5JMYkkHMwgK1/1/kTMgCMHq4THPINpAU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a575c243c23e2851b78c00e9fa245232926ec32f",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.11",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

37
flake.nix Normal file
View File

@ -0,0 +1,37 @@
{
description = "Billbot matrix billshare bot";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.11";
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; eachSystem allSystems (system:
let
pkgs = import nixpkgs {
inherit system;
};
in rec {
packages = {
# docs: <nixpkgs>/doc/languages-frameworks/rust.section.md
mx-billbot = pkgs.rustPlatform.buildRustPackage {
name = "mx-billbot";
src = self;
cargoLock.lockFile = ./Cargo.lock;
# enables debug builds, if we want: https://github.com/NixOS/nixpkgs/issues/60919.
hardeningDisable = [ "fortify" ];
};
};
defaultPackage = packages.mx-billbot;
devShells.default = with pkgs; mkShell {
# enables debug builds, if we want: https://github.com/NixOS/nixpkgs/issues/60919.
hardeningDisable = [ "fortify" ];
# Allow cargo to download crates.
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
nativeBuildInputs = [ cargo ];
};
});
}

3
src/main.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}