mirror of
https://github.com/urbit/shrub.git
synced 2024-12-28 14:42:53 +03:00
build: move ops debug conditional usage to drv metadata
Rather than conditional reconstructing the "urbit/bin/urbit-debug -g" string everytime using the debug conditional, this information has been added to the derivation's .meta attribute.
This commit is contained in:
parent
eaf0cfd995
commit
578adc9363
@ -1,19 +1,11 @@
|
||||
{ pkgs, tlon, deps, pier, arvo, debug }:
|
||||
|
||||
let
|
||||
|
||||
urbitExe = if debug
|
||||
then "${tlon.urbit-debug}/bin/urbit-debug -g"
|
||||
else "${tlon.urbit}/bin/urbit";
|
||||
|
||||
in
|
||||
{ pkgs, herb, urbit, pier, arvo }:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
name = "brass";
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ tlon.herb pkgs.coreutils ];
|
||||
buildInputs = [ herb pkgs.coreutils ];
|
||||
|
||||
URBIT = urbitExe;
|
||||
URBIT = ubit.meta.exe;
|
||||
PIER = pier;
|
||||
ARVO = arvo;
|
||||
}
|
||||
|
@ -2,29 +2,29 @@
|
||||
|
||||
let
|
||||
|
||||
deps = import ../deps { inherit pkgs; };
|
||||
tlon = import ../pkgs { inherit pkgs; };
|
||||
arvo = tlon.arvo;
|
||||
urbit = tlon.urbit;
|
||||
herb = tlon.herb;
|
||||
urbit = if debug then tlon.urbit-debug else tlon.urbit;
|
||||
|
||||
bootbrass = ../../bin/brass.pill;
|
||||
bootsolid = ../../bin/solid.pill;
|
||||
|
||||
rawzod = import ./fakeship {
|
||||
inherit pkgs tlon deps debug;
|
||||
inherit pkgs herb urbit;
|
||||
pill = bootsolid;
|
||||
ship = "zod";
|
||||
arvo = null;
|
||||
};
|
||||
|
||||
zod = import ./fakeship {
|
||||
inherit pkgs tlon deps arvo debug;
|
||||
inherit pkgs herb urbit arvo;
|
||||
pill = bootsolid;
|
||||
ship = "zod";
|
||||
};
|
||||
|
||||
bus = import ./fakeship {
|
||||
inherit pkgs tlon deps arvo debug;
|
||||
inherit pkgs herb urbit arvo;
|
||||
pill = bootsolid;
|
||||
ship = "bus";
|
||||
};
|
||||
@ -34,23 +34,28 @@ in
|
||||
rec {
|
||||
|
||||
test = import ./test {
|
||||
inherit pkgs tlon deps debug;
|
||||
inherit pkgs herb urbit;
|
||||
ship = bus;
|
||||
};
|
||||
|
||||
solid = import ./solid {
|
||||
inherit arvo pkgs tlon deps debug;
|
||||
inherit pkgs herb urbit arvo;
|
||||
pier = rawzod;
|
||||
};
|
||||
|
||||
brass = import ./brass {
|
||||
inherit arvo pkgs tlon deps debug;
|
||||
inherit pkgs herb urbit arvo;
|
||||
pier = zod;
|
||||
};
|
||||
|
||||
ivory = import ./ivory {
|
||||
inherit arvo pkgs tlon deps debug;
|
||||
inherit pkgs herb urbit arvo;
|
||||
pier = zod;
|
||||
};
|
||||
|
||||
image = import ./image {
|
||||
inherit pkgs urbit;
|
||||
pill = bootsolid;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,10 @@
|
||||
{ pkgs, tlon, deps, pill, ship, arvo, debug }:
|
||||
|
||||
let
|
||||
|
||||
urbitExe = if debug
|
||||
then "${tlon.urbit-debug}/bin/urbit-debug -g"
|
||||
else "${tlon.urbit}/bin/urbit";
|
||||
|
||||
in
|
||||
{ pkgs, herb, urbit, pill, ship, arvo }:
|
||||
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "fake" + ship;
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ tlon.herb ];
|
||||
URBIT = urbitExe;
|
||||
buildInputs = [ herb ];
|
||||
URBIT = urbit.meta.exe;
|
||||
ARVO = arvo;
|
||||
PILL = pill;
|
||||
SHIP = ship;
|
||||
|
@ -1,26 +1,30 @@
|
||||
{ pkgs
|
||||
, pill ? ../../../bin/solid.pill
|
||||
, urbit
|
||||
}:
|
||||
{ pkgs, urbit, pill }:
|
||||
|
||||
let
|
||||
|
||||
name = urbit.meta.name;
|
||||
debug = urbit.meta.debug;
|
||||
exe = ''${urbit.meta.exe} "$@"'';
|
||||
|
||||
entrypoint = "${urbit}/bin/${name}";
|
||||
coredump = ''
|
||||
ulimit -c unlimited
|
||||
|
||||
coredump = pkgs.writeScript "entrypoint.sh" ''
|
||||
${exe} || \
|
||||
${pkgs.gdb}/bin/gdb -ex "thread apply all bt" -ex "set pagination 0" -batch \
|
||||
${urbit.meta.bin} \
|
||||
/tmp/cores/core*
|
||||
'';
|
||||
|
||||
entrypoint = pkgs.writeScript "entrypoint.sh" ''
|
||||
#!${pkgs.stdenv.shell}
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ulimit -c unlimited
|
||||
${pkgs.coreutils}/bin/ln -sf ${pill} /data/urbit.pill
|
||||
|
||||
${entrypoint} -B ${pill} "$@" || \
|
||||
$${pkgs.gdb}/bin/gdb -ex "thread apply all bt" -ex "set pagination 0" -batch \
|
||||
${entrypoint} \
|
||||
/tmp/cores/core*
|
||||
${if debug then coredump else exe}
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
pkgs.dockerTools.buildImage {
|
||||
@ -39,7 +43,7 @@ pkgs.dockerTools.buildImage {
|
||||
'';
|
||||
|
||||
config = {
|
||||
Entrypoint = if debug then [ coredump ] else [ entrypoint ];
|
||||
Entrypoint = entrypoint;
|
||||
|
||||
WorkingDir = "/data";
|
||||
|
@ -1,19 +1,11 @@
|
||||
{ pkgs, tlon, deps, pier, arvo, debug }:
|
||||
|
||||
let
|
||||
|
||||
urbitExe = if debug
|
||||
then "${tlon.urbit-debug}/bin/urbit-debug -g"
|
||||
else "${tlon.urbit}/bin/urbit";
|
||||
|
||||
in
|
||||
{ pkgs, herb, urbit, pier, arvo }:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
name = "ivory";
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ tlon.herb pkgs.coreutils ];
|
||||
buildInputs = [ herb pkgs.coreutils ];
|
||||
|
||||
URBIT = urbitExe;
|
||||
URBIT = urbit.meta.exe;
|
||||
PIER = pier;
|
||||
ARVO = arvo;
|
||||
}
|
||||
|
@ -1,19 +1,11 @@
|
||||
{ pkgs, tlon, deps, pier, arvo, debug }:
|
||||
|
||||
let
|
||||
|
||||
urbitExe = if debug
|
||||
then "${tlon.urbit-debug}/bin/urbit-debug -g"
|
||||
else "${tlon.urbit}/bin/urbit";
|
||||
|
||||
in
|
||||
{ pkgs, herb, urbit, pier, arvo }:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
name = "solid";
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ tlon.herb ];
|
||||
buildInputs = [ herb ];
|
||||
|
||||
URBIT = urbitExe;
|
||||
URBIT = urbit.exe;
|
||||
PIER = pier;
|
||||
ARVO = arvo;
|
||||
}
|
||||
|
@ -1,18 +1,10 @@
|
||||
{ pkgs, tlon, deps, ship, debug }:
|
||||
|
||||
let
|
||||
|
||||
urbitExe = if debug
|
||||
then "${tlon.urbit-debug}/bin/urbit-debug -g"
|
||||
else "${tlon.urbit}/bin/urbit";
|
||||
|
||||
in
|
||||
{ pkgs, herb, urbit, ship }:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
name = "test";
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [ tlon.herb ];
|
||||
buildInputs = [ herb ];
|
||||
|
||||
URBIT = urbitExe;
|
||||
URBIT = urbit.meta.exe;
|
||||
SHIP = ship;
|
||||
}
|
||||
|
@ -23,16 +23,6 @@ let
|
||||
urbit = mkUrbit { debug = false; };
|
||||
urbit-debug = mkUrbit { debug = true; };
|
||||
|
||||
mkImage = { debug }:
|
||||
import ./urbit/image.nix {
|
||||
inherit pkgs;
|
||||
|
||||
urbit = if debug then urbit-debug else urbit;
|
||||
};
|
||||
|
||||
urbit-image = mkImage { debug = false; };
|
||||
urbit-image-debug = mkImage { debug = true; };
|
||||
|
||||
in
|
||||
|
||||
{ inherit ent ge-additions arvo herb urbit urbit-debug urbit-image urbit-image-debug; }
|
||||
{ inherit ent ge-additions arvo herb urbit urbit-debug; }
|
||||
|
@ -9,6 +9,13 @@ let
|
||||
name =
|
||||
if debug then "urbit-debug" else "urbit";
|
||||
|
||||
meta = rec {
|
||||
inherit debug;
|
||||
bin = "${urbit}/bin/${name}";
|
||||
flags = if debug then "-g" else "";
|
||||
exe = "${meta.bin} ${meta.flags}";
|
||||
};
|
||||
|
||||
deps =
|
||||
with pkgs;
|
||||
[ curl gmp libsigsegv ncurses openssl zlib lmdb ];
|
||||
@ -16,22 +23,22 @@ let
|
||||
vendor =
|
||||
[ argon2 softfloat3 ed25519 ent ge-additions h2o scrypt uv murmur3 secp256k1 sni ivory-header ca-header ];
|
||||
|
||||
urbit = pkgs.stdenv.mkDerivation {
|
||||
inherit name meta;
|
||||
exename = name;
|
||||
src = ../../../pkg/urbit;
|
||||
builder = ./builder.sh;
|
||||
nativeBuildInputs = deps ++ vendor;
|
||||
|
||||
# See https://github.com/NixOS/nixpkgs/issues/18995
|
||||
hardeningDisable = if debug then [ "all" ] else [];
|
||||
|
||||
CFLAGS = if debug then "-O3 -g -Werror" else "-O3 -Werror";
|
||||
MEMORY_DEBUG = debug;
|
||||
CPU_DEBUG = debug;
|
||||
EVENT_TIME_DEBUG = false;
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = name;
|
||||
exename = name;
|
||||
meta = { inherit debug; };
|
||||
src = ../../../pkg/urbit;
|
||||
builder = ./builder.sh;
|
||||
|
||||
nativeBuildInputs = deps ++ vendor;
|
||||
|
||||
# See https://github.com/NixOS/nixpkgs/issues/18995
|
||||
hardeningDisable = if debug then [ "all" ] else [];
|
||||
|
||||
CFLAGS = if debug then "-O3 -g -Werror" else "-O3 -Werror";
|
||||
MEMORY_DEBUG = debug;
|
||||
CPU_DEBUG = debug;
|
||||
EVENT_TIME_DEBUG = false;
|
||||
}
|
||||
urbit
|
||||
|
15
sh/image
15
sh/image
@ -2,12 +2,6 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
build=${1:-}
|
||||
|
||||
if [[ -z "$build" ]]; then
|
||||
build="urbit-image"
|
||||
fi
|
||||
|
||||
say() {
|
||||
echo "$1" >&2
|
||||
}
|
||||
@ -19,17 +13,18 @@ git_branch="$(git branch --show-current)"
|
||||
|
||||
git_tag="${git_branch}-${git_sha}"
|
||||
|
||||
say "Building $build..."
|
||||
nix_out="$(nix-build default.nix --no-out-link -A $build)"
|
||||
say "Building nix/ops/image..."
|
||||
nix_out="$(nix-build nix/ops -A image --no-out-link "$@")"
|
||||
|
||||
say "Loading $nix_out into Docker..."
|
||||
nix_name="$(docker load --quiet --input $nix_out)"
|
||||
nix_name="${nix_name#Loaded image: }"
|
||||
|
||||
say "Re-tagging with current git branch:$git_branch and SHA:$git_sha"
|
||||
say "Re-tagging with git metadata..."
|
||||
image_repo="$(docker images $nix_name --format '{{.Repository}}')"
|
||||
image_name="${image_repo}:${git_tag}"
|
||||
docker tag $nix_name $image_name
|
||||
|
||||
# Output only the tag on stdout for subsequent pipes/tooling.
|
||||
# Output only the new tag on stdout for subsequent pipes/tooling.
|
||||
say $nix_name
|
||||
echo $image_name
|
||||
|
Loading…
Reference in New Issue
Block a user