summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2021-11-07 14:31:25 +0100
committermakefu <github@syntax-fehler.de>2021-11-07 14:31:25 +0100
commit597f546e9833b2569ee6ec540f688f7fb95bd26c (patch)
treee7393bb0aea4faee24e85e63d82843bd3b9a0bac /tv
parent9392c355ad5198346313ef0972db1910c10d17bf (diff)
parent0e668121a1388914f33a6546c2f63adc212a38c4 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'tv')
-rw-r--r--tv/2configs/elm-packages-proxy.nix107
-rw-r--r--tv/2configs/gitrepos.nix3
-rw-r--r--tv/5pkgs/haskell/mailaids.nix4
-rw-r--r--tv/5pkgs/haskell/th-env/default.nix4
4 files changed, 113 insertions, 5 deletions
diff --git a/tv/2configs/elm-packages-proxy.nix b/tv/2configs/elm-packages-proxy.nix
index 097d706c6..caea18802 100644
--- a/tv/2configs/elm-packages-proxy.nix
+++ b/tv/2configs/elm-packages-proxy.nix
@@ -60,6 +60,11 @@ in {
proxy_pass $new_uri;
'';
+
+ locations."/search.json".extraConfig = ''
+ proxy_pass http://127.0.0.1:${toString config.krebs.htgen.elm-packages-proxy.port};
+ proxy_pass_header Server;
+ '';
};
krebs.htgen.elm-packages-proxy = {
@@ -192,6 +197,36 @@ in {
exit
;;
+ 'DELETE /packages/'*)
+
+ author=$req_x_author
+ pname=$req_x_package
+ user=$req_x_user
+ version=$req_x_version
+
+ zipball=${cfg.packageDir}/$author/$pname/$version/zipball
+ elmjson=$HOME/cache/$author%2F$pname%2F$version%2Felm.json
+ endpointjson=$HOME/cache/$author%2F$pname%2F$version%2Fendpoint.json
+
+ if test -e "$zipball"; then
+ zipball_owner=$(attr -q -g X-User "$zipball" || :)
+ if test "$zipball_owner" = "$req_x_user"; then
+ echo "user $user is deleting package $author/$pname@$version" >&2
+ rm -f "$elmjson"
+ rm -f "$endpointjson"
+ rm "$zipball"
+ string_response 200 OK \
+ "package deleted: $author/$pname@$version" \
+ text/plain
+ exit
+ else
+ string_response 403 Forbidden \
+ "package already exists: $author/$pname@$version" \
+ text/plain
+ exit
+ fi
+ fi
+ ;;
'GET /all-packages'|'POST /all-packages')
response=$(mktemp -t htgen.$$.elm-packages-proxy.all-packages.XXXXXXXX)
@@ -239,7 +274,7 @@ in {
select(.!="") |
sub("^\\./(?<author>[^/]+)/(?<pname>[^/]+)/(?<version>[^/]+)$";"\(.author)/\(.pname)@\(.version)")
) |
- sort_by(split("@") | [.[0]]+(.[1]|split("."))) |
+ sort_by(split("@") | [.[0]]+(.[1]|split(".")|map(tonumber))) |
reverse
'
} |
@@ -248,6 +283,76 @@ in {
file_response 200 OK "$response" 'application/json; charset=UTF-8'
exit
;;
+ 'GET /search.json')
+
+ searchjson=$HOME/cache/search.json
+ mkdir -p "$HOME/cache"
+
+ # update cached search.json
+ (
+ last_modified=$(
+ if test -f "$searchjson"; then
+ date -Rr "$searchjson"
+ else
+ date -R -d @0
+ fi
+ )
+ tempsearchjson=$(mktemp "$searchjson.XXXXXXXX")
+ trap 'rm "$tempsearchjson" >&2' EXIT
+ curl -fsS --compressed https://package.elm-lang.org/search.json \
+ -H "If-Modified-Since: $last_modified" \
+ -o "$tempsearchjson"
+ if test -s "$tempsearchjson"; then
+ mv "$tempsearchjson" "$searchjson"
+ trap - EXIT
+ fi
+ )
+
+ response=$(mktemp -t htgen.$$.elm-packages-proxy.search.XXXXXXXX)
+ trap 'rm "$response" >&2' EXIT
+
+ {
+ printf '{"upstream":'; cat "$searchjson"
+ printf ',"private":'; (cd ${cfg.packageDir}; find -mindepth 3 -maxdepth 3) |
+ jq -Rs '
+ split("\n") |
+ map(
+ select(.!="") |
+ match("^\\./(?<author>[^/]+)/(?<pname>[^/]+)/(?<version>[^/]+)$").captures |
+ map({key:.name,value:.string}) |
+ from_entries
+ ) |
+ map({
+ key: "\(.author)/\(.pname)",
+ value: .version,
+ }) |
+ from_entries
+ '
+ printf '}'
+ } |
+ jq -c '
+ reduce .upstream[] as $upstreamItem ({ private, output: [] };
+ .private[$upstreamItem.name] as $privateItem |
+ if $privateItem then
+ .output += [$upstreamItem * { version: $privateItem.version }] |
+ .private |= del(.[$upstreamItem.name])
+ else
+ .output += [$upstreamItem]
+ end
+ ) |
+
+ .output + (.private | to_entries | sort_by(.key) | map({
+ name: .key,
+ version: .value,
+ summary: "dummy summary",
+ license: "dummy license",
+ }))
+ ' \
+ > $response
+
+ file_response 200 OK "$response" 'application/json; charset=UTF-8'
+ exit
+ ;;
esac
''}'';
};
diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix
index 1586f3b33..2b8457e40 100644
--- a/tv/2configs/gitrepos.nix
+++ b/tv/2configs/gitrepos.nix
@@ -83,6 +83,9 @@ let {
htgen = {
cgit.desc = "toy HTTP server";
};
+ ircaids = {
+ cgit.desc = "Assortment of aids for working with Internet relay chat";
+ };
krops = {
cgit.desc = "deployment tools";
};
diff --git a/tv/5pkgs/haskell/mailaids.nix b/tv/5pkgs/haskell/mailaids.nix
index b705c7c69..f152a76f4 100644
--- a/tv/5pkgs/haskell/mailaids.nix
+++ b/tv/5pkgs/haskell/mailaids.nix
@@ -1,6 +1,6 @@
{ mkDerivation, aeson, aeson-pretty, base, bytestring
, case-insensitive, fetchgit, lens, optparse-applicative
-, purebred-email, stdenv, text, vector, word8
+, purebred-email, lib, text, vector, word8
}:
mkDerivation {
pname = "mailaids";
@@ -17,5 +17,5 @@ mkDerivation {
aeson aeson-pretty base bytestring case-insensitive lens
optparse-applicative purebred-email text vector word8
];
- license = stdenv.lib.licenses.mit;
+ license = lib.licenses.mit;
}
diff --git a/tv/5pkgs/haskell/th-env/default.nix b/tv/5pkgs/haskell/th-env/default.nix
index 474a63b85..158fb165a 100644
--- a/tv/5pkgs/haskell/th-env/default.nix
+++ b/tv/5pkgs/haskell/th-env/default.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, base, stdenv, template-haskell, text }:
+{ mkDerivation, base, lib, template-haskell, text }:
mkDerivation {
pname = "th-env";
version = "1.0.0";
@@ -6,5 +6,5 @@ mkDerivation {
libraryHaskellDepends = [ base template-haskell text ];
homepage = "https://stackoverflow.com/q/57635686";
license = "unknown";
- hydraPlatforms = stdenv.lib.platforms.none;
+ hydraPlatforms = lib.platforms.none;
}