Skip to content

Commit

Permalink
feat: init cli and formatting
Browse files Browse the repository at this point in the history
* feat: add treefmt and format everythign

* feat: add cli

* fix: properly name fly env var

* chore: justfile tweaks

* chore: add cache configs to flake.nix

* feat: add some concurrent fragments

* bump to 0.1.1
  • Loading branch information
ajaxbits authored Apr 21, 2024
1 parent dd04898 commit 164d915
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 179 deletions.
288 changes: 243 additions & 45 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vpod"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "Unlicense"

Expand All @@ -13,6 +13,7 @@ lto = true
[dependencies]
axum = { version = "0.5.17", features = ["axum-macros", "query"] }
chrono = { version = "0.4.22", features = ["serde"] }
clap = { version = "4.5.4", features = ["derive", "env"] }
color-eyre = "0.6.2"
fs_extra = "1.3.0"
futures = "0.3.25"
Expand All @@ -33,6 +34,10 @@ tokio = { version = "1.21.2", features = ["full"] }
tokio-util = "0.7.4"
tower = "0.4.13"
tower-http = { version = "0.3.4", features = ["fs"] }
youtube_dl = { version = "0.7.0", default-features = false, features = ["yt-dlp", "tokio"] }
url = "2.5.0"
youtube_dl = { version = "0.7.0", default-features = false, features = [
"yt-dlp",
"tokio",
] }
yt-feed-xml = "0.2.2"
ytd-rs = { version = "0.1.7", features = ["yt-dlp"] }
65 changes: 35 additions & 30 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
{ config, dream2nix, ... }:
{
config,
dream2nix,
...
}: {
imports = [
dream2nix.modules.dream2nix.rust-cargo-lock
dream2nix.modules.dream2nix.rust-crane
];

deps = {
nixpkgs,
latest,
...
}: {
inherit
(nixpkgs)
stdenv
pkg-config
rustc
openssl
lib
makeWrapper
;
inherit (latest) yt-dlp;
};
deps =
{ nixpkgs, latest, ... }:
{
inherit (nixpkgs)
stdenv
pkg-config
rustc
openssl
lib
makeWrapper
;
inherit (latest) yt-dlp;
};

mkDerivation = with config.deps; {
src = ./.;
buildInputs = [openssl rustc];
nativeBuildInputs = [pkg-config makeWrapper];
postFixup = let
inherit (config.deps) lib yt-dlp;
in ''
wrapProgram $out/bin/vpod \
--set PATH ${lib.makeBinPath [yt-dlp]}
'';
buildInputs = [
openssl
rustc
];
nativeBuildInputs = [
pkg-config
makeWrapper
];
postFixup =
let
inherit (config.deps) lib yt-dlp;
in
''
wrapProgram $out/bin/vpod \
--set PATH ${lib.makeBinPath [ yt-dlp ]}
'';
};

rust-crane = {
depsDrv.mkDerivation = with config.deps; {
buildInputs = [openssl rustc];
nativeBuildInputs = [pkg-config];
buildInputs = [
openssl
rustc
];
nativeBuildInputs = [ pkg-config ];
};
runTests = false;
};
Expand Down
53 changes: 52 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 67 additions & 41 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,78 @@
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
latest.url = "github:nixos/nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
systems.url = "github:nix-systems/default";
};

outputs = inputs @ {
self,
nixpkgs,
dream2nix,
latest,
...
}: let
system = "x86_64-linux";

name = "vpod";
version = "0.1.0";
in {
packages.${system} = {
default = dream2nix.lib.evalModules {
packageSets = {
nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
latest = import latest {inherit system;};
};
nixConfig = {
extra-substituters = [
"https://cache.garnix.io"
"https://numtide.cachix.org"
];
extra-trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE="
];
};

modules = [
./default.nix
{
inherit name version;
paths = {
projectRoot = ./.;
projectRootFile = "flake.nix";
package = ./.;
};
}
];
};
outputs =
inputs@{
self,
nixpkgs,
dream2nix,
latest,
treefmt-nix,
systems,
...
}:
let
system = "x86_64-linux";

name = "vpod";
version = "0.1.1";

eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in
{
packages.${system} = {
default = dream2nix.lib.evalModules {
packageSets = {
nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
latest = import latest { inherit system; };
};

oci-image = let
inherit (nixpkgs.legacyPackages.${system}) dockerTools;
in
dockerTools.buildLayeredImage {
inherit name;
tag = version;
maxLayers = 128;
contents = [dockerTools.caCertificates];
config.Cmd = [
"${self.packages.${system}.default}/bin/vpod"
modules = [
./default.nix
{
inherit name version;
paths = {
projectRoot = ./.;
projectRootFile = "flake.nix";
package = ./.;
};
}
];
};

oci-image =
let
inherit (nixpkgs.legacyPackages.${system}) dockerTools;
in
dockerTools.buildLayeredImage {
inherit name;
tag = version;
maxLayers = 128;
contents = [ dockerTools.caCertificates ];
config.Cmd = [ "${self.packages.${system}.default}/bin/vpod" ];
};
};

formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);

checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
};
};
}
56 changes: 28 additions & 28 deletions fly.staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ kill_timeout = 5
processes = []

[env]
ENV = "staging"
ENV = "staging"

[build]
image = "vpod:dev"
image = "vpod:dev"

[experimental]
allowed_public_ports = []
auto_rollback = true
allowed_public_ports = []
auto_rollback = true

[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
force_https = true
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
force_https = true
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
Loading

0 comments on commit 164d915

Please sign in to comment.