如何在Nixos泊坞映像上安装Nix软件包?

时间:2020-07-19 14:23:34

标签: docker nixos

简短版本:我需要在Docker映像中包括file实用程序。源和目标环境都是NixOS。如何定义docker映像,以便另一个可执行文件可以调用它,或其他任何预先打包的可执行文件?

更长的版本:我已经成功构建了docker映像,在其中将预编译的可执行文件复制到了适当的位置。现在,该可执行文件需要调用file实用程序来识别各种文件的mime类型,这就是我要坚持的地方。

buildInputs中使用shell.nix的方式并没有取得预期的效果。有人可以指出我需要的线索吗?

我的docker.nix如下:

with import <nixpkgs> {};

let
    foobar_deriv = stdenv.mkDerivation rec {
        name = "foobar";
        builder = "${bash}/bin/bash";
        args = [ ./nix-builder.sh ];
        inherit coreutils openssl libyaml;
        system = builtins.currentSystem;
        schemapath = ../../schemas;
        foobarpath = ./foobar;

        buildInputs = [
            pkgs.bash
            pkgs.file
        ];
        env = buildEnv {
            name = name;
            paths = buildInputs;
        };

    };

    ld_path = stdenv.lib.makeLibraryPath [
        pkgs.openssl
        pkgs.libyaml
    ];

    entrypoint = writeScript "entrypoint.sh" ''
    #!${stdenv.shell}
    export LD_LIBRARY_PATH=${ld_path}
    exec $@
    '';

in
pkgs.dockerTools.buildImage {
    name = "myaccount/foobar";
    tag = "0.3.0a11";
    created = "now";

    contents = foobar_deriv;

    config = {
        Cmd = [ "foobar" ];
        Entrypoint = [ entrypoint ];
        ExposedPorts = {
            "4949/tcp" = {};
        };
        WorkingDir = "/";
    };
}

1 个答案:

答案 0 :(得分:0)

答案比我预期的要简单:如果将public tinyMCEConfig : object = { height: 500, menubar: false, plugins: [ 'advlist autolink lists link image charmap print preview anchor', 'searchreplace visualblocks code fullscreen', 'insertdatetime media table paste code help wordcount' ], toolbar: 'undo redo | formatselect | bold italic backcolor | \ alignleft aligncenter alignright alignjustify | \ bullist numlist outdent indent | removeformat | help', init_instance_callback: (editor) => { this.editor = editor; } }; 定义为列表而不是原子,则派生结果将合并为最终图像。

对于这种特定情况,解决方案是更改

<input type="text" (input)="onChange($event)" >

contents

在实践中,我添加了更多实用程序,以便可以根据需要进行查找,因此它变成了

contents = foobar_deriv;