move src out of srv, clean up default.nix and Makefile

This commit is contained in:
Brian Picciano 2022-09-13 12:56:08 +02:00
parent 5485984e05
commit 4f01edb923
427 changed files with 59 additions and 83 deletions

View File

@ -1,22 +1,22 @@
CONFIG = ./config.nix CONFIG = ./config.nix
BASH = $$(nix-build --no-out-link -A pkgs.bash)/bin/bash
entrypoint: entrypoint:
nix-build -A entrypoint \ nix-build -A entrypoint --arg config '(import ${CONFIG})'
--arg config '(import ${CONFIG})'
install: install-systemd:
$$(nix-build -A install --arg config '(import ${CONFIG})') $$(nix-build --no-out-link -A install --arg config '(import ${CONFIG})')
test: test:
$$(nix-build --no-out-link -A pkgs.bash)/bin/bash srv-dev-env.sh \ ${BASH} tmp-dev-env.sh \
--run "cd srv/src && go test ./... -count=1 -tags integration" --run "cd src; go test ./... -count=1 -tags integration"
@echo "\nTESTS PASSED!\n"
srv.dev-shell: shell:
$$(nix-build --no-out-link -A pkgs.bash)/bin/bash srv-dev-env.sh \ ${BASH} tmp-dev-env.sh \
--command "cd srv/src; return" --command " \
cd src; \
srv.shell: echo 'Loading test data...'; \
nix-shell -A srv.shellWithBuild --arg config '(import ${CONFIG})' \ (cd cmd/load-test-data && go run main.go); \
--command 'cd srv/src; return' return; \
"

View File

@ -1,6 +1,6 @@
{ {
pkgsArg ? import (fetchTarball { pkgs ? import (fetchTarball {
name = "nixpkgs-21-05"; name = "nixpkgs-21-05";
url = "https://github.com/NixOS/nixpkgs/archive/7e9b0dff974c89e070da1ad85713ff3c20b0ca97.tar.gz"; url = "https://github.com/NixOS/nixpkgs/archive/7e9b0dff974c89e070da1ad85713ff3c20b0ca97.tar.gz";
sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36"; sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
@ -10,24 +10,60 @@
}: rec { }: rec {
pkgs = pkgsArg; inherit pkgs;
srv = pkgs.callPackage (import ./srv) { init = pkgs.writeText "mediocre-blog-init" ''
inherit config;
export MEDIOCRE_BLOG_DATA_DIR="${config.dataDir}"
# mailing list
export MEDIOCRE_BLOG_ML_SMTP_ADDR="${config.mlSMTPAddr}"
export MEDIOCRE_BLOG_ML_SMTP_AUTH="${config.mlSMTPAuth}"
export MEDIOCRE_BLOG_ML_PUBLIC_URL="${config.publicURL}"
# pow
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
# http
export MEDIOCRE_BLOG_HTTP_PUBLIC_URL="${config.publicURL}"
export MEDIOCRE_BLOG_HTTP_LISTEN_PROTO="${config.httpListenProto}"
export MEDIOCRE_BLOG_HTTP_LISTEN_ADDR="${config.httpListenAddr}"
export MEDIOCRE_BLOG_HTTP_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT='${config.httpAuthRatelimit}'
'';
bin = pkgs.buildGoModule {
pname = "mediocre-blog";
version = "dev";
src = ./src;
vendorSha256 = "sha256:1vazrrg8rs9n8x40c9r53h9qnyxw59xkp0aq7jl15fliigk6q0cr";
subPackages = [ "cmd/mediocre-blog" ];
# disable tests
checkPhase = '''';
}; };
entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" '' entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''
#!/bin/sh #!${pkgs.bash}/bin/bash
set -e set -e
source ${init}
mkdir -p ${config.runDir} mkdir -p ${config.runDir}
mkdir -p ${config.dataDir} mkdir -p ${config.dataDir}
exec ${srv.bin} exec ${bin}/bin/mediocre-blog "$@"
''; '';
shell = pkgs.stdenv.mkDerivation {
name = "mediocre-blog-shell";
buildInputs = [ pkgs.go pkgs.sqlite ];
shellHook = ''
source ${init}
'';
};
service = pkgs.writeText "mediocre-blog" '' service = pkgs.writeText "mediocre-blog" ''
[Unit] [Unit]
Description=mediocregopher mediocre blog Description=mediocregopher mediocre blog

View File

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Some files were not shown because too many files have changed in this diff Show More