Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ jobs:
name: Twitch.Drops.Miner.Linux.AppImage-${{matrix.arch}}
path: Twitch.Drops.Miner.Linux.AppImage-${{matrix.arch}}.zip

linux-nix:
name: Linux (Nix)
runs-on: ubuntu-latest
needs:
- validate

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v27

- name: Build Nix flake
run: nix build -L

update_releases_page:
name: Upload builds to Releases
if: github.event_name != 'pull_request'
Expand All @@ -309,6 +325,7 @@ jobs:
- linux-pyinstaller
- linux-appimage
- macos
- linux-nix
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ Every several seconds, the application pretends to watch a particular stream by
### Usage:

- Download and unzip [the latest release](https://github.com/DevilXD/TwitchDropsMiner/releases) - it's recommended to keep it in the folder it comes in.
- **Nix Users**: You can run the application directly from the flake using `nix run github:DevilXD/TwitchDropsMiner`, or add it to your NixOS/Home Manager configuration:
<details>
<summary>Example Flake configuration</summary>

```nix
# flake.nix
inputs.TwitchDropsMiner = {
url = "github:DevilXD/TwitchDropsMiner";
inputs.nixpkgs.follows = "nixpkgs";
};

# configuration.nix / home.nix
environment.systemPackages = [ # or home.packages
inputs.TwitchDropsMiner.packages.${pkgs.stdenv.hostPlatform.system}.twitch-drops-miner
];
```

</details>
- Run it and login/connect the miner to your Twitch account by using the in-app login form.
- After a successful login, the app should fetch a list of all available campaigns and games you can mine drops for - you can then select and add games of choice to the Priority List available on the Settings tab, and then press on the `Reload` button to start processing. It will fetch a list of all applicable streams it can watch, and start mining right away. You can also manually switch to a different channel as needed.
- If you wish to keep the miner occupied with mining anything it can, beyond what you've selected via the Priority List, you can use the Priority Mode setting to specify the mining order for the rest of the games.
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
description = "An app that allows you to AFK mine Twitch drops, without having to worry about switching channels or claiming drops";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
{ self, nixpkgs }:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = system: nixpkgs.legacyPackages.${system};
in
{
packages = forAllSystems (system: {
default = (pkgsFor system).callPackage ./nix/package.nix { };
twitch-drops-miner = (pkgsFor system).callPackage ./nix/package.nix { };
});

apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/twitch-drops-miner";
};
twitch-drops-miner = {
type = "app";
program = "${self.packages.${system}.twitch-drops-miner}/bin/twitch-drops-miner";
};
});

devShells = forAllSystems (
system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.default ];

packages = with pkgs; [
python3Packages.pytest
python3Packages.black
];
};
}
);
};
}
107 changes: 107 additions & 0 deletions nix/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
lib,
python3Packages,
wrapGAppsHook3,
gobject-introspection,
gtk3,
libnotify,
copyDesktopItems,
makeDesktopItem,
}:

python3Packages.buildPythonApplication rec {
pname = "twitch-drops-miner";
version = "15-dev";

# Use the local repository as the source
src = ../.;

format = "other";

nativeBuildInputs = [
wrapGAppsHook3
gobject-introspection
copyDesktopItems
];

buildInputs = [
gtk3
libnotify
];

propagatedBuildInputs = with python3Packages; [
aiohttp
pillow
pystray
pygobject3
truststore
tkinter
];

dontWrapGApps = true;

# Patch the immutable path behavior for Linux
postPatch = ''
substituteInPlace constants.py \
--replace-fail 'IS_PACKAGED = hasattr(sys, "_MEIPASS") or IS_APPIMAGE' 'IS_PACKAGED = True' \
--replace-fail 'WORKING_DIR = SELF_PATH.parent' 'import os; WORKING_DIR = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"), "twitch-drops-miner"); WORKING_DIR.mkdir(parents=True, exist_ok=True)'
substituteInPlace utils.py \
--replace-fail 'if IS_PACKAGED and sys.platform == "linux":' 'if False:'
'';

desktopItems = [
(makeDesktopItem {
name = "twitch-drops-miner";
exec = "twitch-drops-miner";
icon = "twitch-drops-miner";
desktopName = "Twitch Drops Miner";
comment = "An app that allows you to AFK mine Twitch drops";
categories = [
"Utility"
"Network"
"Game"
];
})
];

installPhase = ''
runHook preInstall

mkdir -p $out/share/twitch-drops-miner
cp -r * $out/share/twitch-drops-miner/

# Install icon
install -Dm644 appimage/pickaxe.png $out/share/icons/hicolor/256x256/apps/twitch-drops-miner.png

# Create the executable wrapper
mkdir -p $out/bin
cat > $out/bin/twitch-drops-miner <<EOF
#!${python3Packages.python.interpreter}
import sys
import runpy

# Add the share directory to the path so it can find its modules
sys.path.insert(0, "$out/share/twitch-drops-miner")
sys._MEIPASS = "$out/share/twitch-drops-miner"

if __name__ == "__main__":
runpy.run_path("$out/share/twitch-drops-miner/main.py", run_name="__main__")
EOF
chmod +x $out/bin/twitch-drops-miner

runHook postInstall
'';

preFixup = ''
makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
'';

meta = with lib; {
description = "An app that allows you to AFK mine Twitch drops, without having to worry about switching channels or claiming drops";
homepage = "https://github.com/DevilXD/TwitchDropsMiner";
license = licenses.gpl3Only;
maintainers = [ ];
mainProgram = "twitch-drops-miner";
platforms = platforms.linux;
};
}