[Feature Request]: home-manager module #2879

Open
opened 2025-01-17 04:10:24 +00:00 by Lalit64 · 9 comments
Lalit64 commented 2025-01-17 04:10:24 +00:00 (Migrated from github.com)

Preflight Checklist

  • I use the latest version of YouTube Music (Application).
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

Hey, has anyone considered a home-manager module

Proposed Solution

create a home-manager module that allows one to configure the plugins and the settings, and also options

Alternatives Considered

none

Additional Information

none

### Preflight Checklist - [x] I use the latest version of YouTube Music (Application). - [x] I have searched the [issue tracker](https://github.com/th-ch/youtube-music/issues) for a feature request that matches the one I want to file, without success. ### Problem Description Hey, has anyone considered a home-manager module ### Proposed Solution create a home-manager module that allows one to configure the plugins and the settings, and also options ### Alternatives Considered none ### Additional Information none
Owner

Could you provide relevant documentation?

Could you provide relevant documentation?
Lalit64 commented 2025-01-17 12:23:36 +00:00 (Migrated from github.com)
https://nix-community.github.io/home-manager/index.xhtml#ch-writing-modules
h-banii commented 2025-01-18 07:26:00 +00:00 (Migrated from github.com)

It's possible to configure youtube-music's config.json file using home manager, but since the nix store is read-only, youtube-music can't write to config.json anymore (it uses it to store some values).

Error: EROFS: read-only file system, open '/nix/store/16y98k58vn7qpy9yqq49y6rm7ymcg90a-hm_YouTubeMusicconfig.json.tmp-7148096567a96831'
    at openSync (node:fs:573:18)
    at func (node:electron/js2c/node_init:2:2559)
    at p (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:157:24681)
    at writeFileSync (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:157:29679)
    at ElectronStore._write (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:8300)
    at ElectronStore.set store [as store] (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:6850)
    at ElectronStore.set (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:5562)
    at Object.set (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:24914)
    at handleData (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:26147)
    at /nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:27818 {
  errno: -30,
  code: 'EROFS',
  syscall: 'open',
  path: '/nix/store/16y98k58vn7qpy9yqq49y6rm7ymcg90a-hm_YouTubeMusicconfig.json.tmp-7148096567a96831'
}

So it's somewhat doable, but I think it would be better to not touch config.json. It would be nice to have separate my-config.json files managed by the user, or home manager in this case, and a way to select/import it. Something similar to #1384

Here's a basic hm module https://github.com/h-banii/youtube-music-nix
(I didn't implement all plugins though, just a few for testing)
edit: I finished implementing all the options, I haven't tested all of them, but they should probably work

It's possible to configure youtube-music's `config.json` file using home manager, but since the nix store is read-only, youtube-music can't write to `config.json` anymore (it uses it to store some values). ``` Error: EROFS: read-only file system, open '/nix/store/16y98k58vn7qpy9yqq49y6rm7ymcg90a-hm_YouTubeMusicconfig.json.tmp-7148096567a96831' at openSync (node:fs:573:18) at func (node:electron/js2c/node_init:2:2559) at p (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:157:24681) at writeFileSync (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:157:29679) at ElectronStore._write (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:8300) at ElectronStore.set store [as store] (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:6850) at ElectronStore.set (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:5562) at Object.set (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:24914) at handleData (/nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:26147) at /nix/store/70l884lf1qcix8j456ygnxlhyn41y3hk-youtube-music-v3.7.1/share/lib/youtube-music/resources/app.asar/dist/main/index.js:165:27818 { errno: -30, code: 'EROFS', syscall: 'open', path: '/nix/store/16y98k58vn7qpy9yqq49y6rm7ymcg90a-hm_YouTubeMusicconfig.json.tmp-7148096567a96831' } ``` So it's somewhat doable, but I think it would be better to not touch `config.json`. It would be nice to have separate `my-config.json` files managed by the user, or home manager in this case, and a way to select/import it. Something similar to #1384 Here's a basic hm module https://github.com/h-banii/youtube-music-nix ~~(I didn't implement all plugins though, just a few for testing)~~ edit: I finished implementing all the options, I haven't tested all of them, but they should *probably* work
Lalit64 commented 2025-01-18 07:39:59 +00:00 (Migrated from github.com)

@h-banii I think the point of nix is for the system to be declarative so why would youtube-music need to write to the config.json?

edit: can we talk on discord?

@h-banii I think the point of nix is for the system to be declarative so why would youtube-music need to write to the config.json? edit: can we talk on discord?
Owner

@Lalit64 we are writing to the config.json for various reasons, one of them is config migration from an older version to a newer version.

@Lalit64 we are writing to the config.json for various reasons, one of them is config migration from an older version to a newer version.
Owner

Another reason is, if you have the setting to continue where you left off, it saves the current url to the config, an immutable config would render this useless

Another reason is, if you have the setting to continue where you left off, it saves the current url to the config, an immutable config would render this useless
Owner

It would be better to have a user-config, like an override, using a secondary file managed by nix, just like how @h-banii proposed

It would be better to have a user-config, like an override, using a secondary file managed by nix, just like how @h-banii proposed
Lalit64 commented 2025-01-18 14:13:29 +00:00 (Migrated from github.com)

@ArjixWasTaken Ok, I understand

@ArjixWasTaken Ok, I understand
h-banii commented 2025-07-29 17:35:12 +00:00 (Migrated from github.com)

Just to give an update on this:

I decided to copy the config.json file instead of symlinking it to the store (to avoid the read-only problem)

So technically the home manager module at https://github.com/h-banii/youtube-music-nix is in a functional state now

I added a documentation for all the options in the repo's github page
https://h-banii.github.io/youtube-music-nix/pages/home-manager/

Just to give an update on this: I decided to copy the `config.json` file instead of symlinking it to the store (to avoid the read-only problem) So technically the home manager module at https://github.com/h-banii/youtube-music-nix is in a functional state now I added a documentation for all the options in the repo's github page https://h-banii.github.io/youtube-music-nix/pages/home-manager/
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: YTMD/youtube-music#2879
No description provided.