Skip to content

Commit

Permalink
build(nix): add home-manager modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Beastwick18 committed Jun 14, 2024
1 parent 6c46d79 commit 7d13559
Show file tree
Hide file tree
Showing 17 changed files with 1,101 additions and 9 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use nix

This comment has been minimized.

Copy link
@amatrelan

amatrelan Jun 14, 2024

Contributor

You can remove this line if you use use flake they do same thing, except use flake is just for flakes, so there is some underlying differences.

This comment has been minimized.

Copy link
@amatrelan

amatrelan Jun 14, 2024

Contributor

I'm not exactly sure but if you use use nix it will load just shell.nix file and when you use use flake it loads flake.nix and then from there it loads devShell environment. In your use case it wont most likely affect anything but you can also specify stuff in flake.nix devShell and then you need to use use flake

use flake
watch_file default.nix
watch_file shell.nix
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ nix run github:Beastwick18/nyaa
Add to `inputs` in `flake.nix`
```nix
nyaa = {
url = "github:Beastwick18/nyaa";
inputs.nixpkgs.follows = "nixpkgs";
url = "github:Beastwick18/nyaa";
inputs.nixpkgs.follows = "nixpkgs";
};
```
Add to `home.nix`
Add to `home.nix` imports and enable
```nix
home.packages = [ inputs.nyaa.packages.x86_64-linux.default ];
imports = [
inputs.nyaa.homeManagerModule
]
programs.nyaa.enable = true;
```

### Windows/Linux Binaries
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{pkgs ? import <nixpkgs> {}}:
{ pkgs ? import <nixpkgs> {} }:
pkgs.rustPlatform.buildRustPackage {
pname = "nyaa";
version =
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
outputs = {
self,
nixpkgs,
}: let
}@inputs: let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = nixpkgs.legacyPackages;
Expand All @@ -18,5 +18,7 @@
devShells = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./shell.nix {};
});

homeManagerModule = import ./modules/home-manager.nix inputs;
};
}
8 changes: 8 additions & 0 deletions modules/clients/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
imports = [
./qBittorrent.nix
./transmission.nix
./rqbit.nix
./other.nix
];
}
53 changes: 53 additions & 0 deletions modules/clients/other.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ lib, ... }:
{
options.programs.nyaa.clients.cmd = {
cmd = lib.mkOption {
type = lib.types.str;
default = ''curl "{torrent}" > ~/{file}'';
description = ''
The command to run on enter
Possible substitutions are:
- `{magnet}`
- `{torrent}`
- `{title}`
- `{file}`
'';
};
shell_cmd = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The shell to spawn the command with (optional)
Example value:
`"bash -c"`
'';
};
};

options.programs.nyaa.clients.default_app = {
use_magnet = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to open magnet links with the default app or torrent links (optional)
'';
};
};

options.programs.nyaa.clients.download = {
save_dir = lib.mkOption {
type = lib.types.str;
default = "~/Downloads";
description = ''
The default path to save .torrent files to
'';
};
filename = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The filename to save the `.torrent` file as (optional)
'';
};
};
}
126 changes: 126 additions & 0 deletions modules/clients/qBittorrent.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@

{ lib, ... }:
{
options.programs.nyaa.clients.qBittorrent = {
base_url = lib.mkOption {
type = lib.types.str;
default = "http://localhost:8080";
description = ''
The base url for qBittorrent
'';
};
username = lib.mkOption {
type = lib.types.str;
default = "admin";
description = ''
The username to login to qBittorrent
'';
};
password = lib.mkOption {
type = lib.types.str;
default = "adminadmin";
description = ''
The password to login to qBittorrent
'';
};
use_magnet = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether or not to send magnet links or torrent links (optional)
'';
};
savepath = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The path to save downloaded torrents to (optional)
'';
};
category = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The category to assign to torrents sent to qBittorrent (optional)
'';
};
tags = lib.mkOption {
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
description = ''
List of tags to assign to torrents sent to qBittorrent (optional)
'';
};
skip_checking = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to skip checking on all downloaded torrents (optional)
'';
};
paused = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether new torrents should start in the paused state (optional)
'';
};
create_root_folder = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to create the root download folder if it does not exist (optional)
'';
};
up_limit = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
The upload limit (in Bytes/sec) for new torrents (optional)
'';
};
dl_limit = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
The download limit (in Bytes/sec) for new torrents (optional)
'';
};
ratio_limit = lib.mkOption {
type = lib.types.nullOr lib.types.float;
default = null;
description = ''
The ratio limit (floating point number) for new torrents (optional)
'';
};
seeding_time_limit = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Limit for how long torrents can seed (measured in minutes) (optional)
Only works if autoTMM is false/null
'';
};
auto_tmm = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to enable automatic torrent management (optional)
'';
};
sequential_download = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to download file contents in sequential order (optional)
'';
};
prioritize_first_last_pieces = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to prioritize the first and last pieces of the file (optional)
'';
};
};
}
33 changes: 33 additions & 0 deletions modules/clients/rqbit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ lib, ... }:
{
options.programs.nyaa.clients.rqbit = {
base_url = lib.mkOption {
type = lib.types.str;
default = "http://localhost:3030";
description = ''
The base url for rqbit
'';
};
use_magnet = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to send magnet links or torrent links (optional)
'';
};
overwrite = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether to overwrite existing files while downloading (optional)
'';
};
output_folder = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The path to save downloaded torrents to (optional)
'';
};
};
}
69 changes: 69 additions & 0 deletions modules/clients/transmission.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{ lib, ... }:
{
options.programs.nyaa.clients.transmission = {
base_url = lib.mkOption {
type = lib.types.str;
default = "http://localhost:9091/transmission/rpc";
description = ''
The base url for Transmission
'';
};
username = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The username to login to Transmission (optional)
'';
};
password = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The password to login to Transmission (optional)
'';
};
use_magnet = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether or not to send magnet links or torrent links (optional)
'';
};
labels = lib.mkOption {
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
description = ''
List of labels to assign to torrents sent to Transmission (optional)
'';
};
paused = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Whether new torrents should start in the paused state (optional)
'';
};
peer_limit = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Limits the number of connected peers (optional)
'';
};
download_dir = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The path to save downloaded torrents to (optional)
'';
};
bandwidth_priority = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
The bandwidth priority assigned to new torrents (optional)
This value can be `Low`, `Normal`, or `High`
'';
};
};
}
Loading

0 comments on commit 7d13559

Please sign in to comment.