Index: config.lua ================================================================== --- config.lua +++ config.lua @@ -78,11 +78,14 @@ 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 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') @@ -89,13 +92,13 @@ 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.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'} Index: default.nix ================================================================== --- default.nix +++ default.nix @@ -1,14 +1,18 @@ let pkg = import {}; in {stdenv ? pkg.stdenv, fetchFromGitHub ? pkg.fetchFromGitHub, - terra ? pkg.terra-modern, + terra ? pkg.terra, pkgconfig ? pkg.pkgconfig, json_c ? pkg.json_c, postgresql ? pkg.postgresql.lib, mbedtls ? pkg.mbedtls, - mongoose ? null + 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"; @@ -19,27 +23,41 @@ 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 "libpq"} = "${postgresql}"; ${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 = ""; + 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 ''; - installPhase = '' - make prefix=$prefix install - ''; + # postInstall = '' + # make prefix=$out install + # ''; meta = { description = "lightweight fediverse server"; homepage = https://c.hale.su/parsav; - license = stdenv.lib.licenses.agpl3; - platforms = stdenv.lib.platforms.unix; + license = lib.licenses.agpl3; + platforms = lib.platforms.unix; }; } Index: dist/BSDmakefile ================================================================== --- dist/BSDmakefile +++ dist/BSDmakefile @@ -1,15 +1,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 +# .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 Index: dist/GNUmakefile ================================================================== --- dist/GNUmakefile +++ dist/GNUmakefile @@ -5,15 +5,15 @@ distro = nix endif ifndef runtime ifeq ($(distro),nix) - rt-pfx = $(shell nix path-info nixos.glibc)/lib + 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 Index: makefile ================================================================== --- makefile +++ makefile @@ -1,13 +1,19 @@ 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) @@ -25,13 +31,13 @@ sassc -t compressed $< $@ clean: rm parsav parsav.o $(images) $(styles) -install: parsav +install: parsav parsavd mkdir $(prefix)/bin - cp $< $(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 Index: pkgdata.lua ================================================================== --- pkgdata.lua +++ pkgdata.lua @@ -4,35 +4,39 @@ return { mbedtls = { libs = {'mbedtls', 'mbedcrypto', 'mbedx509'}; osvars = { linux_nixos = { -- lacks a *.pc on nixos systems - prefix = sthunk('nix', 'path-info', 'nixos.mbedtls'); + -- 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 = sthunk('nix', 'path-info', 'nixos.postgresql.lib'); - incdir = function() - local a = {'nix', 'path-info', 'nixos.postgresql'} - return (util.exec(a)) .. '/include'; - end; + 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 = sthunk('nix', 'path-info', 'nixos.glibc'); + prefix = os.getenv("parsav_pkg_glibc_prefix"); + -- prefix = sthunk('nix', 'path-info', 'nixos.glibc'); override = 'glibc'; }; } }; }