aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-08-11 19:47:15 -0400
committerXe Iaso <me@xeiaso.net>2023-08-11 19:47:15 -0400
commit6607ca0ec6565130aaec80cc750ce5d3cde15924 (patch)
tree0e058be362304419e21ea23dd95f49ddb34c3f2a /cmd
parente50eae921dc8189f8ea34636a77d61897898f019 (diff)
downloadx-6607ca0ec6565130aaec80cc750ce5d3cde15924.tar.xz
x-6607ca0ec6565130aaec80cc750ce5d3cde15924.zip
cmd/yeet: revolutionize a few apps
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/todayinmarch2020/templates/index.html96
-rw-r--r--cmd/todayinmarch2020/yeetfile.js30
-rw-r--r--cmd/within.website/config.ts37
-rw-r--r--cmd/within.website/yeetfile.js7
-rw-r--r--cmd/yeet/main.go26
5 files changed, 83 insertions, 113 deletions
diff --git a/cmd/todayinmarch2020/templates/index.html b/cmd/todayinmarch2020/templates/index.html
index 1192223..40c326f 100644
--- a/cmd/todayinmarch2020/templates/index.html
+++ b/cmd/todayinmarch2020/templates/index.html
@@ -3,97 +3,11 @@
<head>
<title>What Day of March 2020 Is It?</title>
+ <link rel="stylesheet" href="https://cdn.xeiaso.net/static/pkg/xess/xess.css" />
<style>
- main {
- font-family: monospace, monospace;
- max-width: 38rem;
- padding: 2rem 0;
- margin: auto;
- }
-
- @media only screen and (max-device-width: 736px) {
- main {
- padding: 0rem;
- }
- }
-
- ::selection {
- background: #d3869b;
- }
-
- body {
- background: #282828;
- color: #ebdbb2;
- }
-
- main {
- text-align: center;
- }
-
- pre {
- background-color: #3c3836;
- padding: 1em;
- border: 0;
- }
-
- a,
- a:active,
- a:visited {
- color: #b16286;
- background-color: #1d2021;
- }
-
- h1,
- h2,
- h3,
- h4,
- h5 {
- margin-bottom: .1rem;
- }
-
- blockquote {
- border-left: 1px solid #bdae93;
- margin: 0.5em 10px;
- padding: 0.5em 10px;
- }
-
- footer {
- align: center;
- }
-
- @media (prefers-color-scheme: light) {
- body {
- background: #fbf1c7;
- color: #3c3836;
- }
-
- pre {
- background-color: #ebdbb2;
- padding: 1em;
- border: 0;
- }
-
- a,
- a:active,
- a:visited {
- color: #b16286;
- background-color: #f9f5d7;
- }
-
- h1,
- h2,
- h3,
- h4,
- h5 {
- margin-bottom: .1rem;
- }
-
- blockquote {
- border-left: 1px solid #655c54;
- margin: 0.5em 10px;
- padding: 0.5em 10px;
- }
- }
+ main {
+ text-align: center;
+ }
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
@@ -115,7 +29,7 @@
<footer>
<p>From <a href="https://christine.website">Within</a> - <a
href="https://twitter.com/theprincessxena">@theprincessxena</a> - <a
- href="https://tulpa.dev/cadey/todayinmarch2020">Source Code</a></p>
+ href="https://github.com/Xe/x/tree/master/cmd/todayinmarch2020">Source Code</a></p>
</footer>
</main>
</body>
diff --git a/cmd/todayinmarch2020/yeetfile.js b/cmd/todayinmarch2020/yeetfile.js
new file mode 100644
index 0000000..1abdc68
--- /dev/null
+++ b/cmd/todayinmarch2020/yeetfile.js
@@ -0,0 +1,30 @@
+yeet.setenv("GOOS", "linux");
+yeet.setenv("GOARCH", "amd64");
+yeet.setenv("CGO_ENABLED", "0");
+
+go.build();
+const fname = slug.build("todayinmarch2020");
+
+const url = slug.push(fname);
+const hash = nix.hashURL(url);
+
+const expr = nix.expr`{ stdenv }:
+
+stdenv.mkDerivation {
+ name = "todayinmarch2020";
+ src = builtins.fetchurl {
+ url = ${url};
+ sha256 = ${hash};
+ };
+
+ phases = "installPhase";
+
+ installPhase = ''
+ tar xf $src
+ mkdir -p $out/bin
+ cp bin/main $out/bin/todayinmarch2020
+ '';
+}
+`;
+
+file.write("/home/cadey/code/nixos-configs/pkgs/x/todayinmarch2020.nix", expr);
diff --git a/cmd/within.website/config.ts b/cmd/within.website/config.ts
index e69de29..e79434d 100644
--- a/cmd/within.website/config.ts
+++ b/cmd/within.website/config.ts
@@ -0,0 +1,37 @@
+export interface Repo {
+ kind: "gitea" | "github";
+ domain: string;
+ user: string;
+ repo: string;
+ description: string;
+}
+
+const githubRepo = (name: string, description: string): Repo => {
+ return {
+ kind: "github",
+ domain: "github.com",
+ user: "Xe",
+ repo: name,
+ description,
+ };
+};
+
+const giteaRepo = (name: string, description: string): Repo => {
+ return {
+ kind: "gitea",
+ domain: "tulpa.dev",
+ user: "cadey",
+ repo: name,
+ description,
+ };
+};
+
+const repos: Repo[] = [
+ githubRepo("derpigo", "A Derpibooru/Furbooru API client in Go. This is used to monitor Derpibooru/Furbooru for images by artists I care about and archive them."),
+ githubRepo("eclier", "A command router for Go programs that implements every command in Lua. This was an experiment for making extensible command-line applications with Lua for extending them."),
+ giteaRepo("gopher", "A Gopher (RFC 1436) client/server stack for Go applications. This allows users to write custom Gopher clients and servers."),
+ githubRepo("ln", "The natural log function for Go: an easy package for structured logging. This is the logging stack that I use for most of my personal projects."),
+ githubRepo("x", "Various experimental things. /x/ is my monorepo of side projects, hobby programming, and other explorations of how programming in Go can be."),
+];
+
+export default repos;
diff --git a/cmd/within.website/yeetfile.js b/cmd/within.website/yeetfile.js
index 676443e..b79868c 100644
--- a/cmd/within.website/yeetfile.js
+++ b/cmd/within.website/yeetfile.js
@@ -1,12 +1,13 @@
yeet.setenv("GOOS", "linux");
yeet.setenv("GOARCH", "amd64");
+yeet.setenv("CGO_ENABLED", "0");
go.build();
-slug.build("within.website", {
+const fname = slug.build("within.website", {
"config.ts": "config.ts"
});
-const url = slug.push("within.website");
+const url = slug.push(fname);
const hash = nix.hashURL(url);
const expr = nix.expr`{ stdenv }:
@@ -23,7 +24,7 @@ stdenv.mkDerivation {
installPhase = ''
tar xf $src
mkdir -p $out/bin
- cp web $out/bin/withinwebsite
+ cp bin/main $out/bin/withinwebsite
cp config.ts $out/config.ts
'';
}
diff --git a/cmd/yeet/main.go b/cmd/yeet/main.go
index ed76fe7..76e4140 100644
--- a/cmd/yeet/main.go
+++ b/cmd/yeet/main.go
@@ -11,6 +11,7 @@ import (
"runtime"
"runtime/debug"
"strconv"
+ "strings"
"github.com/dop251/goja"
"golang.org/x/exp/slog"
@@ -90,13 +91,14 @@ func nixbuild(target string) {
runcmd("nix", "build", target)
}
-func slugbuild(bin string, extraFiles map[string]string) {
- appsluggr.Must(bin, fmt.Sprintf("%s-%s.tar.gz", bin, yeet.DateTag), extraFiles)
+func slugbuild(bin string, extraFiles map[string]string) string {
+ result := fmt.Sprintf("%s-%s.tar.gz", bin, yeet.DateTag)
+ appsluggr.Must(bin, result, extraFiles)
os.Remove(bin)
+ return result
}
-func slugpush(bin string) string {
- fname := fmt.Sprintf("%s-%s.tar.gz", bin, yeet.DateTag)
+func slugpush(fname string) string {
fin, err := os.Open(fname)
if err != nil {
panic(err)
@@ -113,20 +115,6 @@ func slugpush(bin string) string {
}
func buildNixExpr(literals []string, exprs ...any) string {
- /*
- function nix(strings, ...expressions) {
- let result = "";
- expressions.forEach((value, i) => {
- let formattedValue = `(builtins.fromJSON ${JSON.stringify(JSON.stringify(value))});`;
- result += `${strings[i]} ${formattedValue}`;
- });
-
- result += strings[strings.length - 1]
-
- return result;
- }
- */
-
result := ""
for i, value := range exprs {
formattedValue, _ := json.Marshal(value)
@@ -203,7 +191,7 @@ func main() {
vm.Set("nix", map[string]any{
"build": nixbuild,
- "hashURL": func(fileURL string) string { return runcmd("nix-prefetch-url", fileURL) },
+ "hashURL": func(fileURL string) string { return strings.TrimSpace(runcmd("nix-prefetch-url", fileURL)) },
"expr": buildNixExpr,
"eval": evalNixExpr,
})