rust
Elnu 1 year ago
parent 1aecdf3333
commit de67ef1dec

@ -1 +1 @@
use nix
use flake

12
.gitignore vendored

@ -1,11 +1,3 @@
# Ignore challenge submissions to prevent bloating git repo
/assets/
# Ignore challenge data files
/data/
# Added by cargo
/target
.env
*.db
.direnv
result

@ -0,0 +1,5 @@
{
"rust-analyzer.linkedProjects": [
"./tegakituesday/Cargo.toml",
]
}

@ -1,29 +1,3 @@
[package]
name = "tegakituesday"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
accept-language = "2.0.0"
chrono = { version = "0.4.26", features = ["serde"] }
clap = "4.3.9"
comrak = "0.18.0"
derive_more = "0.99.17"
dotenv = "0.15.0"
gettext = "0.4.0"
gh-emoji = "1.0.7"
poise = "0.5.5"
r2d2 = "0.8.10"
r2d2_sqlite = "0.22.0"
regex = "1.8.4"
reqwest = "0.11.18"
rocket = { version = "=0.5.0-rc.3", features = ["secrets", "json"] }
rocket_contrib = { version = "0.4.11", features = ["templates"] }
rocket_dyn_templates = { version = "0.1.0-rc.3", features = ["tera"] }
rusqlite = { version = "0.29.0", features = ["chrono"] }
serde = "1.0.163"
serde_json = "1.0.96"
serde_yaml = "0.9.21"
tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] }
[workspace]
members = ["tegakituesday"]
resolver = "2"

@ -0,0 +1,96 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1693377291,
"narHash": "sha256-vYGY9bnqEeIncNarDZYhm6KdLKgXMS+HA2mTRaWEc80=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e7f38be3775bab9659575f192ece011c033655f0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1681358109,
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1693447852,
"narHash": "sha256-K9npbs4S6+r51vpiElJi+0vwbAeftCAcOGbot/PCBnQ=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "40e851593ef4f9f8cd0b69c8cae7b722b9953a23",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

@ -0,0 +1,118 @@
/*
Some utility commands:
- `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>`
- `nix build .#tegakituesday` or `nix build .`
- `nix run .#tegakituesday` or `nix run .`
*/
{
description = "The website for the Tegaki Tuesday handwriting challenge.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, rust-overlay }:
let
overlays = [ (import rust-overlay) ];
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.nightly.latest;
rust-bin = rust.minimal;
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-bin;
rustc = rust-bin;
};
rustSettings = with pkgs; {
src = ./.;
cargoHash = nixpkgs.lib.fakeHash;
};
meta = with nixpkgs.lib; {
homepage = "https://tegakituesday.com";
#license = [ licenses.unfree ];
platforms = [ system ];
maintainers = with maintainers; [ elnudev ];
};
in {
devShells.${system}.default = with pkgs; mkShell {
packages = [
(pkgs.rust-bin.nightly.latest.default.override {
extensions = [ "rust-src" ];
})
cargo-edit
bacon
];
inputsFrom = with self.packages.${system}; [ tegakituesday ];
allowUnfree = true;
};
packages.${system} = {
default = self.packages.${system}.tegakituesday;
tegakituesday = rustPlatform.buildRustPackage (rustSettings // {
pname = "tegakituesday";
version = "0.1.0";
nativeBuildInputs = with pkgs; [ pkg-config dart-sass ];
buildInputs = with pkgs; [ openssl gettext sqlite ];
buildAndTestSubdir = "tegakituesday";
cargoHash = "sha256-FBQGBUmLjg1CWFVBlbAqNfRCdIWyuqvlPzpBdOjYLbc=";
postPatch = ''
pushd tegakituesday
sass styles/sass/style.sass:$out/share/styles/css/style.css
if [ -d assets ]; then
cp -r assets $out/share
else
mkdir -p $out/share/assets
fi
cp -r static $out/share
sed -i -E "s|relative\!\(\"([^\"]+)\"\)|\"''${out}\/share\/\1\"|" src/main.rs
popd
'';
meta = meta // {
description = "The website for the Tegaki Tuesday handwriting challenge.";
};
});
};
/*
nixosModules.default = { config, ... }: let
lib = nixpkgs.lib;
in {
options.services.tegakituesday = {
enable = lib.mkEnableOption (lib.mdDoc "tegakituesday service");
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${system}.tegakituesday;
defaultText = "pkgs.tegakituesday";
description = lib.mdDoc ''
The tegakituesday package that should be used.
'';
};
port = lib.mkOption {
type = lib.types.port;
default = 8000;
description = lib.mdDoc ''
The port at which to run.
'';
};
};
config.systemd.services.tegakituesday = let
cfg = config.services.tegakituesday;
pkg = self.packages.${system}.tegakituesday;
in lib.mkIf cfg.enable {
description = pkg.meta.description;
after = [ "network.target" ];
wantedBy = [ "network.target" ];
serviceConfig = {
ExecStart = ''
${cfg.package}/bin/tegakituesday --port ${builtins.toString cfg.port}
'';
Restart = "always";
DynamicUser = true;
};
};
};
*/
};
}

@ -1,24 +0,0 @@
# <shell.nix>
{ pkgs ? import <nixpkgs> {}}:
let
rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz");
pkgs = import <nixpkgs> { overlays = [ rust_overlay ]; };
rustnightly = (pkgs.rust-bin.nightly.latest.default.override {
extensions = [
"rust-src"
];
});
in
pkgs.mkShell {
buildInputs = with pkgs; [
rustnightly
rust-analyzer
bacon
pkg-config
openssl
gettext
sqlite
dart-sass
];
}

@ -0,0 +1,8 @@
# Ignore challenge submissions to prevent bloating git repo
/assets/
# Ignore challenge data files
/data/
.env
*.db

@ -0,0 +1,29 @@
[package]
name = "tegakituesday"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
accept-language = "2.0.0"
chrono = { version = "0.4.26", features = ["serde"] }
clap = "4.3.9"
comrak = "0.18.0"
derive_more = "0.99.17"
dotenv = "0.15.0"
gettext = "0.4.0"
gh-emoji = "1.0.7"
poise = "0.5.5"
r2d2 = "0.8.10"
r2d2_sqlite = "0.22.0"
regex = "1.8.4"
reqwest = "0.11.18"
rocket = { version = "=0.5.0-rc.3", features = ["secrets", "json"] }
rocket_contrib = { version = "0.4.11", features = ["templates"] }
rocket_dyn_templates = { version = "0.1.0-rc.3", features = ["tera"] }
rusqlite = { version = "0.29.0", features = ["chrono"] }
serde = "1.0.163"
serde_json = "1.0.96"
serde_yaml = "0.9.21"
tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] }

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save