Update spotify config handling
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -24,6 +24,8 @@ NixOS dotfiles and configuration for various hosts and users.
|
|||||||
|
|
||||||
- `users/<name>/`: Global configurations for individual users that apply across all hosts. This includes secrets (like GPG keys and third-party service passwords), wallpapers, and more.
|
- `users/<name>/`: Global configurations for individual users that apply across all hosts. This includes secrets (like GPG keys and third-party service passwords), wallpapers, and more.
|
||||||
|
|
||||||
|
- [`lib/`](./lib): Nix library function definitions and utilities.
|
||||||
|
|
||||||
- [`scripts/`](./scripts): Utility scripts for managing the repository.
|
- [`scripts/`](./scripts): Utility scripts for managing the repository.
|
||||||
- [`add-host.sh`](./scripts/add-host.sh): Instantiate the keys for a new host configuration.
|
- [`add-host.sh`](./scripts/add-host.sh): Instantiate the keys for a new host configuration.
|
||||||
- [`remove-host.sh`](./scripts/remove-host.sh): Remove references to a host.
|
- [`remove-host.sh`](./scripts/remove-host.sh): Remove references to a host.
|
||||||
|
@@ -1,2 +1 @@
|
|||||||
app.autostart-mode="off"
|
app.autostart-mode="off"
|
||||||
storage.last-location="/home/nick/.cache/spotify/Storage"
|
|
||||||
|
@@ -9,6 +9,9 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
hmConfig = config.home-manager.users.${user};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
networking.firewall = {
|
networking.firewall = {
|
||||||
allowedTCPPorts = [ 57621 ];
|
allowedTCPPorts = [ 57621 ];
|
||||||
@@ -59,84 +62,22 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user = {
|
sops.secrets."spotify/username" = { };
|
||||||
services =
|
|
||||||
let
|
|
||||||
merge = lib.meta.getExe (
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "merge";
|
|
||||||
runtimeInputs = with pkgs; [
|
|
||||||
gnugrep
|
|
||||||
coreutils
|
|
||||||
];
|
|
||||||
text = builtins.readFile ./config/merge.sh;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
spotify-init = {
|
|
||||||
Unit = {
|
|
||||||
Description = "Populate Spotify preferences from template";
|
|
||||||
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
||||||
DefaultDependencies = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
Service = {
|
xdg.configFile = {
|
||||||
ExecStart = "${merge} ${./config/prefs} ${home}/.config/spotify/prefs";
|
"spotify/prefs.init" = {
|
||||||
Type = "oneshot";
|
source = ./config/prefs;
|
||||||
RemainAfterExit = true;
|
onChange = ''
|
||||||
};
|
${config.lib.runtime.merge.keyValue} "${home}/.config/spotify/prefs.init" "${home}/.config/spotify/prefs"
|
||||||
};
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
spotify-init-user = {
|
"spotify/prefs-user.init" = {
|
||||||
Unit = {
|
source = ./config/prefs-user;
|
||||||
Description = "Populate Spotify user preferences from template";
|
onChange = ''
|
||||||
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
user = $(cat "${hmConfig.sops.secrets."spotify/username".path}")
|
||||||
DefaultDependencies = false;
|
${config.lib.runtime.merge.keyValue} "${home}/.config/spotify/prefs-user.init" "${home}/.config/spotify/Users/''${user}-user/prefs"
|
||||||
};
|
'';
|
||||||
|
|
||||||
Service = {
|
|
||||||
ExecStart = lib.meta.getExe (
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "merge-user";
|
|
||||||
text = ''
|
|
||||||
for USER_DIR in ${home}/.config/spotify/Users/*/; do
|
|
||||||
${merge} ${./config/user-prefs} "$USER_DIR/prefs"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
paths = {
|
|
||||||
spotify-init = {
|
|
||||||
Unit = {
|
|
||||||
Description = "Monitor Spotify directory";
|
|
||||||
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
||||||
};
|
|
||||||
|
|
||||||
Path.PathExists = "${home}/.config/spotify";
|
|
||||||
|
|
||||||
Install.WantedBy = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
spotify-init-user = {
|
|
||||||
Unit = {
|
|
||||||
Description = "Monitor Spotify user directory";
|
|
||||||
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
||||||
};
|
|
||||||
|
|
||||||
Path = {
|
|
||||||
PathExists = "${home}/.config/spotify/Users";
|
|
||||||
PathModified = "${home}/.config/spotify/Users";
|
|
||||||
};
|
|
||||||
|
|
||||||
Install.WantedBy = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
- [ ] Spotify
|
- [ ] Spotify
|
||||||
- [ ] Authenticate
|
- [ ] Authenticate
|
||||||
|
- [ ] Local Files
|
||||||
|
|
||||||
- [ ] Steam
|
- [ ] Steam
|
||||||
- [ ] Authenticate
|
- [ ] Authenticate
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
../../lib
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
(import ./format.nix { device = "/dev/disk/by-id/nvme-SAMSUNG_MZVL22T0HBLB-00BL2_S64RNE0R602762"; })
|
(import ./format.nix { device = "/dev/disk/by-id/nvme-SAMSUNG_MZVL22T0HBLB-00BL2_S64RNE0R602762"; })
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
|
6
lib/default.nix
Normal file
6
lib/default.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
lib = {
|
||||||
|
runtime = pkgs.callPackage ./runtime { };
|
||||||
|
};
|
||||||
|
}
|
4
lib/runtime/default.nix
Normal file
4
lib/runtime/default.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
merge = pkgs.callPackage ./merge { };
|
||||||
|
}
|
13
lib/runtime/merge/default.nix
Normal file
13
lib/runtime/merge/default.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{ lib, pkgs, ... }:
|
||||||
|
{
|
||||||
|
keyValue = lib.meta.getExe (
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "merge-key-value";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
gnugrep
|
||||||
|
coreutils
|
||||||
|
];
|
||||||
|
text = builtins.readFile ./key-value.sh;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
Reference in New Issue
Block a user