parsav  Check-in [8648683aba]

Overview
Comment:fixes to make parsav build on modern nix
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8648683abaa4ba3c66f930236138b3ef2379a94fb996cfcb88c134922a290604
User & Date: lexi on 2022-11-04 04:27:15
Other Links: manifest | tags
Context
2022-11-04
12:45
begin steps to port parsav to mbedtls3 and modern nix. also? fuck mbedtls with a fucking jackhammer i am never using it again holy fuck check-in: e7e16156a6 user: lexi tags: trunk
04:27
fixes to make parsav build on modern nix check-in: 8648683aba user: lexi tags: trunk
02:44
updates check-in: 2fef9385da user: lexi tags: trunk
Changes

Modified config.lua from [52297260cd] to [6ab8d1127e].

76
77
78
79
80
81
82



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
		-- as is realistically possible.
	};
	default_ui_accent = tonumber(default('parsav_ui_default_accent',323));
}
if os.getenv('parsav_let_me_be_an_idiot') == "i know what i'm doing" then
	conf.braingeniousmode = true -- SOUND GENERAL QUARTERS
end



if u.ping '.fslckout' or u.ping '_FOSSIL_' then
	if u.ping '_FOSSIL_' then default_os = 'windows' end
	conf.build.branch = u.exec { 'fossil', 'branch', 'current' }
	conf.build.checkout = (u.exec { 'fossil', 'sql',
		[[select value from localdb.vvar where name = 'checkout-hash']]
	}):gsub("^'(.*)'$", '%1')
end
conf.os    = default('parsav_host_os', default_os)
conf.tgtos = default('parsav_target_os', default_os)
conf.posix = posixes[conf.os]
conf.exe   = u.tobool(default('parsav_link',not conf.tgttrip)) -- turn off for partial builds
conf.prefix_conf = default('parsav_install_prefix_cfg', conf.prefix)
conf.prefix_bin = default('parsav_install_prefix_cfg', conf.prefix)
conf.prefix_static = default('parsav_install_prefix_static', nil)
conf.build.origin = coalesce(
	os.getenv('parsav_builder'),
	string.format('%s@%s', coalesce (
		os.getenv('USER'),
		u.exec{'whoami'}
	), u.exec{'hostname'}) -- whoami and hostname are present on both windows & unix
)







>
>
>
|










|
|
|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
		-- as is realistically possible.
	};
	default_ui_accent = tonumber(default('parsav_ui_default_accent',323));
}
if os.getenv('parsav_let_me_be_an_idiot') == "i know what i'm doing" then
	conf.braingeniousmode = true -- SOUND GENERAL QUARTERS
end
if os.getenv 'parsav_build_branch' then
	conf.build.branch = os.getenv 'parsav_build_branch' 
	conf.build.checkout = os.getenv 'parsav_build_checkout' 
elseif u.ping '.fslckout' or u.ping '_FOSSIL_' then
	if u.ping '_FOSSIL_' then default_os = 'windows' end
	conf.build.branch = u.exec { 'fossil', 'branch', 'current' }
	conf.build.checkout = (u.exec { 'fossil', 'sql',
		[[select value from localdb.vvar where name = 'checkout-hash']]
	}):gsub("^'(.*)'$", '%1')
end
conf.os    = default('parsav_host_os', default_os)
conf.tgtos = default('parsav_target_os', default_os)
conf.posix = posixes[conf.os]
conf.exe   = u.tobool(default('parsav_link',not conf.tgttrip)) -- turn off for partial builds
conf.prefix_conf = default('parsav_install_prefix_cfg', conf.prefix .. "/etc/parsav")
conf.prefix_bin = default('parsav_install_prefix_bin', conf.prefix .. "/bin")
conf.prefix_static = default('parsav_install_prefix_static', conf.prefix_conf .. "/static")
conf.build.origin = coalesce(
	os.getenv('parsav_builder'),
	string.format('%s@%s', coalesce (
		os.getenv('USER'),
		u.exec{'whoami'}
	), u.exec{'hostname'}) -- whoami and hostname are present on both windows & unix
)

Modified default.nix from [69636ff762] to [e620433c36].

1
2
3
4
5
6
7
8



9

10
11
12
13
14
15
16
..
17
18
19
20
21
22
23

24
25
26
27
28














29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
let pkg = import <nixpkgs> {};
in {stdenv          ? pkg.stdenv,
	fetchFromGitHub ? pkg.fetchFromGitHub,
	terra           ? pkg.terra-modern,
	pkgconfig       ? pkg.pkgconfig,
	json_c          ? pkg.json_c,
	postgresql      ? pkg.postgresql.lib,
	mbedtls         ? pkg.mbedtls,



	mongoose        ? null

}:
let mgsrc = if mongoose != null then mongoose
			else fetchFromGitHub {
				owner = "cesanta";
				repo = "mongoose";
				rev = "369f44adfa38e0d8fa9667e9d6bafd7e0e3c6231";
				sha256 = "17rkd7ydic39cw9sfh11mcil02vmi6jjyj2ncbxan6psak09xbrc";
................................................................................
			};
	pkv = val: p: "parsav_pkg_${p}_${val}";
	pkp = pkv "prefix";
in stdenv.mkDerivation {
	name = "parsav";
	version = "dev";
	nativeBuildInputs = [terra json_c pkgconfig mbedtls];

	src = ./.;

	${pkp "json-c"} = "${json_c}";
	${pkp "libpq"} = "${postgresql}";
	${pkp "mbedtls"} = "${mbedtls}";















	parsav_target_os = "linux";
	parsav_dist = "nixos";
	configurePhase = ''
		cp -r ${mgsrc} lib/mongoose
	'';
	installPhase = ''
		make prefix=$prefix install
	'';
	
	meta = {
		description = "lightweight fediverse server";
		homepage = https://c.hale.su/parsav;
		license = stdenv.lib.licenses.agpl3;
		platforms = stdenv.lib.platforms.unix;
	};
} 



|




>
>
>
|
>







 







>



<

>
>
>
>
>
>
>
>
>
>
>
>
>
>






|
|
|




|
|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
21
22
23
24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
let pkg = import <nixpkgs> {};
in {stdenv          ? pkg.stdenv,
	fetchFromGitHub ? pkg.fetchFromGitHub,
	terra           ? pkg.terra,
	pkgconfig       ? pkg.pkgconfig,
	json_c          ? pkg.json_c,
	postgresql      ? pkg.postgresql.lib,
	mbedtls         ? pkg.mbedtls,
	glibc           ? pkg.glibc,
	cmark           ? pkg.cmark,
	inkscape        ? pkg.inkscape,
	mongoose        ? null,
	lib             ? pkg.lib
}:
let mgsrc = if mongoose != null then mongoose
			else fetchFromGitHub {
				owner = "cesanta";
				repo = "mongoose";
				rev = "369f44adfa38e0d8fa9667e9d6bafd7e0e3c6231";
				sha256 = "17rkd7ydic39cw9sfh11mcil02vmi6jjyj2ncbxan6psak09xbrc";
................................................................................
			};
	pkv = val: p: "parsav_pkg_${p}_${val}";
	pkp = pkv "prefix";
in stdenv.mkDerivation {
	name = "parsav";
	version = "dev";
	nativeBuildInputs = [terra json_c pkgconfig mbedtls];
	buildInputs = [cmark inkscape postgresql postgresql.lib];
	src = ./.;

	${pkp "json-c"} = "${json_c}";

	${pkp "mbedtls"} = "${mbedtls}";
	${pkp "libc"} = "${glibc.out}";
	${pkp "cmark"} = "${cmark}";
	${pkp "inkscape"} = "${inkscape}";
	${pkv "incdir" "libpq"} = "${postgresql.out}/include";
	${pkv "libdir" "libpq"} = "${postgresql.lib}/lib";

	parsav_build_branch = "trunk";
	parsav_build_checkout = "<latest>";
	parsav_builder = "nixpkgs";

	parsav_install_prefix_cfg="/etc/parsav";
	preBuild = ''
		export parsav_install_prefix="$out"
	'';

	parsav_target_os = "linux";
	parsav_dist = "nixos";
	configurePhase = ''
		cp -r ${mgsrc} lib/mongoose
	'';
	# postInstall = ''
	# 	make prefix=$out install
	# '';
	
	meta = {
		description = "lightweight fediverse server";
		homepage = https://c.hale.su/parsav;
		license = lib.licenses.agpl3;
		platforms = lib.platforms.unix;
	};
} 

Modified dist/BSDmakefile from [7f20717fa4] to [38a172298b].

1
2
3
4
5
6

7
8
9
10
11
12
13
14
15
# being extremely paranoid here, but there's some vague plans to get nix
# shit working under BSD kernels, so we may as well future-proof the thing
.if defined(NIX_STORE) || defined(NIX_PATH)
    l-glibc-path != nix path-info nixos.glibc
	rt-path = $(l-glibc-path)/lib
.endif


rt-path ?= /usr/lib
runtime = $(rt-path)/crt1.o \
		  $(rt-path)/crti.o \
		  $(rt-path)/crtbegin.o \
		  $(rt-path)/crtend.o \
		  $(rt-path)/crtn.o

.include <makefile>


|
|
|
|
>









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# being extremely paranoid here, but there's some vague plans to get nix
# shit working under BSD kernels, so we may as well future-proof the thing
# .if defined(NIX_STORE) || defined(NIX_PATH)
#     l-glibc-path != nix path-info nixos.glibc
# 	rt-path = $(l-glibc-path)/lib
# .endif
# hahaaaa they broke nix path-info

rt-path ?= /usr/lib
runtime = $(rt-path)/crt1.o \
		  $(rt-path)/crti.o \
		  $(rt-path)/crtbegin.o \
		  $(rt-path)/crtend.o \
		  $(rt-path)/crtn.o

.include <makefile>

Modified dist/GNUmakefile from [1a1f87c1d5] to [cd86389034].

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
else ifndef NIX_PATH
else
    distro = nix
endif

ifndef runtime
    ifeq ($(distro),nix)
        rt-pfx = $(shell nix path-info nixos.glibc)/lib
    else ifeq ($(shell test -e /usr/local/lib/crt1.o; echo $$?),0)
        rt-pfx = /usr/local/lib
    else ifeq ($(shell test -e /lib/crt1.o; echo $$?),0)
        rt-pfx = /lib
    endif
	runtime = $(rt-pfx)/crt1.o $(rt-pfx)/crti.o $(rt-pfx)/crtn.o
endif

include makefile







|









3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
else ifndef NIX_PATH
else
    distro = nix
endif

ifndef runtime
    ifeq ($(distro),nix)
        rt-pfx = $(inputPath-libc)/lib
    else ifeq ($(shell test -e /usr/local/lib/crt1.o; echo $$?),0)
        rt-pfx = /usr/local/lib
    else ifeq ($(shell test -e /lib/crt1.o; echo $$?),0)
        rt-pfx = /lib
    endif
	runtime = $(rt-pfx)/crt1.o $(rt-pfx)/crti.o $(rt-pfx)/crtn.o
endif

include makefile

Modified makefile from [6c573878b0] to [21260c66fc].

1
2
3
4



5
6
7
8



9
10
11
12
13
14
15
..
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
version = dev
dl = git
dbg-flags = $(if $(dbg),-g)




images = static/default-avatar.webp static/query.webp static/heart.webp static/retweet.webp static/reply.webp static/file.webp static/follow.webp
#$(addsuffix .webp, $(basename $(wildcard static/*.svg)))
styles = $(addsuffix .css, $(basename $(wildcard static/*.scss)))




parsav parsavd: parsav.t config.lua pkgdata.lua $(images) $(styles)
	terra $(dbg-flags) $<
parsav.o parsavd.o: parsav.t config.lua pkgdata.lua $(images) $(styles)
	env parsav_link=no terra $(dbg-flags) $<
parsav.ll parsavd.ll: parsav.t config.lua pkgdata.lua $(images) $(styles)
	env parsav_emit_type=ll parsav_link=no terra $(dbg-flags) $<
parsav.s parsavd.ss: parsav.ll
................................................................................
	inkscape -f $< -C -d 180 -e $@
static/%.css: static/%.scss
	sassc -t compressed $< $@

clean:
	rm parsav parsav.o $(images) $(styles)

install: parsav
	mkdir $(prefix)/bin
	cp $< $(prefix)/bin/

dep: dep.mbedtls dep.mongoose dep.mjson
dep.mbedtls: lib/mbedtls/library/libmbedtls.a \
	lib/mbedtls/library/libmbedcrypto.a \
	lib/mbedtls/library/libmbedx509.a
dep.mongoose: lib/mongoose/libmongoose.a
dep.mjson: lib/mjson/libmjson.a




>
>
>




>
>
>







 







|

|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
version = dev
dl = git
dbg-flags = $(if $(dbg),-g)

# for nix
prefix = ${out}

images = static/default-avatar.webp static/query.webp static/heart.webp static/retweet.webp static/reply.webp static/file.webp static/follow.webp
#$(addsuffix .webp, $(basename $(wildcard static/*.svg)))
styles = $(addsuffix .css, $(basename $(wildcard static/*.scss)))

# .PHONY: all
# all: parsav parsavd

parsav parsavd: parsav.t config.lua pkgdata.lua $(images) $(styles)
	terra $(dbg-flags) $<
parsav.o parsavd.o: parsav.t config.lua pkgdata.lua $(images) $(styles)
	env parsav_link=no terra $(dbg-flags) $<
parsav.ll parsavd.ll: parsav.t config.lua pkgdata.lua $(images) $(styles)
	env parsav_emit_type=ll parsav_link=no terra $(dbg-flags) $<
parsav.s parsavd.ss: parsav.ll
................................................................................
	inkscape -f $< -C -d 180 -e $@
static/%.css: static/%.scss
	sassc -t compressed $< $@

clean:
	rm parsav parsav.o $(images) $(styles)

install: parsav parsavd
	mkdir $(prefix)/bin
	cp $^ $(prefix)/bin/

dep: dep.mbedtls dep.mongoose dep.mjson
dep.mbedtls: lib/mbedtls/library/libmbedtls.a \
	lib/mbedtls/library/libmbedcrypto.a \
	lib/mbedtls/library/libmbedx509.a
dep.mongoose: lib/mongoose/libmongoose.a
dep.mjson: lib/mjson/libmjson.a

Modified pkgdata.lua from [dbac8681c6] to [0f9c69d77b].

2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18


19
20
21
22
23
24
25
26
27
28
29
30
31
32

33
34
35
36
37
38
local sthunk = function(...) local a = {...} return function() return util.exec(a) end end

return {
	mbedtls = { 
		libs = {'mbedtls', 'mbedcrypto', 'mbedx509'};
		osvars = {
			linux_nixos = { -- lacks a *.pc on nixos systems
				prefix = sthunk('nix', 'path-info', 'nixos.mbedtls');

			}
		};
		vars = { builddir = '/library', srcincdir = '/include' };
	};
	mongoose = { vars = { builddir = '' } };
	mjson = { vars = { builddir = '', srcincdir = '/src' } };
	libpq = {
		osvars = {
			linux_nixos = {


				prefix = sthunk('nix', 'path-info', 'nixos.postgresql.lib');
				incdir = function()
					local a = {'nix', 'path-info', 'nixos.postgresql'}
					return (util.exec(a)) .. '/include';
				end;
			};
		};
		vars = {pcname = 'postgresql';}
	};
	libc = {
		libs = {'c'}; -- libc.so probably does not need explicit mention, but
		osvars = {
			linux = { override = 'glibc'; };
			linux_nixos = {

				prefix = sthunk('nix', 'path-info', 'nixos.glibc');
				override = 'glibc';
			};
		}
	};
}







|
>









>
>
|
|
|
|
|









>
|





2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
local sthunk = function(...) local a = {...} return function() return util.exec(a) end end

return {
	mbedtls = { 
		libs = {'mbedtls', 'mbedcrypto', 'mbedx509'};
		osvars = {
			linux_nixos = { -- lacks a *.pc on nixos systems
				-- prefix = sthunk('nix', 'path-info', 'nixos.mbedtls');
				prefix = os.getenv("parsav_pkg_mbedtls_prefix");
			}
		};
		vars = { builddir = '/library', srcincdir = '/include' };
	};
	mongoose = { vars = { builddir = '' } };
	mjson = { vars = { builddir = '', srcincdir = '/src' } };
	libpq = {
		osvars = {
			linux_nixos = {
				prefix = os.getenv("parsav_pkg_libpq_libdir");
				incdir = os.getenv("parsav_pkg_libpq_incdir");
				-- prefix = sthunk('nix', 'path-info', 'nixos.postgresql.lib');
				-- incdir = function()
				-- 	local a = {'nix', 'path-info', 'nixos.postgresql'}
				-- 	return (util.exec(a)) .. '/include';
				-- end;
			};
		};
		vars = {pcname = 'postgresql';}
	};
	libc = {
		libs = {'c'}; -- libc.so probably does not need explicit mention, but
		osvars = {
			linux = { override = 'glibc'; };
			linux_nixos = {
				prefix = os.getenv("parsav_pkg_glibc_prefix");
				-- prefix = sthunk('nix', 'path-info', 'nixos.glibc');
				override = 'glibc';
			};
		}
	};
}