From 70779f4e651784165449479a70465b9dded41d28 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 20 Apr 2022 16:12:06 +0200 Subject: refactor(nixery): Adapt Nix build instructions for readTree This does not fully change the build structure of Nixery to be depot-compatible yet, but should allow most targets to be built in depot CI. This contains some hacks to work around surface incompatibilities which we'll clear away later. Change-Id: I84e7734334abbe299983956f528c0897f49fa8c2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5485 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tools/nixery/default.nix | 14 +++++++++++--- tools/nixery/nixpkgs-pin.nix | 4 ---- 2 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 tools/nixery/nixpkgs-pin.nix (limited to 'tools') diff --git a/tools/nixery/default.nix b/tools/nixery/default.nix index 70d5093bb9..e39db40a5a 100644 --- a/tools/nixery/default.nix +++ b/tools/nixery/default.nix @@ -12,7 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -{ pkgs ? import ./nixpkgs-pin.nix +# This function header aims to provide compatibility between builds of +# Nixery taking place inside/outside of the TVL depot. +# +# In the future, Nixery will transition to using //nix/buildGo for its +# build system and this will need some major adaptations to support +# that. +{ depot ? { nix.readTree.drvTargets = x: x; } +, pkgs ? import {} , preLaunch ? "" , extraPackages ? [] , maxLayers ? 20 @@ -27,7 +34,8 @@ let # Current Nixery commit - this is used as the Nixery version in # builds to distinguish errors between deployed versions, see # server/logs.go for details. - nixery-commit-hash = args.commitHash or pkgs.lib.commitIdFromGitRepo ./.git; + gitDir = if builtins.pathExists ./.git then ./.git else ../../.git; + nixery-commit-hash = args.commitHash or pkgs.lib.commitIdFromGitRepo gitDir; # Go implementation of the Nixery server which implements the # container registry interface. @@ -46,7 +54,7 @@ let "-ldflags=-s -w -X main.version=${nixery-commit-hash}" ]; }; -in rec { +in depot.nix.readTree.drvTargets rec { # Implementation of the Nix image building logic nixery-prepare-image = import ./prepare-image { inherit pkgs; }; diff --git a/tools/nixery/nixpkgs-pin.nix b/tools/nixery/nixpkgs-pin.nix deleted file mode 100644 index d868855b5b..0000000000 --- a/tools/nixery/nixpkgs-pin.nix +++ /dev/null @@ -1,4 +0,0 @@ -import (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/2deb07f3ac4eeb5de1c12c4ba2911a2eb1f6ed61.tar.gz"; - sha256 = "0036sv1sc4ddf8mv8f8j9ifqzl3fhvsbri4z1kppn0f1zk6jv9yi"; -}) {} -- cgit 1.4.1