forked from lix-project/lix
docker.nix: add an option to include flake-registry inside docker image (#6750)
Co-authored-by: Alex Wied <centromere@users.noreply.github.com> Co-authored-by: Rok Garbas <rok@floxdev.com>
This commit is contained in:
parent
006291e5be
commit
6dbce3215f
12
docker.nix
12
docker.nix
|
@ -8,6 +8,7 @@
|
||||||
, extraPkgs ? []
|
, extraPkgs ? []
|
||||||
, maxLayers ? 100
|
, maxLayers ? 100
|
||||||
, nixConf ? {}
|
, nixConf ? {}
|
||||||
|
, flake-registry ? null
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
defaultPkgs = with pkgs; [
|
defaultPkgs = with pkgs; [
|
||||||
|
@ -247,7 +248,16 @@ let
|
||||||
mkdir -p $out/bin $out/usr/bin
|
mkdir -p $out/bin $out/usr/bin
|
||||||
ln -s ${pkgs.coreutils}/bin/env $out/usr/bin/env
|
ln -s ${pkgs.coreutils}/bin/env $out/usr/bin/env
|
||||||
ln -s ${pkgs.bashInteractive}/bin/bash $out/bin/sh
|
ln -s ${pkgs.bashInteractive}/bin/bash $out/bin/sh
|
||||||
'';
|
|
||||||
|
'' + (lib.optionalString (flake-registry != null) ''
|
||||||
|
nixCacheDir="/root/.cache/nix"
|
||||||
|
mkdir -p $out$nixCacheDir
|
||||||
|
globalFlakeRegistryPath="$nixCacheDir/flake-registry.json"
|
||||||
|
ln -s ${flake-registry}/flake-registry.json $out$globalFlakeRegistryPath
|
||||||
|
mkdir -p $out/nix/var/nix/gcroots/auto
|
||||||
|
rootName=$(${pkgs.nix}/bin/nix --extra-experimental-features nix-command hash file --type sha1 --base32 <(echo -n $globalFlakeRegistryPath))
|
||||||
|
ln -s $globalFlakeRegistryPath $out/nix/var/nix/gcroots/auto/$rootName
|
||||||
|
'');
|
||||||
|
|
||||||
in
|
in
|
||||||
pkgs.dockerTools.buildLayeredImageWithNixDb {
|
pkgs.dockerTools.buildLayeredImageWithNixDb {
|
||||||
|
|
Loading…
Reference in a new issue