# modules/home/dcx.nix — dcx, the Discord chat export wrapper, as a flake # package: `nix run ~/NixDaemon#dcx` anywhere, and on PATH for this user. # # The script is a copy of ~/.local/bin/dcx (modules/home/dcx/dcx.py) with one # change: when ~/.config/dcx/token is a symlink it treats the token as # sops-managed — it reads it, and refuses to write it (`dcx login` points at # sops instead). Elsewhere (`nix run` on another machine) it behaves as before # and saves the token itself, 0600, outside any repo. # # The token is NEVER in this repo or the Nix store in plain text. It lives only # in secrets/dcx/token (sops, age-encrypted, binary), decrypted at login by the # sops-nix user service into $XDG_RUNTIME_DIR and linked at ~/.config/dcx/token, # readable only by daemonsec. dcx hands it to the exporter via $DISCORD_TOKEN, # never argv. To set or change it: # # TMPDIR=/dev/shm sops secrets/dcx/token # replace the placeholder line # nh os switch # # Note: ~/.local/bin is first on PATH, so the toolbox's own dcx wins there # while it exists; it reads the same sops-linked token file. # # The ricefx shimmer library is not packaged; dcx's built-in plain Rose Pine # fallback is used by the flake copy. { self, ... }: { perSystem = { pkgs, ... }: { packages.dcx = pkgs.stdenvNoCC.mkDerivation { pname = "dcx"; version = "1.1.0"; src = ./dcx; nativeBuildInputs = [ pkgs.makeWrapper ]; installPhase = '' install -Dm755 dcx.py $out/libexec/dcx/dcx patchShebangs $out/libexec/dcx/dcx makeWrapper $out/libexec/dcx/dcx $out/bin/dcx \ --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.discordchatexporter-cli ]} ''; buildInputs = [ pkgs.python3 ]; meta = { description = "Discord chat export wrapper around DiscordChatExporter.Cli"; mainProgram = "dcx"; }; }; }; flake.homeModules.dcx = { config, pkgs, ... }: { home.packages = [ self.packages.${pkgs.stdenv.hostPlatform.system}.dcx ]; sops.secrets.dcx-token = { sopsFile = ../../secrets/dcx/token; format = "binary"; path = "${config.xdg.configHome}/dcx/token"; }; } ; }