add treefmt and format everything

feature/nixinite
Ingolf Wagner 2023-04-26 09:23:56 +02:00
parent b2054c4b33
commit ff9ac63676
Signed by: palo
GPG Key ID: 76BF5F1928B9618B
9 changed files with 123 additions and 85 deletions

View File

@ -1,3 +1,5 @@
#!/usr/bin/env bash
set -e
defaultDevice=PCH
@ -39,8 +41,7 @@ start_jack(){
#
# to find configuration options do
# jack_control dp
if [[ $device_number -eq -1 ]]
then
if [[ $device_number -eq -1 ]]; then
# we use alsa in reality, but pulse opens up all the pulse
# sink and source stuff
# jack_control ds pulse # not working for some reason
@ -48,21 +49,19 @@ start_jack(){
jack_control dps device hw:$defaultDevice
else
jack_control ds alsa
jack_control dps device hw:$device_number # use usb card
jack_control dps device "hw:$device_number" # use usb card
fi
jack_control dps duplex True # record and playback ports
jack_control dps hwmon False # no hardware monitoring
jack_control dps rate 48000 # use cd sample rate
# nperiods are the splitup of the
# sound-ring-buffer. 2 are ok for internal cards
# but for usb you should use 3 because
# you can have to write in junks to the card
# so there is one backup slice in the middle
if [[ $internal_device_number -ne -1 ]]
then
if [[ $internal_device_number -ne -1 ]]; then
jack_control dps nperiods 3
fi
@ -92,14 +91,18 @@ status_jack() {
jack_control status
}
case $1 in
start) start_jack
start)
start_jack
;;
stop) stop_jack
stop)
stop_jack
;;
restart) stop_jack ; start_jack
restart)
stop_jack
start_jack
;;
*) status_jack
*)
status_jack
;;
esac

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash
function stop_program() {
echo "stop $1"
sudo systemctl stop $1
sudo systemctl stop "$1"
}
function start_program() {
echo "start $1"
sudo systemctl stop $1
sudo systemctl stop "$1"
}
function start() {
echo "starting programs again"
echo "-----------------------"
@ -34,17 +34,15 @@ function stop(){
stop_program tor.service
}
# ----
# main
# ----
stop
echo
echo -n "wait to start again -> "
read
read -r
echo
start

View File

@ -26,8 +26,9 @@ def main():
config_path = nginx_config()
with TemporaryDirectory() as temp_dir:
temp_path = os.path.join(temp_dir, "nginx.conf")
with open(temp_path, "wb+") as temp_file, \
open(config_path, "rb") as config_file:
with open(temp_path, "wb+") as temp_file, open(
config_path, "rb"
) as config_file:
shutil.copyfileobj(config_file, temp_file)
temp_file.flush()
subprocess.check_call(["nginxfmt", temp_file.name])

View File

@ -26,7 +26,10 @@ class GitLogger:
"author_email": commit.author.email,
"author_name": commit.author.name,
"authored_date": commit.authored_datetime.isoformat(),
"files": [{"file":file,"changes":changes} for file,changes in commit.stats.files.items()],
"files": [
{"file": file, "changes": changes}
for file, changes in commit.stats.files.items()
],
"committed_date": commit.committed_datetime.isoformat(),
"committer_email": commit.committer.email,
"committer_name": commit.committer.name,
@ -40,8 +43,9 @@ class GitLogger:
"parents": [parent.hexsha for parent in commit.parents],
}
@click.command()
@click.argument("path", type=click.Path(exists=True), envvar='PWD')
@click.argument("path", type=click.Path(exists=True), envvar="PWD")
@click.option("--host")
@click.option("--index")
@click.option("--port", default=9200)
@ -52,17 +56,10 @@ def main(path, host, index, port):
exit(1)
print("Sending commits from %s to %s on index %s" % (path, host, index))
es = Elasticsearch([
{'host': host, 'port': port}
])
es = Elasticsearch([{"host": host, "port": port}])
for entry in GitLogger(path).log():
try:
es.index(
index=index,
doc_type="commit",
id=entry["hash"],
body=entry
)
es.index(index=index, doc_type="commit", id=entry["hash"], body=entry)
except Exception as e:
print(json.dumps(entry))
print(e.info)
@ -71,5 +68,6 @@ def main(path, host, index, port):
for entry in GitLogger(path).log():
print(json.dumps(entry))
if __name__ == '__main__':
if __name__ == "__main__":
main()

View File

@ -1,5 +1,6 @@
from git import Repo
import os
repo = Repo("/home/palo/dev/nixpkgs")
a = repo.head.log()[0]
current_hash = a.newhexsha
@ -7,7 +8,14 @@ commit = repo.commit(current_hash)
commit.author
commit.committed_date
import json
json.dumps( { "commit_name" : commit.author.name, "message" : commit.message , "changes": commit.stats.files } )
json.dumps(
{
"commit_name": commit.author.name,
"message": commit.message,
"changes": commit.stats.files,
}
)
commit.committed_date
commit.committer.email
commit.parents

View File

@ -93,6 +93,11 @@ in
memoryUsage
treefmt
shellcheck
shfmt
black
#gitlog2json
pciutils

View File

@ -8,7 +8,7 @@
{
flakeIgnore = [ "E265" "E225" "W292" ];
}
(lib.fileContents ../../assets/nginx-show-config.sh);
(lib.fileContents ../../assets/nginx-show-config.py);
in
[
pkgs.mosh

View File

@ -368,7 +368,7 @@ ssh-keygen -t ed25519 -N "" -f /mnt/etc/secrets/initrd/ssh_host_ed25519_key
# Install NixOS
#PATH="$PATH" NIX_PATH="$NIX_PATH" `which nixos-install` --no-root-passwd --root /mnt --max-jobs 40
PATH="$PATH" `which nixos-install` --no-root-passwd --root /mnt --max-jobs 40
PATH="$PATH" $( which nixos-install` --no-root-passwd --root /mnt --max-jobs 40 )
umount /mnt/boot-{1,2}
umount /mnt

25
treefmt.toml Normal file
View File

@ -0,0 +1,25 @@
# One CLI to format the code tree - https://github.com/numtide/treefmt
[formatter.nix]
command = "nixpkgs-fmt"
includes = [ "*.nix"]
[formatter.shell]
command = "shfmt"
options = [
"-i",
"2", # indent 2
"-s", # simplify the code
"-w", # write back to the file
]
includes = ["*.sh"]
excludes = ["./scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
[formatter.shellcheck]
command = "shellcheck"
includes = ["*.sh"]
excludes = ["./scripts/hetzner-dedicated-wipe-and-install-nixos.sh"]
[formatter.python]
command = "black"
includes = ["*.py"]