Refactor my home-manager config
This commit is contained in:
parent
c6100f63d7
commit
7539811ce3
31 changed files with 294 additions and 241 deletions
22
flake.nix
22
flake.nix
|
@ -75,16 +75,7 @@
|
|||
# Home manager
|
||||
home-manager.nixosModules.home-manager
|
||||
./home-manager
|
||||
{
|
||||
ty-home-manager-options = {
|
||||
plasma.enable = true;
|
||||
beets.enable = true;
|
||||
firefox.enable = true;
|
||||
thunderbird.enable = true;
|
||||
rescrobbled.enable = true;
|
||||
vscode.enable = true;
|
||||
};
|
||||
}
|
||||
{ meta.home-manager.preset = "plasma-desktop"; }
|
||||
];
|
||||
|
||||
specialArgs = {
|
||||
|
@ -105,16 +96,7 @@
|
|||
# Home manager
|
||||
home-manager.nixosModules.home-manager
|
||||
./home-manager
|
||||
{
|
||||
ty-home-manager-options = {
|
||||
plasma.enable = false;
|
||||
beets.enable = false;
|
||||
firefox.enable = false;
|
||||
thunderbird.enable = false;
|
||||
rescrobbled.enable = false;
|
||||
vscode.enable = false;
|
||||
};
|
||||
}
|
||||
{ meta.home-manager.preset = "cli"; }
|
||||
|
||||
# VSCode server support
|
||||
vscode-server.nixosModules.default
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, ty-home-manager-options, ... }:
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
accounts.email.accounts = lib.mkIf ty-home-manager-options.thunderbird.enable {
|
||||
accounts.email.accounts = lib.mkIf config.meta.home-manager.email.enable {
|
||||
PurelyMail = rec {
|
||||
realName = "Tyler Beckman";
|
||||
address = "ty@myriation.xyz";
|
||||
|
@ -38,7 +38,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
thunderbird.enable = true;
|
||||
thunderbird.enable = config.meta.home-manager.email.thunderbird.enable;
|
||||
};
|
||||
|
||||
Gmail = rec {
|
||||
|
@ -62,7 +62,7 @@
|
|||
|
||||
smtp.tls.useStartTls = false;
|
||||
|
||||
thunderbird.enable = true;
|
||||
thunderbird.enable = config.meta.home-manager.email.thunderbird.enable;
|
||||
};
|
||||
|
||||
School = rec {
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, secrets, ty-home-manager-options, ... }:
|
||||
{ lib, secrets, config, ... }:
|
||||
{
|
||||
programs.beets = lib.mkIf ty-home-manager-options.beets.enable {
|
||||
programs.beets = lib.mkIf config.meta.home-manager.beets.enable {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
20
home-manager/config/default.nix
Normal file
20
home-manager/config/default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
# Directories
|
||||
./accounts
|
||||
./shell
|
||||
./vcs
|
||||
# Individual files
|
||||
./beets.nix
|
||||
./desktop.nix
|
||||
./firefox.nix
|
||||
./gpg.nix
|
||||
./gtk.nix
|
||||
./packages.nix
|
||||
./plasma.nix
|
||||
./rescrobbled.nix
|
||||
./thunderbird.nix
|
||||
./vscode.nix
|
||||
];
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, ty-home-manager-options, ... }:
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
xdg.desktopEntries = lib.mkIf ty-home-manager-options.plasma.enable {
|
||||
xdg.desktopEntries = lib.mkIf config.meta.home-manager.desktop.enable {
|
||||
# Override vesktop for matching icon in beautyline (make it generic discord icon)
|
||||
vesktop = {
|
||||
categories = [ "Network" "InstantMessaging" "Chat" ];
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, inputs, system, lib, ty-home-manager-options, ... }:
|
||||
{ pkgs, inputs, system, lib, config, ... }:
|
||||
{
|
||||
programs.firefox = lib.mkIf ty-home-manager-options.firefox.enable {
|
||||
programs.firefox = lib.mkIf config.meta.home-manager.firefox.enable {
|
||||
enable = true;
|
||||
policies = {
|
||||
ExtensionSettings = {
|
|
@ -1,12 +1,12 @@
|
|||
{ pkgs, lib, config, ty-home-manager-options, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
config = lib.mkIf ty-home-manager-options.plasma.enable {
|
||||
config = lib.mkIf config.meta.home-manager.desktop.enable {
|
||||
gtk = {
|
||||
enable = true;
|
||||
|
||||
gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
|
||||
|
||||
theme = {
|
||||
theme = lib.mkIf config.meta.home-manager.desktop.plasma.enable {
|
||||
name = "Breeze-Dark";
|
||||
package = pkgs.kdePackages.breeze-gtk;
|
||||
};
|
73
home-manager/config/packages.nix
Executable file
73
home-manager/config/packages.nix
Executable file
|
@ -0,0 +1,73 @@
|
|||
{ pkgs, inputs, system, lib, config, ... }:
|
||||
{
|
||||
home.packages =
|
||||
## Packages that are always installed, no matter what
|
||||
(with pkgs; [
|
||||
# :3
|
||||
fastfetch # Modern & faster neofetch alternative
|
||||
|
||||
# CLI Tools
|
||||
ripgrep # Text searching and manipulation
|
||||
jq # JSON filtering
|
||||
eza # Directory lister
|
||||
bat # File reading
|
||||
doggo # DNS Requests
|
||||
nmap # Network scanning
|
||||
glow # Markdown rendering
|
||||
tealdeer # TLDR
|
||||
usbutils # `lsusb`
|
||||
pciutils # `lspci`
|
||||
unzip # Extract zip files
|
||||
|
||||
# Process tools
|
||||
btop # Process monitor
|
||||
nvtopPackages.full # GPU monitor
|
||||
])
|
||||
## Packages that are only installed when a desktop environment is desired
|
||||
++ (lib.optionals config.meta.home-manager.desktop.enable (with pkgs; [
|
||||
# Documents
|
||||
logseq # Outliner
|
||||
libreoffice-qt6-fresh # Office-style editing
|
||||
hunspell
|
||||
hunspellDicts.en_US-large
|
||||
|
||||
# Video
|
||||
jellyfin-media-player # Jellyfin electron client w/ MPV
|
||||
vlc # Video file player
|
||||
|
||||
# Chat
|
||||
element-desktop # Matrix client
|
||||
vesktop # Discord client
|
||||
signal-desktop # Signal client
|
||||
|
||||
# KDE Themes
|
||||
vimix-cursors # Cursors
|
||||
(pkgs.callPackage ../../packages/beautyline {}) # Icons
|
||||
(pkgs.callPackage ../../packages/magna-splash-6 {}) # Splash
|
||||
|
||||
# Programming
|
||||
jetbrains.idea-ultimate # Jetbrains IntelliJ Idea Ultimate IDE
|
||||
nixd # LSP for .nix files
|
||||
gcc # GNU C++ Compiler
|
||||
(lib.meta.hiPrio clang) # LLVM C++ Compiler (better than g++)
|
||||
clang-tools # Clang language server
|
||||
cling # C++ REPL
|
||||
deno # Typescript & Javascript runtime
|
||||
gnumake # Makefile support
|
||||
|
||||
# UI Tools
|
||||
qalculate-qt # Calculator
|
||||
]))
|
||||
## Packages that are only installed if plasma is used as the desktop environment
|
||||
++ (lib.optionals config.meta.home-manager.desktop.plasma.enable (with pkgs.kdePackages; [
|
||||
kate # IDE
|
||||
elisa # Music
|
||||
kdeconnect-kde # Phone sync
|
||||
polkit-kde-agent-1 # Polkit authentication popup support
|
||||
]))
|
||||
## Firefox is only installed when requested
|
||||
++ (lib.optionals config.meta.home-manager.firefox.enable [
|
||||
# Firefox nightly
|
||||
inputs.firefox-nightly.packages.${system}.firefox-nightly-bin
|
||||
]);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, lib, ty-home-manager-options, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
programs.plasma = lib.mkIf ty-home-manager-options.plasma.enable {
|
||||
programs.plasma = lib.mkIf config.meta.home-manager.desktop.plasma.enable {
|
||||
enable = true;
|
||||
|
||||
workspace = {
|
23
home-manager/config/rescrobbled.nix
Normal file
23
home-manager/config/rescrobbled.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ secrets, lib, config, ... }:
|
||||
{
|
||||
config = lib.mkIf config.meta.home-manager.rescrobbled.enable {
|
||||
services.custom.rescrobbled = let s = secrets.programs.rescrobbled; in lib.mkIf s.enable {
|
||||
enable = true;
|
||||
|
||||
session = s.lastfm.session;
|
||||
|
||||
settings = {
|
||||
player-whitelist = [ "elisa" ];
|
||||
|
||||
listenbrainz = lib.mkIf (s.listenbrainz.token != null) [
|
||||
{
|
||||
token = s.listenbrainz.token;
|
||||
}
|
||||
];
|
||||
|
||||
lastfm-key = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.key;
|
||||
lastfm-secret = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.secret;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, lib, ty-home-manager-options, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
programs.konsole = lib.mkIf ty-home-manager-options.plasma.enable {
|
||||
programs.konsole = lib.mkIf config.meta.home-manager.desktop.plasma.enable {
|
||||
enable = true;
|
||||
defaultProfile = "Primary";
|
||||
profiles = {
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, lib, ty-home-manager-options, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
programs.thunderbird = lib.mkIf ty-home-manager-options.thunderbird.enable {
|
||||
programs.thunderbird = lib.mkIf config.meta.home-manager.email.thunderbird.enable {
|
||||
enable = true;
|
||||
package = pkgs.thunderbird-latest;
|
||||
profiles = {
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, inputs, system, lib, ty-home-manager-options, ... }:
|
||||
{ pkgs, inputs, system, lib, config, ... }:
|
||||
{
|
||||
programs.vscode = lib.mkIf ty-home-manager-options.vscode.enable (
|
||||
programs.vscode = lib.mkIf config.meta.home-manager.vscode.enable (
|
||||
let vscode-package = pkgs.vscodium; in {
|
||||
enable = true;
|
||||
package = vscode-package;
|
|
@ -1,85 +0,0 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
let tomlFormat = pkgs.formats.toml { }; in {
|
||||
options = {
|
||||
services.custom.rescrobbled = {
|
||||
enable = lib.mkEnableOption "rescrobbled";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = (pkgs.callPackage ../../packages/rescrobbled {});
|
||||
defaultText = lib.literalExpression "pkgs.rescrobbled";
|
||||
description = "The package to use for rescrobbled";
|
||||
};
|
||||
|
||||
session = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The session token to use for last.fm.
|
||||
This can be found by setting a last.fm API key & secret,
|
||||
and then manually running the daemon. Then, the session token
|
||||
will be located at {file}`$XDG_CONFIG_HOME/rescrobbled/session`.
|
||||
'';
|
||||
default = null;
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = {};
|
||||
example = lib.literalExpression ''
|
||||
lastfm-key = "Last.fm API key"
|
||||
lastfm-secret = "Last.fm API secret"
|
||||
min-play-time = 0
|
||||
player-whitelist = [ "Player MPRIS identity or bus name" ]
|
||||
filter-script = "path/to/script"
|
||||
|
||||
[[listenbrainz]]
|
||||
url = "Custom API URL"
|
||||
token = "User token"
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/rescrobbled/config.toml`.
|
||||
|
||||
See <https://github.com/InputUsername/rescrobbled#configuration> for the full list
|
||||
of options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = let cfg = config.services.custom.rescrobbled; in lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile ={
|
||||
"rescrobbled/config.toml" = lib.mkIf (cfg.settings != { }) {
|
||||
enable = true;
|
||||
|
||||
source = tomlFormat.generate "rescrobbled-config" cfg.settings;
|
||||
};
|
||||
|
||||
"rescrobbled/session" = lib.mkIf (cfg.settings != { }) {
|
||||
enable = true;
|
||||
# Force makes it easy to generate the session file, then add it to nix cfg without issues
|
||||
force = true;
|
||||
|
||||
text = cfg.session;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.rescrobbled = {
|
||||
Unit = {
|
||||
Description = "An MPRIS scrobbler";
|
||||
Documentation = "https://github.com/InputUsername/rescrobbled";
|
||||
Wants = "network-online.target";
|
||||
After = "network-online.target";
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/sleep 15"; # Avoid listenbrainz errors by adding delay till network is connected
|
||||
ExecStart = "${cfg.package}/bin/rescrobbled";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,31 +1,36 @@
|
|||
{ inputs, system, secrets, lib, config, ... }:
|
||||
{
|
||||
options.ty-home-manager-options = {
|
||||
plasma.enable = lib.mkEnableOption "plasma configuration";
|
||||
firefox.enable = lib.mkEnableOption "firefox configuration";
|
||||
thunderbird.enable = lib.mkEnableOption "thunderbird configuration";
|
||||
vscode.enable = lib.mkEnableOption "vscode configuration";
|
||||
beets.enable = lib.mkEnableOption "beets configuration";
|
||||
rescrobbled.enable = lib.mkEnableOption "rescrobbled configuration";
|
||||
};
|
||||
imports = [ ./meta.nix ];
|
||||
|
||||
config = {
|
||||
# Allow user installation of packages
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.sharedModules = [
|
||||
# Import plasma manager and all of my custom modules for use
|
||||
inputs.plasma-manager.homeManagerModules.plasma-manager
|
||||
./custom-modules
|
||||
./modules
|
||||
];
|
||||
# Inherit all of my nixos config custom arguments
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit inputs system secrets;
|
||||
inherit (config) ty-home-manager-options;
|
||||
};
|
||||
|
||||
# Hopefully avoid file conflicts
|
||||
home-manager.backupFileExtension = "backup";
|
||||
|
||||
home-manager.users.ty = {
|
||||
imports = [
|
||||
./home.nix
|
||||
# Import meta options for configuring the configuration
|
||||
./meta.nix
|
||||
# Import all of my config
|
||||
./config
|
||||
];
|
||||
|
||||
home.stateVersion = "24.05";
|
||||
|
||||
# Inherit my home manager config options
|
||||
meta.home-manager = config.meta.home-manager;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
{
|
||||
home.stateVersion = "24.05";
|
||||
home.username = "ty";
|
||||
home.homeDirectory = "/home/ty";
|
||||
|
||||
imports = [
|
||||
./modules/packages.nix
|
||||
./modules/plasma.nix
|
||||
./modules/vcs
|
||||
./modules/firefox.nix
|
||||
./modules/thunderbird.nix
|
||||
./modules/accounts
|
||||
./modules/gpg.nix
|
||||
./modules/shell
|
||||
./modules/vscode.nix
|
||||
./modules/desktop.nix
|
||||
./modules/gtk.nix
|
||||
./modules/beets.nix
|
||||
./modules/rescrobbled.nix
|
||||
];
|
||||
}
|
60
home-manager/meta.nix
Normal file
60
home-manager/meta.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{ lib, config, ... }:
|
||||
{
|
||||
options.meta.home-manager = {
|
||||
# Presets for easy configuring the configuration
|
||||
preset = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.enum [ "plasma-desktop" "cli" ]);
|
||||
default = null;
|
||||
defaultText = lib.literalExpression "null";
|
||||
description = ''
|
||||
The preset to use for enabling individual home-manager meta configuration options.
|
||||
|
||||
Presets:
|
||||
- plasma-desktop
|
||||
- Will enable anything that requires a desktop, and plasma-specific configuration
|
||||
- cli
|
||||
- Will only enable what is necessary for a CLI environment, excluding everything else
|
||||
'';
|
||||
};
|
||||
|
||||
# Individual configuration options
|
||||
beets.enable = lib.mkEnableOption "beets configuration";
|
||||
desktop = {
|
||||
enable = lib.mkEnableOption "configuration that requires a desktop environment";
|
||||
plasma.enable = lib.mkEnableOption "plasma configuration";
|
||||
};
|
||||
email = {
|
||||
enable = lib.mkEnableOption "email configuration";
|
||||
thunderbird.enable = lib.mkEnableOption "email configuration for thunderbird";
|
||||
};
|
||||
firefox.enable = lib.mkEnableOption "firefox configuration";
|
||||
rescrobbled.enable = lib.mkEnableOption "rescrobbled configuration";
|
||||
vscode.enable = lib.mkEnableOption "vscode configuration";
|
||||
};
|
||||
|
||||
# Handle preset logic
|
||||
config.meta.home-manager = lib.mkMerge [
|
||||
# Desktop w/ Plasma preset
|
||||
(lib.mkIf (config.meta.home-manager.preset == "plasma-desktop") {
|
||||
beets.enable = true;
|
||||
desktop.enable = true;
|
||||
desktop.plasma.enable = true;
|
||||
email.enable = true;
|
||||
email.thunderbird.enable = true;
|
||||
firefox.enable = true;
|
||||
rescrobbled.enable = true;
|
||||
vscode.enable = true;
|
||||
})
|
||||
# CLI Preset
|
||||
(lib.mkIf (config.meta.home-manager.preset == "cli") {
|
||||
beets.enable = false;
|
||||
desktop.enable = false;
|
||||
desktop.plasma.enable = false;
|
||||
email.enable = false;
|
||||
email.thunderbird.enable = false;
|
||||
firefox.enable = false;
|
||||
rescrobbled.enable = false;
|
||||
vscode.enable = false;
|
||||
})
|
||||
];
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
{ pkgs, inputs, system, lib, ty-home-manager-options, ... }:
|
||||
{
|
||||
home.packages = (with pkgs; [
|
||||
# :3
|
||||
fastfetch # Modern & faster neofetch alternative
|
||||
|
||||
# CLI Tools
|
||||
ripgrep # Text searching and manipulation
|
||||
jq # JSON filtering
|
||||
eza # Directory lister
|
||||
bat # File reading
|
||||
doggo # DNS Requests
|
||||
nmap # Network scanning
|
||||
glow # Markdown rendering
|
||||
tealdeer # TLDR
|
||||
usbutils # `lsusb`
|
||||
pciutils # `lspci`
|
||||
unzip # Extract zip files
|
||||
|
||||
# Process tools
|
||||
btop # Process monitor
|
||||
nvtopPackages.full # GPU monitor
|
||||
]) ++ (lib.optionals ty-home-manager-options.plasma.enable (with pkgs; [
|
||||
# Documents
|
||||
logseq # Outliner
|
||||
libreoffice-qt6-fresh # Office-style editing
|
||||
hunspell
|
||||
hunspellDicts.en_US-large
|
||||
|
||||
# Video
|
||||
jellyfin-media-player # Jellyfin electron client w/ MPV
|
||||
vlc # Video file player
|
||||
|
||||
# Chat
|
||||
element-desktop # Matrix client
|
||||
vesktop # Discord client
|
||||
signal-desktop # Signal client
|
||||
|
||||
# KDE Themes
|
||||
vimix-cursors # Cursors
|
||||
(pkgs.callPackage ../../packages/beautyline {}) # Icons
|
||||
(pkgs.callPackage ../../packages/magna-splash-6 {}) # Splash
|
||||
|
||||
# Programming
|
||||
jetbrains.idea-ultimate # Jetbrains IntelliJ Idea Ultimate IDE
|
||||
nixd # LSP for .nix files
|
||||
gcc # GNU C++ Compiler
|
||||
(lib.meta.hiPrio clang) # LLVM C++ Compiler (better than g++)
|
||||
clang-tools # Clang language server
|
||||
cling # C++ REPL
|
||||
deno # Typescript & Javascript runtime
|
||||
gnumake # Makefile support
|
||||
|
||||
# UI Tools
|
||||
qalculate-qt # Calculator
|
||||
])) ++ (lib.optionals ty-home-manager-options.firefox.enable [
|
||||
# Firefox nightly
|
||||
inputs.firefox-nightly.packages.${system}.firefox-nightly-bin
|
||||
]) ++ (lib.optionals ty-home-manager-options.plasma.enable (with pkgs.kdePackages; [
|
||||
kate # IDE
|
||||
elisa # Music
|
||||
kdeconnect-kde # Phone sync
|
||||
polkit-kde-agent-1 # Polkit authentication popup support
|
||||
]));
|
||||
}
|
|
@ -1,23 +1,85 @@
|
|||
{ secrets, lib, ty-home-manager-options, ... }:
|
||||
{
|
||||
config = lib.mkIf ty-home-manager-options.rescrobbled.enable {
|
||||
services.custom.rescrobbled = let s = secrets.programs.rescrobbled; in lib.mkIf s.enable {
|
||||
{ pkgs, lib, config, ... }:
|
||||
let tomlFormat = pkgs.formats.toml { }; in {
|
||||
options = {
|
||||
services.custom.rescrobbled = {
|
||||
enable = lib.mkEnableOption "rescrobbled";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = (pkgs.callPackage ../../packages/rescrobbled {});
|
||||
defaultText = lib.literalExpression "pkgs.rescrobbled";
|
||||
description = "The package to use for rescrobbled";
|
||||
};
|
||||
|
||||
session = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The session token to use for last.fm.
|
||||
This can be found by setting a last.fm API key & secret,
|
||||
and then manually running the daemon. Then, the session token
|
||||
will be located at {file}`$XDG_CONFIG_HOME/rescrobbled/session`.
|
||||
'';
|
||||
default = null;
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = {};
|
||||
example = lib.literalExpression ''
|
||||
lastfm-key = "Last.fm API key"
|
||||
lastfm-secret = "Last.fm API secret"
|
||||
min-play-time = 0
|
||||
player-whitelist = [ "Player MPRIS identity or bus name" ]
|
||||
filter-script = "path/to/script"
|
||||
|
||||
[[listenbrainz]]
|
||||
url = "Custom API URL"
|
||||
token = "User token"
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/rescrobbled/config.toml`.
|
||||
|
||||
See <https://github.com/InputUsername/rescrobbled#configuration> for the full list
|
||||
of options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = let cfg = config.services.custom.rescrobbled; in lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile ={
|
||||
"rescrobbled/config.toml" = lib.mkIf (cfg.settings != { }) {
|
||||
enable = true;
|
||||
|
||||
session = s.lastfm.session;
|
||||
|
||||
settings = {
|
||||
player-whitelist = [ "elisa" ];
|
||||
|
||||
listenbrainz = lib.mkIf (s.listenbrainz.token != null) [
|
||||
{
|
||||
token = s.listenbrainz.token;
|
||||
}
|
||||
];
|
||||
|
||||
lastfm-key = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.key;
|
||||
lastfm-secret = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.secret;
|
||||
source = tomlFormat.generate "rescrobbled-config" cfg.settings;
|
||||
};
|
||||
|
||||
"rescrobbled/session" = lib.mkIf (cfg.settings != { }) {
|
||||
enable = true;
|
||||
# Force makes it easy to generate the session file, then add it to nix cfg without issues
|
||||
force = true;
|
||||
|
||||
text = cfg.session;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.rescrobbled = {
|
||||
Unit = {
|
||||
Description = "An MPRIS scrobbler";
|
||||
Documentation = "https://github.com/InputUsername/rescrobbled";
|
||||
Wants = "network-online.target";
|
||||
After = "network-online.target";
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/sleep 15"; # Avoid listenbrainz errors by adding delay till network is connected
|
||||
ExecStart = "${cfg.package}/bin/rescrobbled";
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue