Hi all,
I am trying to build a simple docker image inside the “nixpkgs/nixos” and “nixpkgs/cachix-flakes” images with flake from, but I run into some difficulties.
{
description = "Simple Docker Flake project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
packages.hello = pkgs.dockerTools.buildImage {
name = "hello";
tag = "0.1.0";
config = { Cmd = [ "${pkgs.hello}/bin/hello" ]; };
created = "now";
};
devShells.default =
pkgs.mkShell { buildInputs = with pkgs; [ bat vim ]; };
});
}
When I run nix build .#hello
command without using flake environment (direnv: use flake)
everything works fine, but when I load flake environment and try to build docker image, I get the following error.
error: builder for
'/nix/store/kyfd16cspq8hrc0bjrpd846rkg213jxr-hello-config. json.drv' failed with exit code 1;
last 2 log lines:
> unpacking sources
- variable $src or $srcs should point to the source
For full logs, run 'nix log /nix/store/kyfd16cspq8hrcobjrpd846rkg213jxr-hello-config.json.drv'
error: 1 dependencies of derivation '/nix/store/r2502npbrcsvzips0px03d4xrv5k3i8-hello-config.ison.drv'failed to build
error: 1 dependencies of derivation '/nix/store/roza2pch58s573x615sfswrai60nav4x-docker-image-hello.tar.az.drv'failed to build
Can someone take a look at this and please tell me what I’m doing wrong?
The above Flake code works fine outside the docker environment.