Skip to content

Commit e6ba9b2

Browse files
committed
[toru] add a shell.nix file
1 parent 8333891 commit e6ba9b2

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

cmd/toru/stream.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package main
22

33
import (
44
"fmt"
5-
// "time"
5+
"time"
66

7-
// "github.com/dustin/go-humanize"
7+
"github.com/dustin/go-humanize"
88
"github.com/sweetbbak/toru/pkg/libtorrent"
99
"github.com/sweetbbak/toru/pkg/player"
1010
"github.com/sweetbbak/toru/pkg/search"
@@ -20,18 +20,18 @@ func StreamTorrent(torfile string, cl *libtorrent.Client) (string, error) {
2020
link := cl.ServeTorrent(t)
2121

2222
// consider deleting this as it sometimes conflicts with the fzf user interface
23-
// go func() {
24-
// for !t.Complete.Bool() {
25-
// c := t.BytesCompleted()
26-
// total := t.Length()
27-
// s := humanize.Bytes(uint64(c))
28-
// x := humanize.Bytes(uint64(total))
29-
// numpeers := len(t.PeerConns())
30-
// fmt.Printf("\x1b[2K\rDownloaded (%v/%v) from [%v] Peers...\n", s, x, numpeers)
31-
// time.Sleep(time.Millisecond * 500)
32-
// }
33-
// println("Complete")
34-
// }()
23+
go func() {
24+
for !t.Complete.Bool() {
25+
c := t.BytesCompleted()
26+
total := t.Length()
27+
s := humanize.Bytes(uint64(c))
28+
x := humanize.Bytes(uint64(total))
29+
numpeers := len(t.PeerConns())
30+
fmt.Printf("\x1b[2K\rDownloaded (%v/%v) from [%v] Peers...", s, x, numpeers)
31+
time.Sleep(time.Millisecond * 500)
32+
}
33+
println("Complete")
34+
}()
3535

3636
fmt.Println(link)
3737
return link, nil

shell.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
let
2+
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11";
3+
pkgs = import nixpkgs { config = {}; overlays = []; };
4+
in
5+
6+
pkgs.mkShellNoCC {
7+
packages = with pkgs; [
8+
eza
9+
helix
10+
go_1_21
11+
];
12+
13+
nativeBuildInputs = with pkgs; [
14+
just
15+
go-outline
16+
gopls
17+
gopkgs
18+
go-tools
19+
];
20+
# Env
21+
GOARCH = "amd64";
22+
GOOS = "linux";
23+
}

0 commit comments

Comments
 (0)