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

[DRAFT] Nix flake with ss emulator (to get nix develop to work) #556

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

VzxPLnHqr
Copy link

@VzxPLnHqr VzxPLnHqr commented May 6, 2024

Description

This is an attempt to get a Nix flake working with the seedsigner repository and upstreaming the seedsigner-emulator.

The Goal

# clone seedsigner repo
$ cd seedsigner
$ nix develop
# now you are in a bash shell with all the dependencies you need to make changes to seedsigner
# and you can run the emulator to test those changes by simply:
$ python3 src/main.py

Strategy

  • basic flake so that nix develop drops you into an environment with all seedsigner+emulator dependencies
  • get it working in emulator mode first
  • refactor so it works in both emulator mode as well as provides a flake output for building a SS image
  • refactor the flake to not be so ugly

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

  • I’ve run pytest and made sure all unit tests pass before sumbitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms/os:

Note: Keep your changes limited in scope; if you uncover other issues or improvements along the way, ideally submit those as a separate PR. The more complicated the PR the harder to review, test, and merge.

@VzxPLnHqr
Copy link
Author

VzxPLnHqr commented May 6, 2024

Unfortunately I currently do not know enough python nor the specifics of the seedsigner (and emulator) project code to figure out how to diagnose the following.

$ nix develop
$ python3 --version
Python 3.11.9
$ python3 src/main.py
Traceback (most recent call last):
  File "seedsigner/src/main.py", line 1, in <module>
    from seedsigner.controller import Controller
  File "seedsigner/src/seedsigner/controller.py", line 16, in <module>
    from seedsigner.views.screensaver import ScreensaverScreen
  File "seedsigner/src/seedsigner/views/__init__.py", line 1, in <module>
    from .view import *  # base class has to be first
    ^^^^^^^^^^^^^^^^^^^
  File "seedsigner/src/seedsigner/views/view.py", line 309, in <module>
    @dataclass
     ^^^^^^^^^
  File "/nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/lib/python3.11/dataclasses.py", line 1232, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/lib/python3.11/dataclasses.py", line 1222, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'seedsigner.views.view.Destination'> for field next_destination is not allowed: use default_factory

@VzxPLnHqr
Copy link
Author

with latest commit (ad55919) , emulator now loads up when running $ python3 main.py. Need to fix the camera though:

barcodes = pyzbar.decode(image, symbols=[ZBarSymbol.QRCODE], binary=is_binary)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: decode() got an unexpected keyword argument 'binary'
Appending next destination: UnhandledExceptionView({'error': ['TypeError', 'decode_qr.py, 316, in extract_qr_data', " decode() got an unexpected keyword argument 'binary'"]}) | clear_history: True
------------------------------
back_stack: [
     0: UnhandledExceptionView({'error': ['TypeError', 'decode_qr.py, 316, in extract_qr_data', " decode() got an unexpected keyword argument 'binary'"]}) | clear_history: True
]
Executing UnhandledExceptionView({'error': ['TypeError', 'decode_qr.py, 316, in extract_qr_data', " decode() got an unexpected keyword argument 'binary'"]}) | clear_history: True

@VzxPLnHqr
Copy link
Author

Ok, with (675bd9b), the camera now works! This needs a bunch of refactoring, but we are getting closer to having a nice nix develop workflow for simple PRs or for custom code people may want to run on SS.

@kdmukai
Copy link
Contributor

kdmukai commented Aug 7, 2024

@VzxPLnHqr can you change this PR to "DRAFT" until it's finished?

@VzxPLnHqr VzxPLnHqr changed the title [WIP] Nix flake with ss emulator (to get nix develop to work) [DRAFT] Nix flake with ss emulator (to get nix develop to work) Aug 7, 2024
@VzxPLnHqr
Copy link
Author

VzxPLnHqr commented Aug 7, 2024

@VzxPLnHqr can you change this PR to "DRAFT" until it's finished?

Yes, I changed it to DRAFT now. I am not sure when I will be able to finish it. Any idea if the emulator will be upstreamed? If so and SS can independently determine whether it is running inside the emulator or whether it is running on bare metal and behave accordingly, then it feels like this feature (making nix develop work) would be nice to have and lower the barrier to entry for future contributors.

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