Skip to content

Commit 80a4787

Browse files
committed
Create initial project files
0 parents  commit 80a4787

11 files changed

Lines changed: 151 additions & 0 deletions

File tree

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
target-dir = ".build/target"

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*.lock]
4+
5+
[*]
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
indent_style = space
9+
10+
[**.{nix,sh,rs,toml}]
11+
indent_size = 2

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.build/
2+
.history

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# https://doc.rust-lang.org/cargo/reference/manifest.html
2+
3+
[package]
4+
name = "tabletbot"
5+
version = "1.0.0"
6+
authors = [ "InfinityGhost" ]
7+
edition = "2021"
8+
9+
[dependencies]

default.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ lib
2+
, rustPlatform
3+
}:
4+
5+
rustPlatform.buildRustPackage rec {
6+
pname = "tabletbot";
7+
name = pname;
8+
9+
src = ./src;
10+
11+
cargoLock = {
12+
lockFile = ./src/Cargo.lock;
13+
};
14+
}

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
description = "TabletBot";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
};
7+
8+
outputs = attrs @ { self, nixpkgs, ... }: let
9+
10+
system = "x86_64-linux";
11+
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
config.allowUnfree = true;
15+
};
16+
17+
in {
18+
19+
packages.${system} = rec {
20+
tabletbot = pkgs.callPackage ./. {};
21+
default = tabletbot;
22+
};
23+
24+
devShell.${system} = import ./shell.nix { inherit pkgs; };
25+
26+
};
27+
}

shell.nix

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# https://nixos.wiki/wiki/Rust#Installation_via_rustup
2+
{ pkgs ? import <nixpkgs> {} }:
3+
let
4+
readFileIfExists = path: with pkgs.lib; if pathExists path then readFile path else null;
5+
6+
rustDeps = with pkgs; [
7+
llvmPackages_latest.llvm
8+
llvmPackages_latest.bintools
9+
zlib.out
10+
rustup
11+
xorriso
12+
grub2
13+
qemu
14+
llvmPackages_latest.lld
15+
python3
16+
];
17+
18+
deps = with pkgs; [];
19+
20+
buildPath = toString ./.build/out;
21+
22+
build = pkgs.writers.writeBashBin "build" ''
23+
cd ${toString ./src}
24+
cargo build
25+
'';
26+
27+
run = pkgs.writers.writeBashBin "run" ''
28+
cd ${toString ./src}
29+
cargo run
30+
'';
31+
32+
utils = [
33+
build # cargo build
34+
run # cargo run
35+
];
36+
37+
in pkgs.mkShell rec {
38+
RUSTC_VERSION = readFileIfExists ./rust-toolchain;
39+
CARGO_HOME = toString ./.build/cargo;
40+
RUSTUP_HOME = toString ./.build/rustup;
41+
42+
buildInputs = with pkgs; rustDeps ++ deps ++ utils;
43+
44+
shellHook = with pkgs.lib; ''
45+
export LD_LIBRARY_PATH=${escapeShellArg (makeLibraryPath buildInputs)}
46+
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
47+
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
48+
'';
49+
}

0 commit comments

Comments
 (0)