Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a nix flake for nix users #670

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Create a nix flake for nix users #670

wants to merge 1 commit into from

Conversation

imadnyc
Copy link

@imadnyc imadnyc commented Apr 22, 2024

Hey, I created a simple nix flake for people who use nix like me. The issue I'm running into with is that the --no-db seems to still want to assert a path from the executable dir, which in NixOS it can't do because the executable dir is immutable. The fix should be simple -- just make the assert path in db.py a conditional that checks if no-db is passed first. I don't want to change that though because I'm unfamiliar with the code and am unsure if it'll break something, so I'd like some more feedback first.

@imadnyc imadnyc marked this pull request as draft April 22, 2024 19:26
@nathom
Copy link
Owner

nathom commented Apr 22, 2024

The folder where streamrip stores configuration is generated using the appdirs package. If it's generating a folder that's immutable on Nix that suggests appdirs doesn't support NixOS. Maybe you should open a bug report there too.

In the meantime, a fix could simply be to override the folder in

from appdirs import user_config_dir
APPNAME = "streamrip"
APP_DIR = user_config_dir(APPNAME)
HOME = Path.home()
LOG_DIR = CACHE_DIR = CONFIG_DIR = APP_DIR

if NixOS is detected.

@imadnyc
Copy link
Author

imadnyc commented Apr 22, 2024

Hey, sorry, I forgot to attach logs that I thought would be helpful.

➜  streamrip git:(dev) ✗ run .# -- --config-path ./config.toml --no-db search qobuz  album 'rael'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /nix/store/p4j7bl3paq27d64ifxbygcfk5cphc8g3-python3.11-streamrip-2.0.5/bin/.rip-wrapped:9 in     │
│ <module>                                                                                         │
│                                                                                                  │
│    6 from streamrip.rip import rip                                                               │
│    7 if __name__ == "__main__":                                                                  │
│    8 │   sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])                        │
│ ❱  9 │   sys.exit(rip())                                                                         │
│   10                                                                                             │
│                                                                                                  │
│ /nix/store/wkqfh7y23c3qlmg8igdaw256whsvqndv-python3.11-click-8.1.7/lib/python3.11/site-packages/ │
│ click/core.py:1157 in __call__                                                                   │
│                                                                                                  │
│                                     ... 10 frames hidden ...                                     │
│                                                                                                  │
│ /nix/store/p4j7bl3paq27d64ifxbygcfk5cphc8g3-python3.11-streamrip-2.0.5/lib/python3.11/site-packa │
│ ges/streamrip/rip/main.py:64 in __init__                                                         │
│                                                                                                  │
│    61 │   │   │   downloads_db = db.Dummy()                                                      │
│    62 │   │                                                                                      │
│    63 │   │   if c.failed_downloads_enabled:                                                     │
│ ❱  64 │   │   │   failed_downloads_db = db.Failed(c.failed_downloads_path)                       │
│    65 │   │   else:                                                                              │
│    66 │   │   │   failed_downloads_db = db.Dummy()                                               │
│    67                                                                                            │
│                                                                                                  │
│ /nix/store/p4j7bl3paq27d64ifxbygcfk5cphc8g3-python3.11-streamrip-2.0.5/lib/python3.11/site-packa │
│ ges/streamrip/db.py:67 in __init__                                                               │
│                                                                                                  │
│    64 │   │   """                                                                                │
│    65 │   │   assert self.structure != {}                                                        │
│    66 │   │   assert self.name                                                                   │
│ ❱  67 │   │   assert path                                                                        │
│    68 │   │                                                                                      │
│    69 │   │   self.path = path                                                                   │
│    70                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AssertionError

How nix works is that the the entire repo is copied to an immutable folder, so any thing that changes/creates a file in the repo dir is impossible. That said, the program seems to continue fine if I comment out the assert path, which doesn't make sense -- the path should exist, it should just be immutable.

If I print("this is the name of the path", path) like so in db.py:

assert self.structure != {}
assert self.name
print("This is the path name",path)
if (path == ""):
        print("yup, it's an empty string")
assert path

I get that path is just an empty string. If I then set path = "<some path>" (thereby passing the assert, commenting works also) it works fine. Is this still related to the appdirs thing or something else? I could start a diff bug report if you'd like. I'm kind of unsure as to why it's getting an empty string -- if this is something that I can only get on my machine let me know and I'll do some more testing.

Worst comes to worst I could just add a .patch that's only used in my flake but maybe other non-nix users have this too

@nathom
Copy link
Owner

nathom commented Apr 23, 2024

Do you have db paths set in the config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants