mirror of
https://github.com/kmein/niveum
synced 2026-03-18 19:11:08 +01:00
Compare commits
12 Commits
nethack
...
32fa3e75ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 32fa3e75ea | |||
| 435aa4a365 | |||
| 8d955bf640 | |||
| a44d15a166 | |||
| b33e1d3569 | |||
| cba0f92a7a | |||
| 1f163d65cd | |||
| e816145b13 | |||
| 4cb62b382b | |||
| ad2c922ab4 | |||
| a0f7867a25 | |||
| dd75268d60 |
114
.bin/mp3player-write
Executable file
114
.bin/mp3player-write
Executable file
@@ -0,0 +1,114 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# ./mp3_transfer.sh -s 1.3 /mnt/mp3player file1.m4a file2.m4a ...
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Default speed
|
||||||
|
SPEED=1.0
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while getopts ":s:" opt; do
|
||||||
|
case $opt in
|
||||||
|
s)
|
||||||
|
SPEED=$OPTARG
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
echo "Option -$OPTARG requires a value." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Shift past the options
|
||||||
|
shift $((OPTIND -1))
|
||||||
|
|
||||||
|
# Check arguments
|
||||||
|
if [ "$#" -lt 2 ]; then
|
||||||
|
echo "Usage: $0 [-s speed] MOUNT_POINT FILE1 [FILE2 ...]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MOUNT_POINT=$1
|
||||||
|
shift
|
||||||
|
FILES=("$@")
|
||||||
|
|
||||||
|
# Check mount point exists
|
||||||
|
if [ ! -d "$MOUNT_POINT" ]; then
|
||||||
|
echo "Error: Mount point '$MOUNT_POINT' does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Estimate required space
|
||||||
|
TOTAL_SIZE=0
|
||||||
|
for f in "${FILES[@]}"; do
|
||||||
|
if [ ! -f "$f" ]; then
|
||||||
|
echo "Warning: File '$f' does not exist, skipping."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Get file size in bytes
|
||||||
|
FILE_SIZE=$(stat --printf="%s" "$f")
|
||||||
|
# Estimate mp3 output size: roughly 1/2 of original m4a (adjust if needed)
|
||||||
|
TOTAL_SIZE=$((TOTAL_SIZE + FILE_SIZE / 2))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Get available space in bytes
|
||||||
|
AVAILABLE=$(df --output=avail "$MOUNT_POINT" | tail -n 1)
|
||||||
|
AVAILABLE=$((AVAILABLE * 1024)) # df reports in KB
|
||||||
|
|
||||||
|
if [ "$TOTAL_SIZE" -gt "$AVAILABLE" ]; then
|
||||||
|
echo "Error: Not enough space on device. Required: $TOTAL_SIZE bytes, Available: $AVAILABLE bytes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Enough space available. Starting conversion..."
|
||||||
|
|
||||||
|
sanitize_filename() {
|
||||||
|
local name="$1"
|
||||||
|
# Remove path, keep only base name
|
||||||
|
name=$(basename "$name" .m4a)
|
||||||
|
# Replace spaces and special chars with underscore
|
||||||
|
name=$(echo "$name" | tr ' ' '_' | tr -cd '[:alnum:]_-')
|
||||||
|
# Truncate to max 50 chars
|
||||||
|
echo "${name:0:50}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Convert and copy files
|
||||||
|
for f in "${FILES[@]}"; do
|
||||||
|
if [ ! -f "$f" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine the next prefix
|
||||||
|
existing_prefixes=$(ls "$MOUNT_POINT" | grep -E '^[0-9].*\.mp3$' | sed -E 's/^([0-9]).*/\1/' | sort -n | uniq)
|
||||||
|
for i in {0..9}; do
|
||||||
|
if ! echo "$existing_prefixes" | grep -q "^$i$"; then
|
||||||
|
PREFIX=$i
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Using prefix: $PREFIX"
|
||||||
|
|
||||||
|
BASENAME=$(sanitize_filename "$f")
|
||||||
|
OUT_PATTERN="$MOUNT_POINT/${PREFIX}%02d_${BASENAME}.mp3"
|
||||||
|
|
||||||
|
echo "Converting '$f' to '$OUT_PATTERN' at speed $SPEED..."
|
||||||
|
|
||||||
|
ffmpeg -i "$f" \
|
||||||
|
-filter:a "atempo=$SPEED" -ar 44100 -ac 2 -c:a libmp3lame -b:a 128k \
|
||||||
|
-f segment -segment_time 300 \
|
||||||
|
"$OUT_PATTERN"
|
||||||
|
|
||||||
|
# Update prefix for next file
|
||||||
|
# Count how many segments were created
|
||||||
|
SEG_COUNT=$(ls "$MOUNT_POINT" | grep -E "^${PREFIX}[0-9]{2}_" | wc -l)
|
||||||
|
PREFIX=$((PREFIX + SEG_COUNT))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All files processed successfully."
|
||||||
@@ -4,6 +4,12 @@
|
|||||||
pkgs.zeroad
|
pkgs.zeroad
|
||||||
pkgs.mari0
|
pkgs.mari0
|
||||||
pkgs.luanti # fka minetest
|
pkgs.luanti # fka minetest
|
||||||
|
# pkgs.openarena
|
||||||
|
# pkgs.teeworlds
|
||||||
|
pkgs.nethack
|
||||||
|
# pkgs.freeciv
|
||||||
|
# pkgs.lincity-ng
|
||||||
|
# pkgs.superTuxKart
|
||||||
];
|
];
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
# for 0ad multiplayer
|
# for 0ad multiplayer
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{services.redshift.enable = false;}
|
{ services.redshift.enable = true; }
|
||||||
|
|||||||
@@ -6,15 +6,6 @@
|
|||||||
promptColours.success = "cyan";
|
promptColours.success = "cyan";
|
||||||
promptColours.failure = "red";
|
promptColours.failure = "red";
|
||||||
in {
|
in {
|
||||||
environment.systemPackages = [pkgs.atuin];
|
|
||||||
environment.variables.ATUIN_CONFIG_DIR = toString (pkgs.writeTextDir "/config.toml" ''
|
|
||||||
auto_sync = true
|
|
||||||
update_check = false
|
|
||||||
sync_address = "http://zaatar.r:8888"
|
|
||||||
sync_frequency = 0
|
|
||||||
style = "compact"
|
|
||||||
'');
|
|
||||||
|
|
||||||
programs.zsh = let
|
programs.zsh = let
|
||||||
zsh-completions = pkgs.fetchFromGitHub {
|
zsh-completions = pkgs.fetchFromGitHub {
|
||||||
owner = "zsh-users";
|
owner = "zsh-users";
|
||||||
@@ -67,13 +58,6 @@ in {
|
|||||||
zstyle ':vcs_info:*' formats "%c%u%F{cyan}%b%f"
|
zstyle ':vcs_info:*' formats "%c%u%F{cyan}%b%f"
|
||||||
zstyle ':vcs_info:*' actionformats "(%a) %c%u%F{cyan}%b%f"
|
zstyle ':vcs_info:*' actionformats "(%a) %c%u%F{cyan}%b%f"
|
||||||
|
|
||||||
# atuin distributed shell history
|
|
||||||
export ATUIN_NOBIND="true" # disable all keybdinings of atuin
|
|
||||||
eval "$(atuin init zsh)"
|
|
||||||
bindkey '^r' _atuin_search_widget # bind ctrl+r to atuin
|
|
||||||
# use zsh only session history
|
|
||||||
fc -p
|
|
||||||
|
|
||||||
precmd () {
|
precmd () {
|
||||||
vcs_info
|
vcs_info
|
||||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] || [ -n "$SSH_CONNECTION" ]; then
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] || [ -n "$SSH_CONNECTION" ]; then
|
||||||
|
|||||||
2
secrets
2
secrets
Submodule secrets updated: 3f3a8d1334...236a3353a7
@@ -16,8 +16,17 @@
|
|||||||
boot.initrd.kernelModules = [];
|
boot.initrd.kernelModules = [];
|
||||||
boot.kernelModules = ["kvm-intel"];
|
boot.kernelModules = ["kvm-intel"];
|
||||||
boot.extraModulePackages = [];
|
boot.extraModulePackages = [];
|
||||||
boot.loader.systemd-boot.enable = true;
|
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot = {
|
||||||
|
loader = {
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
systemd-boot = {
|
||||||
|
enable = true;
|
||||||
|
configurationLimit = 5;
|
||||||
|
consoleMode = "max";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
boot.initrd.luks.devices."luks-aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5".device = "/dev/disk/by-uuid/aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5";
|
boot.initrd.luks.devices."luks-aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5".device = "/dev/disk/by-uuid/aa6beb1b-3e54-4a0e-ac9c-e0c007d73cd5";
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ in {
|
|||||||
./scrabble.nix
|
./scrabble.nix
|
||||||
# ./onlyoffice.nix
|
# ./onlyoffice.nix
|
||||||
./retiolum-map.nix
|
./retiolum-map.nix
|
||||||
./tarot.nix
|
./oracle
|
||||||
./tt-rss.nix
|
./tt-rss.nix
|
||||||
./weechat.nix
|
./weechat.nix
|
||||||
../../configs/monitoring.nix
|
../../configs/monitoring.nix
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
tarotPort = 7407;
|
tarotPort = 7407;
|
||||||
|
ichingPort = 1819;
|
||||||
tarotFiles = pkgs.fetchzip {
|
tarotFiles = pkgs.fetchzip {
|
||||||
url = "https://c.krebsco.de/tarot.zip";
|
url = "https://c.krebsco.de/tarot.zip";
|
||||||
sha256 = "0jl5vdwlj17pqp94yj02xgsb1gyvs9i08m83kac0jdnhfjl2f75a";
|
sha256 = "0jl5vdwlj17pqp94yj02xgsb1gyvs9i08m83kac0jdnhfjl2f75a";
|
||||||
@@ -21,39 +22,30 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
serviceConfig.Type = "simple";
|
serviceConfig.Type = "simple";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
environment = {
|
||||||
|
TAROT_FILES = tarotFiles;
|
||||||
|
TAROT_PORT = toString tarotPort;
|
||||||
|
};
|
||||||
serviceConfig.ExecStart = pkgs.writers.writePython3 "tarot-server" {
|
serviceConfig.ExecStart = pkgs.writers.writePython3 "tarot-server" {
|
||||||
libraries = py: [ py.pillow py.flask ];
|
libraries = py: [
|
||||||
} ''
|
py.pillow
|
||||||
from flask import Flask, send_file
|
py.flask
|
||||||
from pathlib import Path
|
];
|
||||||
from random import choice, randint
|
} ./tarot.py;
|
||||||
from io import BytesIO
|
};
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
systemd.services.iching = {
|
||||||
TAROT_DIR = Path("${tarotFiles}")
|
enable = true;
|
||||||
|
serviceConfig.Type = "simple";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
@app.route("/")
|
environment = {
|
||||||
def tarot():
|
ICHING_PORT = toString ichingPort;
|
||||||
card_path = choice(list(TAROT_DIR.glob("*")))
|
};
|
||||||
|
serviceConfig.ExecStart = pkgs.writers.writePython3 "iching-server" {
|
||||||
with Image.open(card_path) as img:
|
libraries = py: [
|
||||||
if randint(0, 1):
|
py.flask
|
||||||
img = img.rotate(180)
|
];
|
||||||
buf = BytesIO()
|
} ./iching.py;
|
||||||
img.save(buf, format="JPEG")
|
|
||||||
buf.seek(0)
|
|
||||||
return send_file(
|
|
||||||
buf,
|
|
||||||
mimetype='image/jpeg',
|
|
||||||
as_attachment=False
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(port=${toString tarotPort})
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
niveum.passport.services = [
|
niveum.passport.services = [
|
||||||
@@ -62,8 +54,21 @@ in
|
|||||||
title = "Tarot";
|
title = "Tarot";
|
||||||
description = "draws Tarot cards for you. See <a href=\"${link}/files/key.pdf\">here</a> for information on how to interpret them.";
|
description = "draws Tarot cards for you. See <a href=\"${link}/files/key.pdf\">here</a> for information on how to interpret them.";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
link = "https://iching.kmein.de";
|
||||||
|
title = "I Ching";
|
||||||
|
description = "draws I Ching hexagrams for you.";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."iching.kmein.de" = {
|
||||||
|
enableACME = true;
|
||||||
|
forceSSL = true;
|
||||||
|
locations = {
|
||||||
|
"/".proxyPass = "http://127.0.0.1:${toString ichingPort}/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts."tarot.kmein.de" = {
|
services.nginx.virtualHosts."tarot.kmein.de" = {
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
202
systems/makanek/oracle/iching.py
Normal file
202
systems/makanek/oracle/iching.py
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
from flask import Flask
|
||||||
|
import random
|
||||||
|
from typing import List
|
||||||
|
from enum import Enum
|
||||||
|
import os
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
KING_WEN_SEQUENCE: List[int] = [
|
||||||
|
0b111111,
|
||||||
|
0b000000,
|
||||||
|
0b100010,
|
||||||
|
0b010001,
|
||||||
|
0b111010,
|
||||||
|
0b010111,
|
||||||
|
0b010000,
|
||||||
|
0b000010,
|
||||||
|
0b111011,
|
||||||
|
0b110111,
|
||||||
|
0b111000,
|
||||||
|
0b000111,
|
||||||
|
0b101111,
|
||||||
|
0b111101,
|
||||||
|
0b001000,
|
||||||
|
0b000100,
|
||||||
|
0b100110,
|
||||||
|
0b011001,
|
||||||
|
0b110000,
|
||||||
|
0b000011,
|
||||||
|
0b100101,
|
||||||
|
0b101001,
|
||||||
|
0b000001,
|
||||||
|
0b100000,
|
||||||
|
0b100111,
|
||||||
|
0b111001,
|
||||||
|
0b100001,
|
||||||
|
0b011110,
|
||||||
|
0b010010,
|
||||||
|
0b101101,
|
||||||
|
0b001110,
|
||||||
|
0b011100,
|
||||||
|
0b001111,
|
||||||
|
0b111100,
|
||||||
|
0b000101,
|
||||||
|
0b101000,
|
||||||
|
0b101011,
|
||||||
|
0b110101,
|
||||||
|
0b001010,
|
||||||
|
0b010100,
|
||||||
|
0b110001,
|
||||||
|
0b100011,
|
||||||
|
0b111110,
|
||||||
|
0b011111,
|
||||||
|
0b000110,
|
||||||
|
0b011000,
|
||||||
|
0b010110,
|
||||||
|
0b011010,
|
||||||
|
0b101110,
|
||||||
|
0b011101,
|
||||||
|
0b100100,
|
||||||
|
0b001001,
|
||||||
|
0b001011,
|
||||||
|
0b110100,
|
||||||
|
0b101100,
|
||||||
|
0b001101,
|
||||||
|
0b011011,
|
||||||
|
0b110110,
|
||||||
|
0b010011,
|
||||||
|
0b110010,
|
||||||
|
0b110011,
|
||||||
|
0b001100,
|
||||||
|
0b101010,
|
||||||
|
0b010101,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class Line(Enum):
|
||||||
|
"""
|
||||||
|
Represents a line in an I Ching hexagram.
|
||||||
|
Each line can be one of the following:
|
||||||
|
- 6: Old Yin (changing yin)
|
||||||
|
- 7: Young Yang (static yang)
|
||||||
|
- 8: Young Yin (static yin)
|
||||||
|
- 9: Old Yang (changing yang)
|
||||||
|
"""
|
||||||
|
|
||||||
|
OLD_YIN = 6 # changing yin
|
||||||
|
YOUNG_YANG = 7 # static yang
|
||||||
|
YOUNG_YIN = 8 # static yin
|
||||||
|
OLD_YANG = 9 # changing yang
|
||||||
|
|
||||||
|
def is_changing(self) -> bool:
|
||||||
|
"""Returns True if the line is changing (old)."""
|
||||||
|
return self in [Line.OLD_YIN, Line.OLD_YANG]
|
||||||
|
|
||||||
|
def symbol(self) -> str:
|
||||||
|
"""Returns the textual representation of the line."""
|
||||||
|
symbols = {
|
||||||
|
Line.YOUNG_YANG: "───────",
|
||||||
|
Line.YOUNG_YIN: "─── ───",
|
||||||
|
Line.OLD_YANG: "───o───",
|
||||||
|
Line.OLD_YIN: "───x───",
|
||||||
|
}
|
||||||
|
return symbols[self]
|
||||||
|
|
||||||
|
def binary_value(self) -> int:
|
||||||
|
"""Returns the binary value of the line (1 for yang, 0 for yin)."""
|
||||||
|
return 1 if self in [Line.YOUNG_YANG, Line.OLD_YANG] else 0
|
||||||
|
|
||||||
|
|
||||||
|
class Hexagram:
|
||||||
|
"""
|
||||||
|
Represents an I Ching hexagram.
|
||||||
|
Each hexagram consists of six lines.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, lines: List[Line] | None = None) -> None:
|
||||||
|
"""
|
||||||
|
Initializes a Hexagram.
|
||||||
|
If lines are not provided, generates a random hexagram.
|
||||||
|
:param lines: List of six integers = the lines of the hexagram.
|
||||||
|
"""
|
||||||
|
if lines is None:
|
||||||
|
self.lines = random.choices(
|
||||||
|
[Line.OLD_YIN, Line.YOUNG_YANG, Line.YOUNG_YIN, Line.OLD_YANG],
|
||||||
|
weights=[1, 5, 7, 3],
|
||||||
|
k=6,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.lines = lines
|
||||||
|
|
||||||
|
def print(self) -> str:
|
||||||
|
"""Prints the hexagram details."""
|
||||||
|
return "\n".join(
|
||||||
|
[
|
||||||
|
"HEXAGRAM {} {}".format(
|
||||||
|
self.king_wen_number(), self.unicode_representation()
|
||||||
|
),
|
||||||
|
"Binary: {:06b}".format(self.binary_representation()),
|
||||||
|
"Lines (bottom → top): {}".format(
|
||||||
|
" ".join(str(line.value) for line in self.lines)
|
||||||
|
),
|
||||||
|
self.render_text(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def render_text(self) -> str:
|
||||||
|
"""Renders the hexagram in a textual box format."""
|
||||||
|
lines = []
|
||||||
|
lines.append("┌─────────┐")
|
||||||
|
for line in reversed(self.lines):
|
||||||
|
body = line.symbol()
|
||||||
|
lines.append(f"│ {body} │")
|
||||||
|
lines.append("└─────────┘")
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
def binary_representation(self) -> int:
|
||||||
|
"""Returns the binary representation of the hexagram."""
|
||||||
|
return sum(
|
||||||
|
val << i
|
||||||
|
for i, val in enumerate(
|
||||||
|
line.binary_value() for line in reversed(self.lines)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def king_wen_number(self) -> int:
|
||||||
|
"""Returns the King Wen number of the hexagram."""
|
||||||
|
return KING_WEN_SEQUENCE.index(self.binary_representation()) + 1
|
||||||
|
|
||||||
|
def unicode_representation(self) -> str:
|
||||||
|
"""Returns the Unicode character representing the hexagram."""
|
||||||
|
return chr(0x4DC0 + self.king_wen_number() - 1)
|
||||||
|
|
||||||
|
def changing_hexagram(self):
|
||||||
|
"""Returns the changing hexagram
|
||||||
|
if there are changing lines, else None."""
|
||||||
|
if any(line.is_changing() for line in self.lines):
|
||||||
|
new_lines = [
|
||||||
|
(
|
||||||
|
Line.YOUNG_YIN
|
||||||
|
if line == Line.OLD_YANG
|
||||||
|
else Line.YOUNG_YANG if line == Line.OLD_YIN else line
|
||||||
|
)
|
||||||
|
for line in self.lines
|
||||||
|
]
|
||||||
|
return Hexagram(new_lines)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def main():
|
||||||
|
result = ""
|
||||||
|
hexagram = Hexagram()
|
||||||
|
result += hexagram.print()
|
||||||
|
if changing_hex := hexagram.changing_hexagram():
|
||||||
|
result += "\n"
|
||||||
|
result += changing_hex.print()
|
||||||
|
return f"<pre>{result}</pre>"
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(port=int(os.environ["ICHING_PORT"]))
|
||||||
26
systems/makanek/oracle/tarot.py
Normal file
26
systems/makanek/oracle/tarot.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from flask import Flask, send_file
|
||||||
|
from pathlib import Path
|
||||||
|
from random import choice, randint
|
||||||
|
from io import BytesIO
|
||||||
|
from PIL import Image
|
||||||
|
import os
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
TAROT_DIR = Path(os.environ["TAROT_FILES"])
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def tarot():
|
||||||
|
card_path = choice(list(TAROT_DIR.glob("*")))
|
||||||
|
|
||||||
|
with Image.open(card_path) as img:
|
||||||
|
if randint(0, 1):
|
||||||
|
img = img.rotate(180)
|
||||||
|
buf = BytesIO()
|
||||||
|
img.save(buf, format="JPEG")
|
||||||
|
buf.seek(0)
|
||||||
|
return send_file(buf, mimetype="image/jpeg", as_attachment=False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(port=int(os.environ["TAROT_PORT"]))
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{pkgs, ...}: {
|
|
||||||
services.postgresqlBackup = {
|
|
||||||
enable = true;
|
|
||||||
databases = ["atuin"];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.postgresql.package = pkgs.postgresql_14;
|
|
||||||
|
|
||||||
services.atuin = {
|
|
||||||
host = "0.0.0.0";
|
|
||||||
openFirewall = true;
|
|
||||||
openRegistration = true;
|
|
||||||
port = 8888;
|
|
||||||
enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -7,11 +7,9 @@
|
|||||||
inherit (import ../../lib) retiolumAddresses restic;
|
inherit (import ../../lib) retiolumAddresses restic;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./atuin.nix
|
|
||||||
./backup.nix
|
./backup.nix
|
||||||
./gaslight.nix
|
./gaslight.nix
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./nas.nix
|
|
||||||
../../configs/mycelium.nix
|
../../configs/mycelium.nix
|
||||||
./home-assistant.nix
|
./home-assistant.nix
|
||||||
../../configs/monitoring.nix
|
../../configs/monitoring.nix
|
||||||
@@ -66,11 +64,9 @@ in {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.logind = {
|
services.logind.settings.Login.HandleLidSwitchDocked = "ignore";
|
||||||
lidSwitch = "ignore";
|
services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore";
|
||||||
lidSwitchDocked = "ignore";
|
services.logind.settings.Login.HandleLidSwitch = "ignore";
|
||||||
lidSwitchExternalPower = "ignore";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.illum.enable = true;
|
services.illum.enable = true;
|
||||||
|
|
||||||
@@ -88,9 +84,6 @@ in {
|
|||||||
pkgs.python3 # for sshuttle
|
pkgs.python3 # for sshuttle
|
||||||
];
|
];
|
||||||
|
|
||||||
# since 22.05 timeout fails?
|
|
||||||
# systemd.services.systemd-networkd-wait-online.enable = false;
|
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "zaatar";
|
hostName = "zaatar";
|
||||||
wireless.interfaces = ["wlp2s0"];
|
wireless.interfaces = ["wlp2s0"];
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
{ config, ... }:
|
|
||||||
{
|
|
||||||
users.extraUsers.nas = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = "nas";
|
|
||||||
uid = 7451;
|
|
||||||
};
|
|
||||||
users.extraGroups.nas = {
|
|
||||||
gid = 7452;
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/media/sd" = {
|
|
||||||
device = "/dev/disk/by-id/5E4S5_0x4c585d15-part1";
|
|
||||||
fsType = "ext4";
|
|
||||||
options = [
|
|
||||||
"nofail"
|
|
||||||
"defaults"
|
|
||||||
"uid=${toString config.users.extraUsers.nas.uid}"
|
|
||||||
"gid=${toString config.users.extraGroups.nas.gid}"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/media/hdd" = {
|
|
||||||
device = "/dev/disk/by-id/0x50014ee658872039-part1";
|
|
||||||
fsType = "ntfs";
|
|
||||||
options = [ # ref https://askubuntu.com/a/113746
|
|
||||||
"nofail"
|
|
||||||
"defaults"
|
|
||||||
"nls=utf8"
|
|
||||||
"umask=000"
|
|
||||||
"dmask=027"
|
|
||||||
"fmask=137"
|
|
||||||
"uid=${toString config.users.extraUsers.nas.uid}"
|
|
||||||
"gid=${toString config.users.extraGroups.nas.gid}"
|
|
||||||
"windows_names"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# ref https://dataswamp.org/~solene/2020-10-18-nixos-nas.html
|
|
||||||
# ref https://www.reddit.com/r/NixOS/comments/relwsh/comment/hoapgrr/
|
|
||||||
services.samba = {
|
|
||||||
enable = true;
|
|
||||||
securityType = "user";
|
|
||||||
openFirewall = true;
|
|
||||||
settings = {
|
|
||||||
global = {
|
|
||||||
"guest account" = "nobody";
|
|
||||||
"hosts allow" = ["192.168.178." "127.0.0.1" "localhost"];
|
|
||||||
"hosts deny" = ["0.0.0.0/0"];
|
|
||||||
"map to guest" = "Bad User";
|
|
||||||
"netbios name" = "zaatar";
|
|
||||||
"security" = "user";
|
|
||||||
"server role" = "standalone server";
|
|
||||||
"server string" = "zaatar";
|
|
||||||
"workgroup" = "WORKGROUP";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
shares.nas = {
|
|
||||||
path = "/media";
|
|
||||||
browseable = "yes";
|
|
||||||
writable = "yes";
|
|
||||||
# "read only" = "no";
|
|
||||||
"guest ok" = "yes";
|
|
||||||
"create mask" = "0644";
|
|
||||||
"directory mask" = "0755";
|
|
||||||
"force user" = config.users.extraUsers.nas.name;
|
|
||||||
"force group" = config.users.extraUsers.nas.group;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.samba-wsdd = {
|
|
||||||
enable = true;
|
|
||||||
openFirewall = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.firewall.enable = true;
|
|
||||||
networking.firewall.allowPing = true;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user