Compare commits
1 Commits
updated-in
...
updated-in
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3edafb0950 |
6
flake.lock
generated
6
flake.lock
generated
@@ -666,11 +666,11 @@
|
||||
},
|
||||
"nixpkgs_5": {
|
||||
"locked": {
|
||||
"lastModified": 1761114652,
|
||||
"narHash": "sha256-f/QCJM/YhrV/lavyCVz8iU3rlZun6d+dAiC3H+CDle4=",
|
||||
"lastModified": 1757487488,
|
||||
"narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "01f116e4df6a15f4ccdffb1bcd41096869fb385c",
|
||||
"rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
signal-desktop
|
||||
dino
|
||||
fractal
|
||||
tuba
|
||||
flare-signal
|
||||
|
||||
tio
|
||||
xournalpp
|
||||
@@ -25,7 +23,6 @@
|
||||
wireshark
|
||||
tcpdump
|
||||
nmap
|
||||
pkgs."http.server"
|
||||
|
||||
kdePackages.okular
|
||||
chromium-incognito
|
||||
|
||||
@@ -11,28 +11,7 @@ with lib;
|
||||
};
|
||||
users.groups.data-em = {};
|
||||
|
||||
users.users.data-em-mp3 = {
|
||||
group = "data-em-mp3";
|
||||
home = "/data/em-mp3";
|
||||
useDefaultShell = true;
|
||||
isSystemUser = true;
|
||||
};
|
||||
users.groups.data-em-mp3 = {};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /data/em - data-em data-em - -"
|
||||
"d /data/em-mp3 - data-em-mp3 data-em-mp3 - -"
|
||||
];
|
||||
|
||||
systemd.services.convert-flac-dir-to-mp3 = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${lib.getExe pkgs.convert-flac-dir-to-mp3} /data/em /data/em-mp3";
|
||||
StateDirectory = "convert-flac-dir-to-mp3";
|
||||
WorkingDirectory = "/var/lib/convert-flac-dir-to-mp3";
|
||||
User = "data-em-mp3";
|
||||
Group = "data-em-mp3";
|
||||
};
|
||||
startAt = "*-*-* 03:47:00";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,23 +53,17 @@ in {
|
||||
"mixcloud.clerie.de" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
basicAuthFile = config.sops.secrets.mixcloud-htpasswd.path;
|
||||
locations."/" = {
|
||||
alias = "/data/mixcloud/";
|
||||
basicAuthFile = config.sops.secrets.mixcloud-htpasswd.path;
|
||||
extraConfig = ''
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
'';
|
||||
};
|
||||
locations."/api/" = {
|
||||
alias = "/data/mixcloud/";
|
||||
extraConfig = ''
|
||||
autoindex on;
|
||||
autoindex_format json;
|
||||
'';
|
||||
};
|
||||
locations."/media/" = {
|
||||
alias = "/data/media/";
|
||||
basicAuthFile = config.sops.secrets.mixcloud-htpasswd.path;
|
||||
extraConfig = ''
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
python3,
|
||||
makeWrapper,
|
||||
runCommand,
|
||||
writeTextFile,
|
||||
lib,
|
||||
}:
|
||||
|
||||
@@ -10,7 +9,6 @@
|
||||
text,
|
||||
runtimePackages ? ps: [],
|
||||
pythonPackage ? python3,
|
||||
runtimeInputs ? [],
|
||||
meta ? {},
|
||||
passthru ? {},
|
||||
derivationArgs ? {},
|
||||
@@ -20,17 +18,13 @@ let
|
||||
|
||||
pythonWithPackages = pythonPackage.withPackages runtimePackages;
|
||||
|
||||
in runCommand name ({
|
||||
passAsFile = [ "text" ] ++ (derivationArgs.passAsFile or []);
|
||||
|
||||
meta = {
|
||||
mainProgram = name;
|
||||
} // meta // (derivationArgs.meta or {});
|
||||
|
||||
passthru = passthru // (derivationArgs.passthru or {});
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ] ++ (derivationArgs.nativeBuildInputs or []);
|
||||
|
||||
in writeTextFile {
|
||||
inherit
|
||||
name
|
||||
meta
|
||||
passthru
|
||||
derivationArgs
|
||||
;
|
||||
executable = true;
|
||||
destination = "/bin/${name}";
|
||||
allowSubstitutes = true;
|
||||
@@ -40,17 +34,4 @@ in runCommand name ({
|
||||
|
||||
${text}
|
||||
'';
|
||||
} // (
|
||||
builtins.removeAttrs derivationArgs [ "passAsFile" "meta" "passthru" "nativeBuildInputs" ]
|
||||
))
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
|
||||
target=$out/bin/${lib.escapeShellArg name}
|
||||
|
||||
cp "$textPath" "$target"
|
||||
|
||||
chmod +x "$target"
|
||||
|
||||
wrapProgram "$target" --prefix PATH : "${lib.makeBinPath runtimeInputs}"
|
||||
''
|
||||
}
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from progress.bar import Bar
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
def files_and_dirs_for_directory(path):
|
||||
filepaths = []
|
||||
dirpaths = []
|
||||
|
||||
for dirpath, dirnames, filenames in path.walk():
|
||||
dirpaths.append(dirpath)
|
||||
|
||||
for filename in filenames:
|
||||
filepath = dirpath / filename
|
||||
filepaths.append(filepath)
|
||||
|
||||
return set(filepaths), set(dirpaths)
|
||||
|
||||
def make_paths_relative(paths, relative_to_path):
|
||||
return set(path.relative_to(relative_to_path) for path in paths)
|
||||
|
||||
def replace_suffix(path, suffix):
|
||||
return path.with_name(path.stem + suffix)
|
||||
|
||||
def convert_filepath(path):
|
||||
if path.suffix == ".flac":
|
||||
return replace_suffix(path, ".mp3")
|
||||
|
||||
return path
|
||||
|
||||
def ffmpeg_flac_to_mp3(in_path, out_path):
|
||||
print("")
|
||||
subprocess.run(["ffmpeg", "-hide_banner", "-loglevel", "warning", "-stats", "-i", in_path, "-ab", "320k", "-map_metadata", "0", "-id3v2_version", "3", out_path], check=True)
|
||||
print("")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
parser = argparse.ArgumentParser(prog="convert-flac-dir-to-mp3")
|
||||
parser.add_argument("from_dir", type=Path)
|
||||
parser.add_argument("to_dir", type=Path)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
from_path = args.from_dir.absolute()
|
||||
to_path = args.to_dir.absolute()
|
||||
|
||||
if not from_path.exists():
|
||||
raise Exception("from_path does not exist")
|
||||
|
||||
if not to_path.exists():
|
||||
raise Exception("to_path does not exist")
|
||||
|
||||
if not from_path.is_dir():
|
||||
raise Exception("from_path is not a directory")
|
||||
|
||||
if not to_path.is_dir():
|
||||
raise Exception("to_path is not a directory")
|
||||
|
||||
print(f"Converting {from_path} to {to_path}…")
|
||||
|
||||
from_filepaths, from_dirpaths = files_and_dirs_for_directory(from_path)
|
||||
to_filepaths, to_dirpaths = files_and_dirs_for_directory(to_path)
|
||||
|
||||
|
||||
relative_from_filepaths = make_paths_relative(from_filepaths, from_path)
|
||||
relative_to_filepaths = make_paths_relative(to_filepaths, to_path)
|
||||
|
||||
converted_from_filepaths = set(convert_filepath(filepath) for filepath in relative_from_filepaths)
|
||||
|
||||
filepaths_missing_in_to_path = converted_from_filepaths - relative_to_filepaths
|
||||
|
||||
|
||||
relative_from_dirpaths = make_paths_relative(from_dirpaths, from_path)
|
||||
relative_to_dirpaths = make_paths_relative(to_dirpaths, to_path)
|
||||
|
||||
dirpaths_missing_in_to_path = relative_from_dirpaths - relative_to_dirpaths
|
||||
|
||||
print(f"Missing {len(filepaths_missing_in_to_path)} files and {len(dirpaths_missing_in_to_path)} directories")
|
||||
|
||||
if len(dirpaths_missing_in_to_path) > 0:
|
||||
for dirpath in Bar("Creating directories").iter(dirpaths_missing_in_to_path):
|
||||
(to_path / dirpath).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if len(filepaths_missing_in_to_path) > 0:
|
||||
for filepath in Bar("Creating files").iter(filepaths_missing_in_to_path):
|
||||
if filepath in relative_from_filepaths:
|
||||
# Just copy the file
|
||||
shutil.copy(from_path / filepath, to_path / filepath)
|
||||
elif filepath.suffix == ".mp3" and replace_suffix(filepath, ".flac") in relative_from_filepaths:
|
||||
# Convert from flac
|
||||
print("")
|
||||
print(f"Converting {to_path / filepath}…")
|
||||
|
||||
# Tempfile for ffmpeg
|
||||
tmpfilepath = filepath.with_name(".~" + filepath.name)
|
||||
(to_path / tmpfilepath).unlink(missing_ok=True)
|
||||
|
||||
print(f"Using tempfile for ffmpeg {to_path / tmpfilepath}…")
|
||||
|
||||
# Convert
|
||||
ffmpeg_flac_to_mp3(from_path / replace_suffix(filepath, ".flac"), to_path / tmpfilepath)
|
||||
|
||||
# Rename tempfile
|
||||
(to_path / tmpfilepath).rename(to_path / filepath)
|
||||
else:
|
||||
raise Exception("Unable to figure out how to get {to_path / filepath} from {from_path}")
|
||||
@@ -1,8 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.clerie-build-support.writePythonScript {
|
||||
name = "convert-flac-dir-to-mp3";
|
||||
runtimePackages = ps: with ps; [ progress ];
|
||||
runtimeInputs = [ pkgs.ffmpeg-headless ];
|
||||
text = builtins.readFile ./convert-flac-dir-to-mp3.py;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
e2fsprogs,
|
||||
gptfdisk,
|
||||
jq,
|
||||
parted,
|
||||
writeShellApplication,
|
||||
@@ -11,7 +10,6 @@ writeShellApplication {
|
||||
text = builtins.readFile ./grow-last-partition-and-filesystem.sh;
|
||||
runtimeInputs = [
|
||||
e2fsprogs
|
||||
gptfdisk
|
||||
jq
|
||||
parted
|
||||
];
|
||||
|
||||
@@ -11,9 +11,6 @@ fi
|
||||
|
||||
DEVICE="$1"
|
||||
|
||||
echo "Move GTP backup header to end of disk"
|
||||
sgdisk "${DEVICE}" --move-second-header
|
||||
|
||||
PARTITIONDATA="$(parted --script --json --fix "${DEVICE}" print)"
|
||||
PARTNUMBER="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .number')"
|
||||
PARTNAME="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .name')"
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
python3,
|
||||
writeShellApplication,
|
||||
}:
|
||||
|
||||
writeShellApplication {
|
||||
name = "http.server";
|
||||
text = ''
|
||||
python3 -m http.server "$@"
|
||||
'';
|
||||
runtimeInputs = [
|
||||
python3
|
||||
];
|
||||
}
|
||||
@@ -12,7 +12,6 @@ final: prev: {
|
||||
clerie-sops-edit = final.callPackage ./clerie-sops/clerie-sops-edit.nix {};
|
||||
clerie-update-nixfiles = final.callPackage ./clerie-update-nixfiles/clerie-update-nixfiles.nix {};
|
||||
chromium-incognito = final.callPackage ./chromium-incognito {};
|
||||
convert-flac-dir-to-mp3 = final.callPackage ./convert-flac-dir-to-mp3 {};
|
||||
curl-timings = final.callPackage ./curl-timings {};
|
||||
factorio-launcher = final.callPackage ./factorio-launcher {};
|
||||
feeds-dir = final.callPackage ./feeds-dir {};
|
||||
@@ -22,7 +21,6 @@ final: prev: {
|
||||
git-pp = final.callPackage ./git-pp {};
|
||||
git-show-link = final.callPackage ./git-show-link {};
|
||||
grow-last-partition-and-filesystem = final.callPackage ./grow-last-partition-and-filesystem {};
|
||||
"http.server" = final.callPackage ./http.server {};
|
||||
nix-remove-result-links = final.callPackage ./nix-remove-result-links {};
|
||||
nixfiles-auto-install = final.callPackage ./nixfiles/nixfiles-auto-install.nix {};
|
||||
nixfiles-generate-config = final.callPackage ./nixfiles/nixfiles-generate-config.nix {};
|
||||
|
||||
Reference in New Issue
Block a user