mirror of
https://code.tvl.fyi/depot.git:/tools/nixery.git
synced 2025-03-15 06:01:51 +00:00
refactor(nixery): Modernise structure of binaries
Nixery is going to gain a new binary (used for building images without a registry server); to prepare for this the server binary has moved to cmd/server and the Nix build logic has been updated to wrap this binary and set the required environment variables. Change-Id: I9b4f49f47872ae76430463e2fcb8f68114070f72 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5603 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
58bb2c004c
commit
137ff9051a
55
default.nix
55
default.nix
|
@ -25,23 +25,6 @@ let
|
||||||
# through revision numbers.
|
# through revision numbers.
|
||||||
nixery-commit-hash = "depot";
|
nixery-commit-hash = "depot";
|
||||||
|
|
||||||
# Go implementation of the Nixery server which implements the
|
|
||||||
# container registry interface.
|
|
||||||
#
|
|
||||||
# Users should use the nixery-bin derivation below instead as it
|
|
||||||
# provides the paths of files needed at runtime.
|
|
||||||
nixery-server = buildGoModule rec {
|
|
||||||
name = "nixery-server";
|
|
||||||
src = ./.;
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
# Needs to be updated after every modification of go.mod/go.sum
|
|
||||||
vendorSha256 = "1xnmyz2a5s5sck0fzhcz51nds4s80p0jw82dhkf4v2c4yzga83yk";
|
|
||||||
|
|
||||||
buildFlagsArray = [
|
|
||||||
"-ldflags=-s -w -X main.version=${nixery-commit-hash}"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
depot.nix.readTree.drvTargets rec {
|
depot.nix.readTree.drvTargets rec {
|
||||||
# Implementation of the Nix image building logic
|
# Implementation of the Nix image building logic
|
||||||
|
@ -52,19 +35,33 @@ depot.nix.readTree.drvTargets rec {
|
||||||
# nixery.dev.
|
# nixery.dev.
|
||||||
nixery-book = callPackage ./docs { };
|
nixery-book = callPackage ./docs { };
|
||||||
|
|
||||||
# Wrapper script running the Nixery server with the above two data
|
|
||||||
# dependencies configured.
|
|
||||||
#
|
|
||||||
# In most cases, this will be the derivation a user wants if they
|
|
||||||
# are installing Nixery directly.
|
|
||||||
nixery-bin = writeShellScriptBin "nixery" ''
|
|
||||||
export WEB_DIR="${nixery-book}"
|
|
||||||
export PATH="${nixery-prepare-image}/bin:$PATH"
|
|
||||||
exec ${nixery-server}/bin/nixery
|
|
||||||
'';
|
|
||||||
|
|
||||||
nixery-popcount = callPackage ./popcount { };
|
nixery-popcount = callPackage ./popcount { };
|
||||||
|
|
||||||
|
# Build Nixery's Go code, resulting in the binaries used for various
|
||||||
|
# bits of functionality.
|
||||||
|
#
|
||||||
|
# The server binary is wrapped to ensure that required environment
|
||||||
|
# variables are set at runtime.
|
||||||
|
nixery = buildGoModule rec {
|
||||||
|
name = "nixery";
|
||||||
|
src = ./.;
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
# Needs to be updated after every modification of go.mod/go.sum
|
||||||
|
vendorSha256 = "1xnmyz2a5s5sck0fzhcz51nds4s80p0jw82dhkf4v2c4yzga83yk";
|
||||||
|
|
||||||
|
buildFlagsArray = [
|
||||||
|
"-ldflags=-s -w -X main.version=${nixery-commit-hash}"
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
postInstall = ''
|
||||||
|
wrapProgram $out/bin/server \
|
||||||
|
--set WEB_DIR "${nixery-book}" \
|
||||||
|
--prefix PATH : ${nixery-prepare-image}/bin
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Container image containing Nixery and Nix itself. This image can
|
# Container image containing Nixery and Nix itself. This image can
|
||||||
# be run on Kubernetes, published on AppEngine or whatever else is
|
# be run on Kubernetes, published on AppEngine or whatever else is
|
||||||
# desired.
|
# desired.
|
||||||
|
@ -98,7 +95,7 @@ depot.nix.readTree.drvTargets rec {
|
||||||
# This can be achieved by setting a 'preLaunch' script.
|
# This can be achieved by setting a 'preLaunch' script.
|
||||||
${preLaunch}
|
${preLaunch}
|
||||||
|
|
||||||
exec ${nixery-bin}/bin/nixery
|
exec ${nixery}/bin/server
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
dockerTools.buildLayeredImage {
|
dockerTools.buildLayeredImage {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user