set up project

This commit is contained in:
Nickiel12 2024-07-17 02:17:42 +00:00
parent 1f2f746654
commit ea8ccdc30b
8 changed files with 2082 additions and 127 deletions

6
.gitignore vendored
View file

@ -1,3 +1,3 @@
/target /target
.direnv .direnv
result result

1886
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,3 @@
[workspace] [workspace]
members = ["helloworld"] members = ["vcs-obs-satellite"]
resolver = "2" resolver = "2"

62
flake.lock Normal file
View file

@ -0,0 +1,62 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1720957393,
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1718428119,
"narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1721096425,
"narHash": "sha256-9/58mnoDCyBHsJZwTg3MfgX3kgVqP/SzGMy0WnnWII8=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "1c95d396d7395829b5c06bea84fb1dd23169ca42",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

220
flake.nix
View file

@ -1,110 +1,110 @@
/* /*
TODO TODO
1. Find and replace "helloworld" with your package name for **ALL FILES IN REPOSITORY** 1. Find and replace "helloworld" with your package name for **ALL FILES IN REPOSITORY**
2. Add a flake description that describes the workspace on line 27 2. Add a flake description that describes the workspace on line 27
3. Add a package description on line 70 3. Add a package description on line 70
4. (optional) uncomment `nativeBuildInputs` and `buildInputs` on lines 43 and 44 if you need openssl 4. (optional) uncomment `nativeBuildInputs` and `buildInputs` on lines 43 and 44 if you need openssl
5. (optional) set your project homepage, license, and maintainers list on lines 48-51 5. (optional) set your project homepage, license, and maintainers list on lines 48-51
6. (optional) uncomment the NixOS module and update it for your needs 6. (optional) uncomment the NixOS module and update it for your needs
7. Delete this comment block 7. Delete this comment block
*/ */
/* /*
Some utility commands: Some utility commands:
- `nix flake update --commit-lock-file` - `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>` - `nix flake lock update-input <input>`
- `nix build .#helloworld` or `nix build .` - `nix build .#helloworld` or `nix build .`
- `nix run .#helloworld` or `nix run .` - `nix run .#helloworld` or `nix run .`
*/ */
{ {
description = ""; description = "Companion program to VCS Cotroller to control OBS on a remote machine";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = { self, nixpkgs, rust-overlay }: outputs = { self, nixpkgs, rust-overlay }:
let let
overlays = [ (import rust-overlay) ]; overlays = [ (import rust-overlay) ];
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system overlays;
}; };
rustSettings = with pkgs; { rustSettings = with pkgs; {
src = ./.; src = ./.;
#nativeBuildInputs = [ pkg-config ]; #nativeBuildInputs = [ pkg-config ];
#buildInputs = [ openssl ]; buildInputs = [ obs-studio ];
cargoHash = nixpkgs.lib.fakeHash; cargoHash = nixpkgs.lib.fakeHash;
}; };
meta = with nixpkgs.lib; { meta = with nixpkgs.lib; {
#homepage = "https://example.com"; #homepage = "https://example.com";
#license = [ licenses.gpl3 ]; #license = [ licenses.gpl3 ];
platforms = [ system ]; platforms = [ system ];
#maintainers = with maintainers; [ ]; #maintainers = with maintainers; [ ];
}; };
in { in {
devShells.${system}.default = with pkgs; mkShell { devShells.${system}.default = with pkgs; mkShell {
packages = [ packages = [
(pkgs.rust-bin.stable.latest.default.override { (pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ]; extensions = [ "rust-src" ];
}) })
cargo-edit cargo-edit
bacon bacon
]; ];
inputsFrom = with self.packages.${system}; [ helloworld ]; inputsFrom = with self.packages.${system}; [ helloworld ];
}; };
packages.${system} = { packages.${system} = {
default = self.packages.${system}.helloworld; default = self.packages.${system}.helloworld;
helloworld = pkgs.rustPlatform.buildRustPackage (rustSettings // { helloworld = pkgs.rustPlatform.buildRustPackage (rustSettings // {
pname = "helloworld"; pname = "vcs-obs-satellite";
version = "0.1.0"; version = "0.1.0";
buildAndTestSubdir = "helloworld"; buildAndTestSubdir = "vcs-obs-satellite";
cargoHash = "sha256-+TaGIiKf+Pz2bTABeG8aCZz0/ZTCKl5398+qbas4Nvo="; cargoHash = "sha256-+TaGIiKf+Pz2bTABeG8aCZz0/ZTCKl5398+qbas4Nvo=";
meta = meta // { meta = meta // {
description = ""; description = "";
}; };
}); });
}; };
/* /*
nixosModules.default = { config, ... }: let nixosModules.default = { config, ... }: let
lib = nixpkgs.lib; lib = nixpkgs.lib;
in { in {
options.services.helloworld = { options.services.helloworld = {
enable = lib.mkEnableOption (lib.mdDoc "helloworld service"); enable = lib.mkEnableOption (lib.mdDoc "helloworld service");
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = self.packages.${system}.helloworld; default = self.packages.${system}.helloworld;
defaultText = "pkgs.helloworld"; defaultText = "pkgs.helloworld";
description = lib.mdDoc '' description = lib.mdDoc ''
The helloworld package that should be used. The helloworld package that should be used.
''; '';
}; };
port = lib.mkOption { port = lib.mkOption {
type = lib.types.port; type = lib.types.port;
default = 8000; default = 8000;
description = lib.mdDoc '' description = lib.mdDoc ''
The port at which to run. The port at which to run.
''; '';
}; };
}; };
config.systemd.services.helloworld = let config.systemd.services.helloworld = let
cfg = config.services.helloworld; cfg = config.services.helloworld;
pkg = self.packages.${system}.helloworld; pkg = self.packages.${system}.helloworld;
in lib.mkIf cfg.enable { in lib.mkIf cfg.enable {
description = pkg.meta.description; description = pkg.meta.description;
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "network.target" ]; wantedBy = [ "network.target" ];
serviceConfig = { serviceConfig = {
ExecStart = '' ExecStart = ''
${cfg.package}/bin/helloworld --port ${builtins.toString cfg.port} ${cfg.package}/bin/helloworld --port ${builtins.toString cfg.port}
''; '';
Restart = "always"; Restart = "always";
DynamicUser = true; DynamicUser = true;
}; };
}; };
}; };
*/ */
}; };
} }

View file

@ -1,8 +0,0 @@
[package]
name = "helloworld"
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

@ -0,0 +1,15 @@
[package]
name = "helloworld"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
console-subscriber = "0.3.0"
obws = "0.12.0"
tokio = { version = "1.38.1", features = ["rt-multi-thread"] }
tokio-tungstenite = "0.23.1"
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.18", features = ["tracing-log"] }

View file

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