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

sourcehut: init #54425

Merged
merged 10 commits into from Aug 14, 2019
@@ -0,0 +1,60 @@
{ stdenv, fetchgit, buildPythonPackage
, python
, buildGoModule
, srht, redis, celery, pyyaml, markdown }:

let
version = "0.45.13";

buildWorker = src: buildGoModule {
inherit src version;
pname = "builds-sr-ht-worker";
goPackagePath = "git.sr.ht/~sircmpwn/builds.sr.ht/worker";

modSha256 = "1jm259ncw8dgqp0fqbjn30c4y3v3vwqj41gfh99jx30bwlmpgfax";
};
in buildPythonPackage rec {
inherit version;
pname = "buildsrht";

src = fetchgit {
url = "https://git.sr.ht/~sircmpwn/builds.sr.ht";
rev = version;
sha256 = "002pcj2a98gbmv77a10449w1q6iqhqjz4fim8hm4qm7vn6bwp0hz";
};

patches = [
./use-srht-path.patch
];

nativeBuildInputs = srht.nativeBuildInputs;

propagatedBuildInputs = [
srht
redis
celery
pyyaml
markdown
];

preBuild = ''
export PKGVER=${version}
export SRHT_PATH=${srht}/${python.sitePackages}/srht
'';

postInstall = ''
mkdir -p $out/lib
mkdir -p $out/bin/builds.sr.ht
cp -r images $out/lib
cp contrib/submit_image_build $out/bin/builds.sr.ht
cp ${buildWorker "${src}/worker"}/bin/worker $out/bin/builds.sr.ht-worker
'';

meta = with stdenv.lib; {
homepage = https://git.sr.ht/~sircmpwn/builds.sr.ht;
description = "Continuous integration service for the sr.ht network";
license = licenses.agpl3;
maintainers = with maintainers; [ eadwu ];
};
}
@@ -0,0 +1,80 @@
{ stdenv, fetchgit, fetchNodeModules, buildPythonPackage
, pgpy, flask, bleach, misaka, humanize, markdown, psycopg2, pygments, requests
, sqlalchemy, flask_login, beautifulsoup4, sqlalchemy-utils, celery, alembic
, sassc, nodejs-11_x
, writeText }:

buildPythonPackage rec {
pname = "srht";
version = "0.52.13";

src = fetchgit {
url = "https://git.sr.ht/~sircmpwn/core.sr.ht";
rev = version;
sha256 = "0i7gd2rkq4y4lffxsgb3mql9ddmk3vqckan29w266imrqs6p8c0z";
};

node_modules = fetchNodeModules {
src = "${src}/srht";
nodejs = nodejs-11_x;
sha256 = "0axl50swhcw8llq8z2icwr4nkr5qsw2riih0a040f9wx4xiw4p6p";
};

patches = [
./disable-npm-install.patch
];

nativeBuildInputs = [
sassc
nodejs-11_x
];

propagatedBuildInputs = [
pgpy
flask
bleach
misaka
humanize
markdown
psycopg2
pygments
requests
sqlalchemy
flask_login
beautifulsoup4
sqlalchemy-utils

# Unofficial runtime dependencies?
celery
alembic
];

PKGVER = version;

preBuild = ''
cp -r ${node_modules} srht/node_modules
'';

# No actual? tests but seems like it needs this anyway
preCheck = let
config = writeText "config.ini" ''
[webhooks]
private-key=K6JupPpnr0HnBjelKTQUSm3Ro9SgzEA2T2Zv472OvzI=
[meta.sr.ht]
origin=http://meta.sr.ht.local
'';
in ''
# Validation needs config option(s)
# webhooks <- ( private-key )
# meta.sr.ht <- ( origin )
cp ${config} config.ini
This conversation was marked as resolved by eadwu

This comment has been minimized.

Copy link
@tomberek

tomberek Feb 10, 2019

Contributor

Does this override the ability to customize "origin=" settings?

This comment has been minimized.

Copy link
@tomberek

tomberek Feb 10, 2019

Contributor

For example. Login/Register links seem to be broken.

This comment has been minimized.

Copy link
@eadwu

eadwu Feb 10, 2019

Author Contributor

Not really someone who actively uses Python, but looking at the code [1], there is a possibility that the local config.ini overrides the global configuration. However, I don't see any config.inis (find -name '*.ini') in the output derivation so I believe it shouldn't matter.

The login/register links in meta.sr.ht work fine for me, however, there is a "broken" link that leads to sr.ht instead of /login

[1] https://git.sr.ht/~sircmpwn/core.sr.ht/tree/master/srht/config.py#L12

This comment has been minimized.

Copy link
@tomberek

tomberek Feb 10, 2019

Contributor

I think I was able to resolve this with service.srht.*.domain settings.

'';

meta = with stdenv.lib; {
homepage = https://git.sr.ht/~sircmpwn/srht;
description = "Core modules for sr.ht";
license = licenses.bsd3;
maintainers = with maintainers; [ eadwu ];
};
}
@@ -0,0 +1,49 @@
{ python37, openssl_1_1
, callPackage }:

# To expose the *srht modules, they have to be a python module so we use `buildPythonModule`
# Then we expose them through all-packages.nix as an application through `toPythonApplication`
# https://github.com/NixOS/nixpkgs/pull/54425#discussion_r250688781

let
fetchNodeModules = callPackage ../../networking/instant-messengers/rambox/fetchNodeModules.nix { };

python = python37.override {
packageOverrides = self: super: {
srht = self.callPackage ./core.nix { inherit fetchNodeModules; };

buildsrht = self.callPackage ./builds.nix { };
dispatchsrht = self.callPackage ./dispatch.nix { };
gitsrht = self.callPackage ./git.nix { };
hgsrht = self.callPackage ./hg.nix { };
listssrht = self.callPackage ./lists.nix { };
mansrht = self.callPackage ./man.nix { };
metasrht = self.callPackage ./meta.nix { };
pastesrht = self.callPackage ./paste.nix { };
todosrht = self.callPackage ./todo.nix { };

scmsrht = self.callPackage ./scm.nix { };

# OVERRIDES

cryptography = super.cryptography.override {
openssl = openssl_1_1;
};

pyopenssl = super.pyopenssl.override {
openssl = openssl_1_1;

This comment has been minimized.

Copy link
@eadwu

eadwu Apr 20, 2019

Author Contributor

Don't know whether or not this (and the one above) should be handled on python-packages.nix.

};
};
};
in with python.pkgs; {
inherit python;
buildsrht = toPythonApplication buildsrht;
dispatchsrht = toPythonApplication dispatchsrht;
gitsrht = toPythonApplication gitsrht;
hgsrht = toPythonApplication hgsrht;
listssrht = toPythonApplication listssrht;
mansrht = toPythonApplication mansrht;
metasrht = toPythonApplication metasrht;
pastesrht = toPythonApplication pastesrht;
todosrht = toPythonApplication todosrht;
}
@@ -0,0 +1,14 @@
diff --git a/setup.py b/setup.py
index d63bac8..e1d0c35 100755
--- a/setup.py
+++ b/setup.py
@@ -5,9 +5,6 @@ import glob
import os
import sys

-if subprocess.call(["npm", "i"], cwd="srht") != 0:
- sys.exit(1)
-
ver = os.environ.get("PKGVER") or subprocess.run(['git', 'describe', '--tags'],
stdout=subprocess.PIPE).stdout.decode().strip()

@@ -0,0 +1,39 @@
{ stdenv, fetchgit, buildPythonPackage
, python
, srht, pyyaml, PyGithub, cryptography }:

buildPythonPackage rec {
pname = "dispatchsrht";
version = "0.11.0";

src = fetchgit {
url = "https://git.sr.ht/~sircmpwn/dispatch.sr.ht";
rev = version;
sha256 = "1kahl2gy5a5li79djwkzkglkw2s7pl4d29bzqp8c53r0xvx4sqkz";
};

patches = [
./use-srht-path.patch
];

nativeBuildInputs = srht.nativeBuildInputs;

propagatedBuildInputs = [
srht
pyyaml
PyGithub
cryptography
];

preBuild = ''
export PKGVER=${version}
export SRHT_PATH=${srht}/${python.sitePackages}/srht
'';

meta = with stdenv.lib; {
homepage = https://dispatch.sr.ht/~sircmpwn/dispatch.sr.ht;
description = "Task dispatcher and service integration tool for the sr.ht network";
license = licenses.agpl3;
maintainers = with maintainers; [ eadwu ];
};
}
@@ -0,0 +1,55 @@
{ stdenv, fetchgit, buildPythonPackage
, python
, buildGoModule
, srht, pygit2, scmsrht }:

let
version = "0.32.3";

buildDispatcher = src: buildGoModule {
inherit src version;
pname = "git-sr-ht-dispatcher";
goPackagePath = "git.sr.ht/~sircmpwn/git.sr.ht/gitsrht-dispatch";

modSha256 = "1lmgmlin460g09dph2hw6yz25d4agqwjhrjv0qqsis7df9qpf3i1";
};
in buildPythonPackage rec {
inherit version;
pname = "gitsrht";

src = fetchgit {
url = "https://git.sr.ht/~sircmpwn/git.sr.ht";
rev = version;
sha256 = "0grycmblhm9dnhcf1kcmn6bclgb9znahk2026dan58m9j9pja5vw";
};

patches = [
./use-srht-path.patch
];

nativeBuildInputs = srht.nativeBuildInputs;

propagatedBuildInputs = [
srht
pygit2
scmsrht
];

preBuild = ''
export PKGVER=${version}
export SRHT_PATH=${srht}/${python.sitePackages}/srht
'';

# TODO: Remove redundant mkdir?
postInstall = ''
mkdir -p $out/bin
cp ${buildDispatcher "${src}/gitsrht-dispatch"}/bin/gitsrht-dispatch $out/bin/gitsrht-dispatch
'';

meta = with stdenv.lib; {
homepage = https://git.sr.ht/~sircmpwn/git.sr.ht;
description = "Git repository hosting service for the sr.ht network";
license = licenses.agpl3;
maintainers = with maintainers; [ eadwu ];
};
}
@@ -0,0 +1,39 @@
{ stdenv, fetchhg, buildPythonPackage
, python
, srht, hglib, scmsrht, unidiff }:

buildPythonPackage rec {
pname = "hgsrht";
version = "0.13.0";

src = fetchhg {
url = "https://hg.sr.ht/~sircmpwn/hg.sr.ht";
rev = version;
sha256 = "0qkknvja0pyk69fvzqafj3x8hi5miw22nmksvifbrjcqph8jknqg";
};

patches = [
./use-srht-path.patch
];

nativeBuildInputs = srht.nativeBuildInputs;

propagatedBuildInputs = [
srht
hglib
scmsrht
unidiff
];

preBuild = ''
export PKGVER=${version}
export SRHT_PATH=${srht}/${python.sitePackages}/srht
'';

meta = with stdenv.lib; {
homepage = https://git.sr.ht/~sircmpwn/hg.sr.ht;
description = "Mercurial repository hosting service for the sr.ht network";
license = licenses.agpl3;
maintainers = with maintainers; [ eadwu ];
};
}
@@ -0,0 +1,40 @@
{ stdenv, fetchgit, buildPythonPackage
, python
, srht, asyncpg, unidiff, aiosmtpd, emailthreads }:

buildPythonPackage rec {
pname = "listssrht";
version = "0.36.3";

src = fetchgit {
url = "https://git.sr.ht/~sircmpwn/lists.sr.ht";
rev = version;
sha256 = "1q2z2pjwz4zifsrkxab9b9jh1vzayjqych1cx3i4859f1swl2gwa";
};

patches = [
./use-srht-path.patch
];

nativeBuildInputs = srht.nativeBuildInputs;

propagatedBuildInputs = [
srht
asyncpg
unidiff
aiosmtpd
emailthreads
];

preBuild = ''
export PKGVER=${version}
export SRHT_PATH=${srht}/${python.sitePackages}/srht
'';

meta = with stdenv.lib; {
homepage = https://git.sr.ht/~sircmpwn/lists.sr.ht;
description = "Mailing list service for the sr.ht network";
license = licenses.agpl3;
maintainers = with maintainers; [ eadwu ];
};
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.