coder-templates/image.nix

28 lines
812 B
Nix
Raw Normal View History

2024-04-24 16:45:10 +02:00
{
lib,
pkgs,
processes ? {},
...
}: let
# https://github.com/cachix/devenv/blob/5a30b9e5ac7c6167e61b1f4193d5130bb9f8defa/src/modules/processes.nix#L121
procfile = pkgs.writeText "procfile" (lib.concatStringsSep "\n" (lib.mapAttrsToList (name: process: "${name}: exec ${pkgs.writeShellScript name process}") processes));
overmind-sys = pkgs.writeShellScriptBin "overmind-sys" ''
OVERMIND_SOCKET=/run/overmind-sys.sock \
OVERMIND_ANY_CAN_DIE=1 \
OVERMIND_PROCFILE=${procfile} \
${pkgs.overmind}/bin/overmind "$@"
'';
in
pkgs.dockerTools.buildImage {
name = "nix-coder";
tag = "latest";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [pkgs.bashInteractive overmind-sys];
pathsToLink = ["/bin"];
};
config.Cmd = ["/bin/bash"];
}