~sircmpwn/sr.ht-discuss

3 3

How do I set up sr.ht locally for hacking?

Details
Message ID
<CBEMZUYZ5SK1.1YPSYJFS3A1G0@bellwether>
DKIM signature
fail
Download raw message
DKIM signature: fail
I'd like to hack on sourcehut a bit and contribute to it, but I don't yet have a
server to deploy it on. I'm not very familiar with using this kind of software
and the Hacking on Sourcehut [1] page isn't very beginner-friendly.

Can somebody assist me with setting it up on my local machine? I have a feeling
it's a very simple process that I'm missing.

[1]: https://man.sr.ht/hacking.md
Details
Message ID
<CBETDFZWXLBD.1EM5LC08T7EXH@taiga>
In-Reply-To
<CBEMZUYZ5SK1.1YPSYJFS3A1G0@bellwether> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
No one is going to sit down with you and walk you through each of the
steps. It would help if you made an earnest effort to do it on your own,
following the documentation, and ask with more specific questions as you
run into issues.
Details
Message ID
<27df2992-3572-a7c4-2325-5dd6e5e1371a@mehdix.org>
In-Reply-To
<CBEMZUYZ5SK1.1YPSYJFS3A1G0@bellwether> (view parent)
DKIM signature
pass
Download raw message
On 5/16/21 13:35, Sol Fisher Romanoff wrote:
> I'd like to hack on sourcehut a bit and contribute to it, but I don't yet have a
> server to deploy it on. I'm not very familiar with using this kind of software
> and the Hacking on Sourcehut [1] page isn't very beginner-friendly.
> 
> Can somebody assist me with setting it up on my local machine? I have a 
feeling
> it's a very simple process that I'm missing.
> 
> [1]: https://man.sr.ht/hacking.md
> 

I guess the Hacking document expects you to figure out everything for 
yourself. However there is value in not figuring everything out by trial 
and error.

Here is my quick intro, based on my experience running sr.ht locally on 
Arch Linux to make a few patches for core and lists. For each service 
see the respective installation document please.

SourceHut is made of a few independent python projects. They all share 
scm, core and meta. A postgres server is necessary. Setting up lists 
would need a functional mail server. I used postfix with mostly default 
configurations and mutt for testing. You should probably tweak your 
local DNS. scm and core contain the shared python (Flask) code and much 
of templates, so they should be installed in the same python 
environment. You can install them system-wide or use a virtualenv.

A brief walk-through would be: clone scm, core and meta and everything 
else you want to hack on. Activate your virtualenv (or go system-wide). 
In each directory run python setup.py install. Then run `run.py` of the 
respective project and install missing dependencies along the way if any 
(celery, pygit2 and some others were missing for me). In each repository 
there is a `NAME-initdb` script which you should run to add the 
necessities to the database before first use (there are also other 
scripts, see for yourself). You would need an admin user to login, use 
the `metasrht-manageuser` to create that (which will be in your path if 
you install meta in your (virtual)-environment. Don't forget to activate 
it everytime if you decided for virtualenv).

I experienced problem logging in at first and was stuck in a login loop. 
I guess it was due to DNS and forwarding issues. I made the following 
changes to my /etc/hosts file (playground is my hostname):

	127.0.0.1   playground.localdomain playground
	127.0.0.1   meta.sr.ht.localdomain
	127.0.0.1   git.sr.ht.localdomain
	127.0.0.1   lists.sr.ht.localdomain

And installed nginx on top of it and configured to forward these 
addresses to locally running python processes. I added the following 
server blocks to my nginx configuration:

     server {
         listen 80;
         server_name meta.sr.ht.localdomain;

         client_max_body_size 100M;

         location / {
             proxy_pass http://127.0.0.1:5000;
         }

         location /query {
             proxy_pass http://127.0.0.1:5100;
         }
     }
     server {
         listen 80;
         server_name git.sr.ht.localdomain;

         client_max_body_size 100M;

         location / {
             proxy_pass http://127.0.0.1:5001;
         }
     }
     server {
         listen 80;
         server_name lists.sr.ht.localdomain;

         client_max_body_size 100M;

         location / {
             proxy_pass http://127.0.0.1:5006;
         }
     }

And so forth for each service. With these changes I was able to login at 
http://meta.sr.ht.localdomain after running meta.sr.ht/run.py. Remember 
for each service you have to run a separate process, i.e. for meta, git, 
lists, etc (except scm and core since those are only packages).

For testing mailing list functionality LMTP should be configured. 
Basically we tell postfix (or other Mail Transfer Agents) to hand over 
certain mails such as patches to a process running somewhere, in this 
case lists.sr.ht. I had to edit /etc/postfix/transfer and add the 
following lines for LMTP to work:

	playground.localdomain local:playground
	lists.sr.ht.localdomain lmtp:localhost:5555

And then run `postmaster /etc/postfix/transport` for the changes to take 
effect and restart postfix. See postfix docs for more details. You would 
need to run `listsrht-lmtp` in a separate terminal to make this work.

I also modified my postfix main.cf to contain the following:

	myhostname = playground
	mydomain = playground

For interacting with the local mail server and lists.sr.ht.localdomain I 
used the the configuration from Drew's article [0]. For details on mail 
server installation see sr.ht docs [1].

In my experience making lists.sr.ht to work was the most involved and 
the login-loop was the most annoying.

Hope this helps.

[0]: https://drewdevault.com/2018/08/05/Local-mail-server.html
[1]: https://man.sr.ht/lists.sr.ht/configuration.md
Details
Message ID
<CBFFZF723BNV.2RT6XS3SS5235@bellwether>
In-Reply-To
<27df2992-3572-a7c4-2325-5dd6e5e1371a@mehdix.org> (view parent)
DKIM signature
pass
Download raw message
Thank you very much, this was extremely helpful and I now have  a working local
instance!
Reply to thread Export thread (mbox)