From dccfe0db58c9a53fb17a0065fae4020c7919859e Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Fri, 22 Sep 2023 19:39:18 +0200 Subject: [PATCH] move stuff to legacy --- nixos/legacy/dms.nix | 98 ++++++++++++++++++++++++++++++++++++++++++ nixos/legacy/grocy.nix | 24 +++++++++++ nixos/legacy/mpd.nix | 78 +++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 nixos/legacy/dms.nix create mode 100644 nixos/legacy/grocy.nix create mode 100644 nixos/legacy/mpd.nix diff --git a/nixos/legacy/dms.nix b/nixos/legacy/dms.nix new file mode 100644 index 0000000..7dbb073 --- /dev/null +++ b/nixos/legacy/dms.nix @@ -0,0 +1,98 @@ +{ lib, pkgs, config, ... }: + +# a very simple dms setup which. +# I have a brother ADS-1600W scanner, which is configured to send all +# PDFs to this machine in /home/ftp-upload/input +# from there the dms.py scans them and makes them searchable. + +let + dms = pkgs.fetchgit { + url = "https://github.com/mrVanDalo/dms.git"; + rev = "2f5c44f017bdfd8abfe908d419ef26bac300f809"; + sha256 = "0dxhk1ah6wwbsxyk4hd32rz7886w7r5gfy16485gjbvky1qsi8gd"; + }; +in +{ + + # setup ftp + services.vsftpd = { + enable = true; + userlist = [ "ftp-upload" ]; + userlistEnable = true; + localUsers = true; + writeEnable = true; + extraConfig = '' + # additional ports for directory list and stuff + pasv_min_port=4242 + pasv_max_port=4243 + ''; + }; + networking.firewall.allowedTCPPortRanges = [ + { + # ftp: additional ports for directory list and stuff + from = 4242; + to = 4243; + } + { + # ftp + from = 20; + to = 21; + } + ]; + + sops.secrets.ftp_password = { }; + + # create user + users.users.ftp-upload = { + passwordFile = config.sops.secrets.ftp_password.path; + isNormalUser = true; + }; + + # create dms service + systemd.services.dms = { + enable = true; + wantedBy = [ "multi-user.target" ]; + path = [ + (pkgs.python3.withPackages (ps: with ps; [ flask ])) + pkgs.imagemagickBig + (pkgs.pdfsandwich.override { imagemagick = pkgs.imagemagickBig; }) + pkgs.poppler_utils + pkgs.which + pkgs.netpbm + pkgs.gawk + pkgs.bash + ]; + serviceConfig = { User = "ftp-upload"; }; + preStart = '' + if [[ ! -L /home/ftp-upload/db/SOURCE_DIR ]] + then + rm -rf /home/ftp-upload/db/SOURCE_DIR + mkdir -p /home/ftp-upload/db + mkdir -p /home/ftp-upload/input + ln -s /home/ftp-upload/input /home/ftp-upload/db/SOURCE_DIR + fi + ''; + script = '' + DMSDATA=/home/ftp-upload/db \ + FLASK_APP=${dms}/dms.py \ + flask run --host 0.0.0.0 \ + "$@" + ''; + }; + + # host nginx setup + services.nginx = { + enable = true; + virtualHosts = { + "dms.pepe.private" = { + serverAliases = + [ "pdf.pepe.private" "docs.pepe.private" "dms.pepe.lan" ]; + locations."/" = { proxyPass = "http://localhost:5000"; }; + }; + }; + }; + + # add documents to backup + backup.dirs = [ "/home/ftp-upload/db" ]; + +} diff --git a/nixos/legacy/grocy.nix b/nixos/legacy/grocy.nix new file mode 100644 index 0000000..df197bb --- /dev/null +++ b/nixos/legacy/grocy.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, ... }: + +{ + #services.grocy = { + # enable = true; + # settings = { + # culture = "de"; + # currency = "EUR"; + # }; + # hostName = "grocy.pepe.private"; + # nginx.enableSSL = false; + #}; + #backup.dirs = [ config.services.grocy.dataDir ]; + + services.grocy-scanner = { + enable = true; + host = "https://grocy.ingolf-wagner.de"; + device = "/dev/input/by-id/usb-Belon.cn_2.4G_Wireless_Device_Belon_Smart-event-kbd"; + apiKeyFile = config.sops.secrets.grocyApiKey.path; + }; + + sops.secrets.grocyApiKey = { }; + +} diff --git a/nixos/legacy/mpd.nix b/nixos/legacy/mpd.nix new file mode 100644 index 0000000..ff9622d --- /dev/null +++ b/nixos/legacy/mpd.nix @@ -0,0 +1,78 @@ +{ config, lib, pkgs, ... }: +{ + services.mpd = { + enable = true; + network.listenAddress = "any"; + musicDirectory = "/media/syncthing/music-library"; + playlistDirectory = "/media/syncthing/music-library/playlists"; + }; + + users.groups."syncthing".members = [ "mpd" ]; + + sound.enable = true; + + networking.firewall.allowedTCPPorts = [ + 6680 # mopidy + 6600 # mpd + 1234 # zeroconf + ]; + + users.users."spotifyd" = { + isSystemUser = true; + group = "spotifyd"; + }; + users.groups.spotifyd = { }; + + sops.secrets.spotify_pass.owner = "spotifyd"; + sops.secrets.spotify_user.owner = "spotifyd"; + + services.spotifyd.enable = true; + services.spotifyd.settings = { + global = { + + username_cmd = "cat ${config.sops.secrets.spotify_user.path}"; + password_cmd = "cat ${config.sops.secrets.spotify_pass.path}"; + backend = "alsa"; # use portaudio for macOS [homebrew] + + # The alsa mixer used by `spotifyd`. + mixer = "PCM"; + + # A script that gets evaluated in the user's shell when the song changes [aliases: onevent] + on-song-change-hook = "${pkgs.mpc_cli}/bin/mpc --host localhost --port 6600 stop"; + + # The volume controller. Each one behaves different to + # volume increases. For possible values, run + # `spotifyd --help`. + volume_controller = "alsa"; + + # The name that gets displayed under the connect tab on + # official clients. Spaces are not allowed! + device_name = "DJane"; + + # The audio bitrate. 96, 160 or 320 kbit/s + bitrate = 320; + + # If set to true, audio data does NOT get cached. + no_audio_cache = true; + + # Volume on startup between 0 and 100 + # NOTE: This variable's type will change in v0.4, to a number (instead of string) + initial_volume = "90"; + + # If set to true, enables volume normalisation between songs. + volume_normalisation = false; + + # The normalisation pregain that is applied for each song. + # normalisation_pregain = -10 + + # The port `spotifyd` uses to announce its service over the network. + zeroconf_port = 1234; + + # The displayed device type in Spotify clients. + # Can be unknown, computer, tablet, smartphone, speaker, t_v, + # a_v_r (Audio/Video Receiver), s_t_b (Set-Top Box), and audio_dongle. + device_type = "computer"; + + }; + }; +}