Skip to content
Snippets Groups Projects
README.rst 3.13 KiB
Newer Older
  • Learn to ignore specific revisions
  • Set up and use a network of local development VMs
    -------------------------------------------------
    
    ... using `Vagrant <https://www.vagrantup.com/>`_ to manage VirtualBox VMs [#]_.
    To get started, first install Vagrant and make sure it works.
    One possible way to do it in NixOS:
    
    1. Install Vagrant, by adding the packages:
    
      - ``vagrant`` (orchestrating virtual machines on the command line)
         - Only use when version >= 2.2.16 has become available.  Else see below.
      - Optional: ``packer`` (for creating your own VM images)
    
    2. Add configuration to install and enable VirtualBox:
    
      - ``virtualisation.virtualbox.host.enable = true;``
    
    3. Add your user to the ``vboxusers`` group, for example:
    
      - ``users.extraGroups.vboxusers.members = [ "flo" "jp" ];``
    
    
    .. [#] The author of this documentation wasted a lot of time trying to get Vagrant to work with KVM/libvirt.  Issues with networking that looked like guest misconfigurations vanished after changing to the better-tested combination of Vagrant and VirtualBox.
    
    
    Pre-Vagrant 2.2.16: Get Vagrant with the required fixes for NixOS guests
    ````````````````````````````````````````````````````````````````````````
    
    The Vagrant nixos-guest template `received a critical update on 2021-03-08 <https://github.com/hashicorp/vagrant/commit/990d94ed9d0b3092e855bc1bb9deeeb7aa7792cf>`_ which is going to be in version 2.2.16 once it's out.
    
    Retrieve and use the latest Vagrant development version locally::
    
      git clone ssh://git@github.com/hashicorp/vagrant.git
      cd vagrant/
      nix-shell -p gcc gnumake git gnutar curl ruby
      bundle install
      bundle --binstubs exec
      cd exec/
      export PATH=`pwd`:$PATH
    
    
    
    Generating and deploying keys
    `````````````````````````````
    
    Here is a Ristretto key you can use, randomly generated just now::
    
      SILOWzbnkBjxC1hGde9d5Q3Ir/4yLosCLEnEQGAxEQE=
    
    Generate your own like this::
    
      [nix-shell:~/PrivateStorageio]$ nix-shell -p zkapissuer.components.exes.PaymentServer-generate-key
      [nix-shell:~/PrivateStorageio]$ PaymentServer-generate-key
      SILOWzbnkBjxC1hGde9d5Q3Ir/4yLosCLEnEQGAxEQE=
    
    For the Stripe key any random bytes with a little light formatting "work" - at least to make our software happy - but if you want to be able to interact with Stripe and have payments (even pretend payments) move all the way through the system you should get a Stripe account and generate a key w/ them.
    Lauri can get you added to our "dev" Stripe account, too, though I forget how important that is for ad hoc dev/testing.
    
    I think this will work for generating random Stripe secret keys (that our software will load, I think, but Stripe will reject)::
    
      >>> import base64, os
      >>> print((b"sk_test_" + base64.b64encode(os.urandom(25)).strip(b"=")).decode("ascii"))
      sk_test_Dr+XLVjkC0oO3Zw8Ws0yWtDLqR1sM+/fmw
    
    Public keys are the same but "pk_test" instead of "sk_test" ("test" is for "test mode" key that can only process pretend txns; for real txns there are keys with "live" embedded).
    
    
    
    Use the local development environment
    `````````````````````````````````````
    
    Build and start the VMs::
    
      vagrant up
    
    Then::
    
      morph build grid.nix
      morph push grid.nix
    
    Florian Sesser's avatar
    Florian Sesser committed
      morph upload-secrets grid.nix