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

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

     1      1   let pkg = import <nixpkgs> {};
     2      2   in {stdenv          ? pkg.stdenv,
     3      3   	fetchFromGitHub ? pkg.fetchFromGitHub,
     4         -	terra           ? pkg.terra-modern,
            4  +	terra           ? pkg.terra,
     5      5   	pkgconfig       ? pkg.pkgconfig,
     6      6   	json_c          ? pkg.json_c,
     7      7   	postgresql      ? pkg.postgresql.lib,
     8      8   	mbedtls         ? pkg.mbedtls,
     9         -	mongoose        ? null
            9  +	glibc           ? pkg.glibc,
           10  +	cmark           ? pkg.cmark,
           11  +	inkscape        ? pkg.inkscape,
           12  +	mongoose        ? null,
           13  +	lib             ? pkg.lib
    10     14   }:
    11     15   let mgsrc = if mongoose != null then mongoose
    12     16   			else fetchFromGitHub {
    13     17   				owner = "cesanta";
    14     18   				repo = "mongoose";
    15     19   				rev = "369f44adfa38e0d8fa9667e9d6bafd7e0e3c6231";
    16     20   				sha256 = "17rkd7ydic39cw9sfh11mcil02vmi6jjyj2ncbxan6psak09xbrc";
................................................................................
    17     21   			};
    18     22   	pkv = val: p: "parsav_pkg_${p}_${val}";
    19     23   	pkp = pkv "prefix";
    20     24   in stdenv.mkDerivation {
    21     25   	name = "parsav";
    22     26   	version = "dev";
    23     27   	nativeBuildInputs = [terra json_c pkgconfig mbedtls];
           28  +	buildInputs = [cmark inkscape postgresql postgresql.lib];
    24     29   	src = ./.;
    25     30   
    26     31   	${pkp "json-c"} = "${json_c}";
    27         -	${pkp "libpq"} = "${postgresql}";
    28     32   	${pkp "mbedtls"} = "${mbedtls}";
           33  +	${pkp "libc"} = "${glibc.out}";
           34  +	${pkp "cmark"} = "${cmark}";
           35  +	${pkp "inkscape"} = "${inkscape}";
           36  +	${pkv "incdir" "libpq"} = "${postgresql.out}/include";
           37  +	${pkv "libdir" "libpq"} = "${postgresql.lib}/lib";
           38  +
           39  +	parsav_build_branch = "trunk";
           40  +	parsav_build_checkout = "<latest>";
           41  +	parsav_builder = "nixpkgs";
           42  +
           43  +	parsav_install_prefix_cfg="/etc/parsav";
           44  +	preBuild = ''
           45  +		export parsav_install_prefix="$out"
           46  +	'';
    29     47   
    30     48   	parsav_target_os = "linux";
    31     49   	parsav_dist = "nixos";
    32     50   	configurePhase = ''
    33     51   		cp -r ${mgsrc} lib/mongoose
    34     52   	'';
    35         -	installPhase = ''
    36         -		make prefix=$prefix install
    37         -	'';
           53  +	# postInstall = ''
           54  +	# 	make prefix=$out install
           55  +	# '';
    38     56   	
    39     57   	meta = {
    40     58   		description = "lightweight fediverse server";
    41     59   		homepage = https://c.hale.su/parsav;
    42         -		license = stdenv.lib.licenses.agpl3;
    43         -		platforms = stdenv.lib.platforms.unix;
           60  +		license = lib.licenses.agpl3;
           61  +		platforms = lib.platforms.unix;
    44     62   	};
    45     63   } 

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

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

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

     3      3   else ifndef NIX_PATH
     4      4   else
     5      5       distro = nix
     6      6   endif
     7      7   
     8      8   ifndef runtime
     9      9       ifeq ($(distro),nix)
    10         -        rt-pfx = $(shell nix path-info nixos.glibc)/lib
           10  +        rt-pfx = $(inputPath-libc)/lib
    11     11       else ifeq ($(shell test -e /usr/local/lib/crt1.o; echo $$?),0)
    12     12           rt-pfx = /usr/local/lib
    13     13       else ifeq ($(shell test -e /lib/crt1.o; echo $$?),0)
    14     14           rt-pfx = /lib
    15     15       endif
    16     16   	runtime = $(rt-pfx)/crt1.o $(rt-pfx)/crti.o $(rt-pfx)/crtn.o
    17     17   endif
    18     18   
    19     19   include makefile

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

     1      1   version = dev
     2      2   dl = git
     3      3   dbg-flags = $(if $(dbg),-g)
     4      4   
            5  +# for nix
            6  +prefix = ${out}
            7  +
     5      8   images = static/default-avatar.webp static/query.webp static/heart.webp static/retweet.webp static/reply.webp static/file.webp static/follow.webp
     6      9   #$(addsuffix .webp, $(basename $(wildcard static/*.svg)))
     7     10   styles = $(addsuffix .css, $(basename $(wildcard static/*.scss)))
     8     11   
           12  +# .PHONY: all
           13  +# all: parsav parsavd
           14  +
     9     15   parsav parsavd: parsav.t config.lua pkgdata.lua $(images) $(styles)
    10     16   	terra $(dbg-flags) $<
    11     17   parsav.o parsavd.o: parsav.t config.lua pkgdata.lua $(images) $(styles)
    12     18   	env parsav_link=no terra $(dbg-flags) $<
    13     19   parsav.ll parsavd.ll: parsav.t config.lua pkgdata.lua $(images) $(styles)
    14     20   	env parsav_emit_type=ll parsav_link=no terra $(dbg-flags) $<
    15     21   parsav.s parsavd.ss: parsav.ll
................................................................................
    23     29   	inkscape -f $< -C -d 180 -e $@
    24     30   static/%.css: static/%.scss
    25     31   	sassc -t compressed $< $@
    26     32   
    27     33   clean:
    28     34   	rm parsav parsav.o $(images) $(styles)
    29     35   
    30         -install: parsav
           36  +install: parsav parsavd
    31     37   	mkdir $(prefix)/bin
    32         -	cp $< $(prefix)/bin/
           38  +	cp $^ $(prefix)/bin/
    33     39   
    34     40   dep: dep.mbedtls dep.mongoose dep.mjson
    35     41   dep.mbedtls: lib/mbedtls/library/libmbedtls.a \
    36     42   	lib/mbedtls/library/libmbedcrypto.a \
    37     43   	lib/mbedtls/library/libmbedx509.a
    38     44   dep.mongoose: lib/mongoose/libmongoose.a
    39     45   dep.mjson: lib/mjson/libmjson.a

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

     2      2   local sthunk = function(...) local a = {...} return function() return util.exec(a) end end
     3      3   
     4      4   return {
     5      5   	mbedtls = { 
     6      6   		libs = {'mbedtls', 'mbedcrypto', 'mbedx509'};
     7      7   		osvars = {
     8      8   			linux_nixos = { -- lacks a *.pc on nixos systems
     9         -				prefix = sthunk('nix', 'path-info', 'nixos.mbedtls');
            9  +				-- prefix = sthunk('nix', 'path-info', 'nixos.mbedtls');
           10  +				prefix = os.getenv("parsav_pkg_mbedtls_prefix");
    10     11   			}
    11     12   		};
    12     13   		vars = { builddir = '/library', srcincdir = '/include' };
    13     14   	};
    14     15   	mongoose = { vars = { builddir = '' } };
    15     16   	mjson = { vars = { builddir = '', srcincdir = '/src' } };
    16     17   	libpq = {
    17     18   		osvars = {
    18     19   			linux_nixos = {
    19         -				prefix = sthunk('nix', 'path-info', 'nixos.postgresql.lib');
    20         -				incdir = function()
    21         -					local a = {'nix', 'path-info', 'nixos.postgresql'}
    22         -					return (util.exec(a)) .. '/include';
    23         -				end;
           20  +				prefix = os.getenv("parsav_pkg_libpq_libdir");
           21  +				incdir = os.getenv("parsav_pkg_libpq_incdir");
           22  +				-- prefix = sthunk('nix', 'path-info', 'nixos.postgresql.lib');
           23  +				-- incdir = function()
           24  +				-- 	local a = {'nix', 'path-info', 'nixos.postgresql'}
           25  +				-- 	return (util.exec(a)) .. '/include';
           26  +				-- end;
    24     27   			};
    25     28   		};
    26     29   		vars = {pcname = 'postgresql';}
    27     30   	};
    28     31   	libc = {
    29     32   		libs = {'c'}; -- libc.so probably does not need explicit mention, but
    30     33   		osvars = {
    31     34   			linux = { override = 'glibc'; };
    32     35   			linux_nixos = {
    33         -				prefix = sthunk('nix', 'path-info', 'nixos.glibc');
           36  +				prefix = os.getenv("parsav_pkg_glibc_prefix");
           37  +				-- prefix = sthunk('nix', 'path-info', 'nixos.glibc');
    34     38   				override = 'glibc';
    35     39   			};
    36     40   		}
    37     41   	};
    38     42   }