{"id":346932,"date":"2023-03-17T21:02:49","date_gmt":"2023-03-17T21:02:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346932"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2023-03-17T21:02:49","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346932","title":{"rendered":"<span>\u041a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c Rust \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Nix<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043c\u0435\u0441\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c Docker \u043e\u0431\u0440\u0430\u0437\u044b \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 Rust. \u041e\u0431\u044b\u0447\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f Dockerfile, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043a\u0435\u0440\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0432\u0441\u0435. \u041d\u043e \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e: \u0442\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f \u0435\u0441\u0442\u044c x86_64 Linux \u043c\u0430\u0448\u0438\u043d\u0430, \u043d\u043e \u043b\u044e\u0431\u043e\u0439 \u0448\u0430\u0433 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. <\/p>\n<p>\u0412\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0436\u0435 \u043d\u0430 Intel MacBook \u043c\u0430\u0448\u0438\u043d\u0430\u0445, \u0434\u043e\u043a\u0435\u0440 \u043f\u043e\u0435\u0434\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u0445\u043e\u0441\u0442\u0430, \u0430 \u0435\u0449\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u0441\u044f\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043a\u043e\u043b\u044b \u0441 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u041d\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0443\u0436\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u041c\u0430\u043a\u0431\u0443\u043a\u0430\u0445 \u0441 Apple Silicon \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u043c\u0438, \u0433\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0443\u0436\u0435 \u043d\u0435 \u043e\u0431\u043e\u0439\u0434\u0435\u0448\u044c\u0441\u044f \u0438 \u043c\u043e\u0436\u043d\u043e \u0447\u0430\u0441\u0430\u043c\u0438 \u0436\u0434\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 qemu. \u041c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0431\u043e\u0440\u043a\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0432 CI, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043c\u043d\u043e\u0433\u043e, \u0430 \u0438\u043c \u043d\u0430\u0434\u043e \u0447\u0430\u0441\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c, \u0442\u043e \u0442\u0430\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0443\u0442\u0438, \u0430 \u043a\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0448\u0435\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438 \u0445\u043e\u0447\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h2>Nix Package Manager<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c Nix Package Manager, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u0447\u0438\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0438 \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u041f\u041e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u0430\u043d\u0430\u043b\u043e\u0433 virtualenv, \u0438\u043b\u0438 nvm, \u043d\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u0432\u043e\u043e\u0431\u0449\u0435 \u043b\u044e\u0431\u044b\u0445 \u043c\u044b\u0441\u043b\u0438\u043c\u044b\u0445 \u0438 \u043d\u0435\u043c\u044b\u0441\u043b\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. <\/p>\n<p><a href=\"https:\/\/nixos.org\/download.html\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f<\/a> \u043e\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e (\u0445\u043e\u0442\u044f \u043d\u0430 \u043c\u0430\u043a\u0435 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 APFS \u0442\u043e\u043c\u0430 \u0438 root \u043f\u0440\u0430\u0432), \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0435\u0434\u0438\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043d\u0430 Linux (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 WSL), \u0442\u0430\u043a \u0438 \u043d\u0430 MacOS. \u0410 \u0441\u0430\u043c\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/nixos.wiki\/wiki\/Development_environment_with_nix-shell\" rel=\"noopener noreferrer nofollow\">shell.nix<\/a> \u0444\u0430\u0439\u043b\u0435, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"haskell\">{ pkgs ? import &lt;nixpkgs> {} }:   pkgs.mkShell {     # \u0412\u0441\u044f\u043a\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u0438\u043f\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432     nativeBuildInputs = with pkgs; [       rustc       cargo       protobuf       cmake       pkg-config     ];     # \u0412\u0441\u044f\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438     buildInputs = with pkgs; [        openssl        zlib     ]; }<\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0438\u0441\u0430\u043d \u044d\u0442\u043e\u0442 shell.nix \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<pre><code class=\"bash\"># \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0439\u0442\u0438 \u0432 \u0448\u0435\u043b\u043b nix-shell shell.nix # \u0410 \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0437 \u043f\u043e\u0434 \u0448\u0435\u043b\u043b\u0430 nix-shell --run \"cargo build\"<\/code><\/pre>\n<p>\u0418 \u0434\u0430\u043b\u044c\u0448\u0435 Nix Package Manager \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 shell.nix \u0444\u0430\u0439\u043b\u0435. \u0422\u0430\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 Rust \u043f\u0440\u043e\u0435\u043a\u0442\u044b. \u041f\u0440\u0438\u0447\u0435\u043c, \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \/nix\/store \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 nix store gc.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u043b\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u0438\u043a \u0432 \u0434\u0435\u043b\u0435 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/h2>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e Nix \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e <a href=\"https:\/\/nix.dev\/tutorials\/cross-compilation\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u043f\u043b\u043e\u0445\u043e<\/a> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u043d\u043e \u043c\u043e\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0437\u044f\u0442\u044c \u0438 \u0432 \u043b\u043e\u0431 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441 \u041c\u0430\u043a\u0430 \u043f\u043e\u0434 \u041b\u0438\u043d\u0443\u043a\u0441 \u0447\u0442\u043e-\u0442\u043e, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0448\u0435\u043b\u043b\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435, \u0441 \u0442\u0440\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0430\u0441\u044c. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438 Rust \u0438\u0437 Nix \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u043c\u0435\u0435\u0442 \u0432 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0438 \u0435\u0449\u0435 \u043a\u0443\u0447\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f. <\/p>\n<p>\u041d\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/oxalica\/rust-overlay\/tree\/master\/examples\/cross-aarch64\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a<\/a> \u0438 <a href=\"https:\/\/github.com\/ipetkov\/crane\/tree\/master\/examples\/cross-musl\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0432\u0435\u0442\u043e\u0432<\/a> \u043a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0432\u0441\u044e \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u044f \u0443\u0436\u0435, \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443\u044f\u0441\u044c \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043f\u043e Nix, \u043d\u0430\u0447\u0430\u043b \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\" rel=\"noopener noreferrer nofollow\">\u043e\u0432\u0435\u0440\u043b\u0435\u0439<\/a> \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0441\u043c\u043e\u0433 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u0438 \u043a\u0435\u0448 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0447\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u0431\u044b\u0441\u0442\u0440\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u0448\u0435\u043b\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443. \u041e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<\/p>\n<pre><code class=\"bash\">nix-shell -p cachix --run \"cachix use nixpkgs-cross-overlay\"<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0448\u0435\u043b\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 musl \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438 \u043f\u043e\u0434 x86_86 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e <a href=\"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\/tree\/main\/examples\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a\u0438\u043c<\/a> \u0444\u0430\u0439\u043b\u043e\u043c:<\/p>\n<pre><code class=\"haskell\">{ localSystem ? builtins.currentSystem   # Default cross-compilation configuration, you may override it by passing the    # `--arg crossSystem '&lt;our-own-config>'` to `nix-shell`. , crossSystem ? { config = \"x86_64-unknown-linux-musl\"; isStatic = true; useLLVM = true; }   # Override nixpkgs-cross-overlay branch. }: let   # Fetch the nixpkgs-cross-overlay sources.   src = builtins.fetchTarball \"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\/tarball\/main\";   # Use the nixpkgs revision provided by the overlay.    # This is the best way, as they are the most proven and compatible.   nixpkgs = \"${src}\/utils\/nixpkgs.nix\";   # Make cross system packages.   pkgs = import nixpkgs {     inherit localSystem crossSystem;     overlays = [       # &lt;- You may add your extra overlays here.     ];   }; in # And now, with the resulting packages, we can describe the cross-compilation shell. pkgs.mkShell {   # Native project dependencies like build utilities and additional routines    # like container building, linters, etc.   nativeBuildInputs = [     # This overlay also provides the `rust-overlay`, so it is easy to override the default Rust toolchain setup.     # Uncomment this line if you want to use the Rust toolchain provided by this shell.     pkgs.pkgsBuildHost.rust-bin.stable.latest.default     # Will add some dependencies like libiconv.     pkgs.pkgsBuildHost.rustBuildHostDependencies     # Crates dependencies     pkgs.cargoDeps.openssl-sys     pkgs.cargoDeps.prost   ];   # Libraries essential to build the service binaries.   buildInputs = with pkgs; [     # Enable Rust cross-compilation support.     rustCrossHook     # Some native libraries.     icu   ];   # Prettify shell prompt.   shellHook = \"${pkgs.crossBashPrompt}\"; }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"bash\">nix-shell shell.nix<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 libc \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c Linux \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0435, \u043d\u0443 \u0438\u043b\u0438 \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437. \u041e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c, \u0431\u044b\u0441\u0442\u0440\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0443\u0436\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 \u043e\u0442 \u0436\u0438\u0437\u043d\u0438, \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432 Alpine Linux \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c, \u043d\u043e Nix \u0441\u0430\u043c \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u0414\u043e\u043a\u0435\u0440\u0430 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u043e\u043a\u0435\u0440\u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<h2>Nix dockerTools<\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/nix.dev\/tutorials\/building-and-running-docker-images\" rel=\"noopener noreferrer nofollow\">dockerTools<\/a> \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Nix, \u043f\u0440\u0438\u0447\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0441\u0430\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0444\u0430\u0439\u043b\u043e\u0432, \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0439 \u0441 distroless \u043e\u0431\u0440\u0430\u0437\u0430\u043c\u0438, \u0430 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0443\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u043a-\u0436\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Nix Package Manager. <\/p>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/gist.github.com\/alekseysidorov\/5e027e7574cd47d720324f00c20eeb8e\" rel=\"noopener noreferrer nofollow\">\u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437 \u0438\u0437 \u0432\u044b\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0435\u043c\u0443 Rust \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430:<\/p>\n<pre><code class=\"haskell\">{ localSystem ? builtins.currentSystem , crossSystem ? { config = \"x86_64-unknown-linux-musl\"; isStatic = true; useLLVM = true; } }: let   # Fetch the nixpkgs-cross-overlay sources.   src = builtins.fetchTarball \"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\/tarball\/main\";   # Use the nixpkgs revision provided by the overlay.    # This is the best way, as they are the most proven and compatible.   nixpkgs = \"${src}\/utils\/nixpkgs.nix\";   # Make cross system packages.   pkgs = import nixpkgs {     inherit localSystem crossSystem;     overlays = [       # &lt;- You may add your extra overlays here.     ];   }; in # And now, with the resulting packages, we can describe the cross-compilation shell. pkgs.mkShell {   # Native project dependencies like build utilities and additional routines    # like container building, linters, etc.   nativeBuildInputs = [     pkgs.pkgsBuildHost.rust-bin.stable.latest.default     # Will add some dependencies like libiconv.     pkgs.pkgsBuildHost.rustBuildHostDependencies     # Crates dependencies.     pkgs.cargoDeps.openssl-sys     # A simple script to create a docker image from the Cargo workspace member.     (pkgs.pkgsBuildHost.writeShellApplication {       name = \"cargo-nix-docker-image\";       runtimeInputs = with pkgs.pkgsBuildHost; [         nix         docker       ];       text = let shellFile = .\/shell.nix; in ''         binary_name=$1         # Compile cargo binary         cargo build --release         # Copy this shell to the target dir         cp ${shellFile} .\/target\/shell.nix         # Build docker image from the compiled service         image_archive=$(nix-build .\/target\/shell.nix -A dockerImage --argstr name \"$binary_name\")         docker load &lt;\"$image_archive\"       '';     })   ];   # Libraries essential to build the service binaries.   buildInputs = with pkgs; [     # Enable Rust cross-compilation support.     rustCrossHook   ];   # Prettify shell prompt.   shellHook = ''     ${pkgs.crossBashPrompt}     echo \"Welcome to the Cargo docker images builder demo shell!\"     echo \"\"     echo \"Usage:\"     echo \"\"     echo \"$ cargo-nix-docker-image &lt;executable-name>\"     echo \"\"     echo \"Have a nice day!\"   '';   \/* Service docker image definition     Usage:      ```shell     cargo-nix-docker-image executable-name>     ```   *\/   passthru.dockerImage = (     {       # Cargo workspace member name       name     , tag ? \"latest\"     }:     pkgs.pkgsBuildHost.dockerTools.buildLayeredImage {       inherit tag name;        contents = with pkgs; [         coreutils         bashInteractive         dockerTools.caCertificates         # Actual service binary compiled by Cargo         (copyBinaryFromCargoBuild {           inherit name;           targetDir = .\/.;           buildInputs = [             openssl.dev           ];         })         # Utilites like ldd to help image debugging         stdenv.cc.libc_bin       ];        config = {         Cmd = [ name ];         WorkingDir = \"\/\";         Expose = 8080;       };     }   ); }<\/code><\/pre>\n<p>\u041e\u043d \u0443\u0436\u0435 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0445\u0438\u0442\u0440\u044b\u0439, \u0442\u0443\u0442 shell.nix \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432 \u0434\u0432\u0443\u0445 \u0438\u043f\u043e\u0441\u0442\u0430\u0441\u044f\u0445: \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043a\u0430\u043a \u0430\u043d\u0430\u043b\u043e\u0433 Dockerfile. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0430 \u0448\u0430\u0433\u0430:<\/p>\n<pre><code class=\"bash\"># \u0417\u0430\u0439\u0442\u0438 \u0432 \u0448\u0435\u043b\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0441\u0431\u043e\u0440\u043a\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u044b nix-shell shell.nix cargo build --release # \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 nix-build \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c dockerImage \u0434\u043b\u044f \u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0438  # \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430 \u0432 \u0414\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437 export IMAGE=$(nix-build .\/target\/shell.nix -A dockerImage --argstr name &lt;\u0438\u043c\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430>) # \u041f\u0440\u0438\u0447\u0435\u043c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u0432\u0430\u0441 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 $IMAGE \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0434\u043e\u043a\u0435\u0440 \u0430\u0440\u0445\u0438\u0432, # \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 docker load &lt;\"$IMAGE\"<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a, \u0430 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u043f\u0430\u043a\u0443\u0435\u0442\u0435 \u0435\u0433\u043e \u0432 \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437. \u0410 \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u044d\u0442\u0430\u043f\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f passthru, \u0438\u0434\u0435\u044f \u0435\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 pkgs.mkShell \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u0448\u0435\u043b\u043b \u044d\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 output derivation,  \u043d\u0443 \u0430 buildLayeredImage \u0442\u043e\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0440\u0445\u0438\u0432 \u0441 \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438 \u0435\u0441\u043b\u0438 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 passthru, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043b\u044e\u0447\u0430 -A \u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b nix-build.<\/p>\n<pre><code>nix-build .\/target\/shell.nix -A dockerImage --argstr name &lt;\u0438\u043c\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430><\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0438, \u043e \u043d\u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0432\u043e\u0432\u0440\u0435\u043c\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0443\u0436\u0435 \u043a \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e.<\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/nixos.org\" rel=\"noopener noreferrer nofollow\">Nix<\/a> &#8212; \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\" rel=\"noopener noreferrer nofollow\">nixpkgs-cross-overlay<\/a> &#8212; \u0441\u0430\u043c \u043e\u0432\u0435\u0440\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/alekseysidorov\/nixpkgs-rust-service-example\" rel=\"noopener noreferrer nofollow\">nixpkgs-rust-service-example<\/a> &#8212; \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0432\u0435\u0440\u043b\u0435\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0432 \u0441\u0435\u0431\u044f CI \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0431\u043e\u0440\u043a\u0438 (\u043e\u0431 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f).<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u042d\u0442\u043e \u043b\u0438\u0448\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 Nix \u0441 \u043c\u043e\u0438\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u043e\u0432\u0435\u0440\u043b\u0435\u0435\u043c, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u044d\u0442\u043e\u0433\u043e \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 Apple Silicon \u043c\u0430\u0448\u0438\u043d\u044b. \u042f \u043f\u0440\u044f\u043c\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0449\u0443\u0442\u0438\u043b \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0438 \u043a\u0430\u043a \u043e\u043d\u043e \u0441\u0442\u0430\u043b\u043e \u0442\u0435\u043f\u0435\u0440\u044c, \u0430 \u0435\u0449\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Nix \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043e\u0432\u0435\u0440\u043b\u0435\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0445 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438 &#8212; \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0440\u0445\u0435\u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>\u0418 \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0436\u0438\u0437\u043d\u044c, \u043d\u043e \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e, \u043e \u0447\u0435\u043c \u0431\u044b \u044f \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0432 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043d\u0430 \u0442\u0435\u043c\u0443 \u0432\u043e\u0441\u043f\u0440\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0431\u043e\u0440\u043a\u0438, \u043d\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0442\u044f\u043d\u0435\u0442 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e, \u0432 \u043e\u0431\u0449\u0435\u043c, \u0436\u0434\u0438\u0442\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f, \u044d\u0442\u043e\u0442 \u043e\u0432\u0435\u0440\u043b\u0435\u0439 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0441 C++ \u0438\u043b\u0438 C \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/723194\/\"> https:\/\/habr.com\/ru\/post\/723194\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043c\u0435\u0441\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c Docker \u043e\u0431\u0440\u0430\u0437\u044b \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 Rust. \u041e\u0431\u044b\u0447\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f Dockerfile, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043a\u0435\u0440\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0432\u0441\u0435. \u041d\u043e \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e: \u0442\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f \u0435\u0441\u0442\u044c x86_64 Linux \u043c\u0430\u0448\u0438\u043d\u0430, \u043d\u043e \u043b\u044e\u0431\u043e\u0439 \u0448\u0430\u0433 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. <\/p>\n<p>\u0412\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u0436\u0435 \u043d\u0430 Intel MacBook \u043c\u0430\u0448\u0438\u043d\u0430\u0445, \u0434\u043e\u043a\u0435\u0440 \u043f\u043e\u0435\u0434\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u0445\u043e\u0441\u0442\u0430, \u0430 \u0435\u0449\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0432\u0441\u044f\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043a\u043e\u043b\u044b \u0441 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u041d\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0443\u0436\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u041c\u0430\u043a\u0431\u0443\u043a\u0430\u0445 \u0441 Apple Silicon \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u043c\u0438, \u0433\u0434\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0443\u0436\u0435 \u043d\u0435 \u043e\u0431\u043e\u0439\u0434\u0435\u0448\u044c\u0441\u044f \u0438 \u043c\u043e\u0436\u043d\u043e \u0447\u0430\u0441\u0430\u043c\u0438 \u0436\u0434\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 qemu. \u041c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0431\u043e\u0440\u043a\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0432 CI, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043c\u043d\u043e\u0433\u043e, \u0430 \u0438\u043c \u043d\u0430\u0434\u043e \u0447\u0430\u0441\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c, \u0442\u043e \u0442\u0430\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0443\u0442\u0438, \u0430 \u043a\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0448\u0435\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438 \u0445\u043e\u0447\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h2>Nix Package Manager<\/h2>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c Nix Package Manager, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u0447\u0438\u0441\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0438 \u0441\u0440\u0435\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u041f\u041e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u0430\u043d\u0430\u043b\u043e\u0433 virtualenv, \u0438\u043b\u0438 nvm, \u043d\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u0432\u043e\u043e\u0431\u0449\u0435 \u043b\u044e\u0431\u044b\u0445 \u043c\u044b\u0441\u043b\u0438\u043c\u044b\u0445 \u0438 \u043d\u0435\u043c\u044b\u0441\u043b\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. <\/p>\n<p><a href=\"https:\/\/nixos.org\/download.html\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f<\/a> \u043e\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e (\u0445\u043e\u0442\u044f \u043d\u0430 \u043c\u0430\u043a\u0435 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 APFS \u0442\u043e\u043c\u0430 \u0438 root \u043f\u0440\u0430\u0432), \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0435\u0434\u0438\u043d\u044b\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043d\u0430 Linux (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 WSL), \u0442\u0430\u043a \u0438 \u043d\u0430 MacOS. \u0410 \u0441\u0430\u043c\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/nixos.wiki\/wiki\/Development_environment_with_nix-shell\" rel=\"noopener noreferrer nofollow\">shell.nix<\/a> \u0444\u0430\u0439\u043b\u0435, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"haskell\">{ pkgs ? import &lt;nixpkgs> {} }:   pkgs.mkShell {     # \u0412\u0441\u044f\u043a\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u0438\u043f\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432     nativeBuildInputs = with pkgs; [       rustc       cargo       protobuf       cmake       pkg-config     ];     # \u0412\u0441\u044f\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438     buildInputs = with pkgs; [        openssl        zlib     ]; }<\/code><\/pre>\n<p>\u041d\u0443 \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0438\u0441\u0430\u043d \u044d\u0442\u043e\u0442 shell.nix \u0444\u0430\u0439\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/p>\n<pre><code class=\"bash\"># \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0439\u0442\u0438 \u0432 \u0448\u0435\u043b\u043b nix-shell shell.nix # \u0410 \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0437 \u043f\u043e\u0434 \u0448\u0435\u043b\u043b\u0430 nix-shell --run \"cargo build\"<\/code><\/pre>\n<p>\u0418 \u0434\u0430\u043b\u044c\u0448\u0435 Nix Package Manager \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432 shell.nix \u0444\u0430\u0439\u043b\u0435. \u0422\u0430\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 Rust \u043f\u0440\u043e\u0435\u043a\u0442\u044b. \u041f\u0440\u0438\u0447\u0435\u043c, \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0432 \/nix\/store \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 nix store gc.<\/p>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u043b\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u0438\u043a \u0432 \u0434\u0435\u043b\u0435 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u043e\u0441\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/h2>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e Nix \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e <a href=\"https:\/\/nix.dev\/tutorials\/cross-compilation\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u043f\u043b\u043e\u0445\u043e<\/a> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e, \u043d\u043e \u043c\u043e\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0437\u044f\u0442\u044c \u0438 \u0432 \u043b\u043e\u0431 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441 \u041c\u0430\u043a\u0430 \u043f\u043e\u0434 \u041b\u0438\u043d\u0443\u043a\u0441 \u0447\u0442\u043e-\u0442\u043e, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0448\u0435\u043b\u043b\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435, \u0441 \u0442\u0440\u0435\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0430\u0441\u044c. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438 Rust \u0438\u0437 Nix \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u043c\u0435\u0435\u0442 \u0432 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0438 \u0435\u0449\u0435 \u043a\u0443\u0447\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f. <\/p>\n<p>\u041d\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/oxalica\/rust-overlay\/tree\/master\/examples\/cross-aarch64\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a<\/a> \u0438 <a href=\"https:\/\/github.com\/ipetkov\/crane\/tree\/master\/examples\/cross-musl\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0432\u0435\u0442\u043e\u0432<\/a> \u043a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0443 \u0432\u0441\u044e \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u044f \u0443\u0436\u0435, \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443\u044f\u0441\u044c \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043f\u043e Nix, \u043d\u0430\u0447\u0430\u043b \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\" rel=\"noopener noreferrer nofollow\">\u043e\u0432\u0435\u0440\u043b\u0435\u0439<\/a> \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0441\u043c\u043e\u0433 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u0438 \u043a\u0435\u0448 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0447\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u0431\u044b\u0441\u0442\u0440\u044f\u0435\u0442 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443 \u0448\u0435\u043b\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443. \u041e\u0447\u0435\u043d\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<\/p>\n<pre><code class=\"bash\">nix-shell -p cachix --run \"cachix use nixpkgs-cross-overlay\"<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0448\u0435\u043b\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 musl \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438 \u043f\u043e\u0434 x86_86 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e <a href=\"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\/tree\/main\/examples\" rel=\"noopener noreferrer nofollow\">\u0442\u0430\u043a\u0438\u043c<\/a> \u0444\u0430\u0439\u043b\u043e\u043c:<\/p>\n<pre><code class=\"haskell\">{ localSystem ? builtins.currentSystem   # Default cross-compilation configuration, you may override it by passing the    # `--arg crossSystem '&lt;our-own-config>'` to `nix-shell`. , crossSystem ? { config = \"x86_64-unknown-linux-musl\"; isStatic = true; useLLVM = true; }   # Override nixpkgs-cross-overlay branch. }: let   # Fetch the nixpkgs-cross-overlay sources.   src = builtins.fetchTarball \"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\/tarball\/main\";   # Use the nixpkgs revision provided by the overlay.    # This is the best way, as they are the most proven and compatible.   nixpkgs = \"${src}\/utils\/nixpkgs.nix\";   # Make cross system packages.   pkgs = import nixpkgs {     inherit localSystem crossSystem;     overlays = [       # &lt;- You may add your extra overlays here.     ];   }; in # And now, with the resulting packages, we can describe the cross-compilation shell. pkgs.mkShell {   # Native project dependencies like build utilities and additional routines    # like container building, linters, etc.   nativeBuildInputs = [     # This overlay also provides the `rust-overlay`, so it is easy to override the default Rust toolchain setup.     # Uncomment this line if you want to use the Rust toolchain provided by this shell.     pkgs.pkgsBuildHost.rust-bin.stable.latest.default     # Will add some dependencies like libiconv.     pkgs.pkgsBuildHost.rustBuildHostDependencies     # Crates dependencies     pkgs.cargoDeps.openssl-sys     pkgs.cargoDeps.prost   ];   # Libraries essential to build the service binaries.   buildInputs = with pkgs; [     # Enable Rust cross-compilation support.     rustCrossHook     # Some native libraries.     icu   ];   # Prettify shell prompt.   shellHook = \"${pkgs.crossBashPrompt}\"; }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"bash\">nix-shell shell.nix<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 libc \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c Linux \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u0435, \u043d\u0443 \u0438\u043b\u0438 \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437. \u041e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c, \u0431\u044b\u0441\u0442\u0440\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0443\u0436\u0435 \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043b\u0430\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435 \u043e\u0442 \u0436\u0438\u0437\u043d\u0438, \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0438 \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0435\u0431\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432 Alpine Linux \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c, \u043d\u043e Nix \u0441\u0430\u043c \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u0414\u043e\u043a\u0435\u0440\u0430 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u043e\u043a\u0435\u0440\u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<h2>Nix dockerTools<\/h2>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"https:\/\/nix.dev\/tutorials\/building-and-running-docker-images\" rel=\"noopener noreferrer nofollow\">dockerTools<\/a> \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Nix, \u043f\u0440\u0438\u0447\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0441\u0430\u043c\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0444\u0430\u0439\u043b\u043e\u0432, \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0439 \u0441 distroless \u043e\u0431\u0440\u0430\u0437\u0430\u043c\u0438, \u0430 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0443\u043b\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0430\u043a-\u0436\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Nix Package Manager. <\/p>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/gist.github.com\/alekseysidorov\/5e027e7574cd47d720324f00c20eeb8e\" rel=\"noopener noreferrer nofollow\">\u0441\u043a\u0440\u0438\u043f\u0442\u0430<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437 \u0438\u0437 \u0432\u044b\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0435\u043c\u0443 Rust \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0430:<\/p>\n<pre><code class=\"haskell\">{ localSystem ? builtins.currentSystem , crossSystem ? { config = \"x86_64-unknown-linux-musl\"; isStatic = true; useLLVM = true; } }: let   # Fetch the nixpkgs-cross-overlay sources.   src = builtins.fetchTarball \"https:\/\/github.com\/alekseysidorov\/nixpkgs-cross-overlay\/tarball\/main\";   # Use the nixpkgs revision provided by the overlay.    # This is the best way, as they are the most proven and compatible.   nixpkgs = \"${src}\/utils\/nixpkgs.nix\";   # Make cross system packages.   pkgs = import nixpkgs {     inherit localSystem crossSystem;     overlays = [       # &lt;- You may add your extra overlays here.     ];   }; in # And now, with the resulting packages, we can describe the cross-compilation shell. pkgs.mkShell {   # Native project dependencies like build utilities and additional routines    # like container building, linters, etc.   nativeBuildInputs = [     pkgs.pkgsBuildHost.rust-bin.stable.latest.default     # Will add some dependencies like libiconv.     pkgs.pkgsBuildHost.rustBuildHostDependencies     # Crates dependencies.     pkgs.cargoDeps.openssl-sys     # A simple script to create a docker image from the Cargo workspace member.     (pkgs.pkgsBuildHost.writeShellApplication {       name = \"cargo-nix-docker-image\";       runtimeInputs = with pkgs.pkgsBuildHost; [         nix         docker       ];       text = let shellFile = .\/shell.nix; in ''         binary_name=$1         # Compile cargo binary         cargo build --release         # Copy this shell to the target dir         cp ${shellFile} .\/target\/shell.nix         # Build docker image from the compiled service         image_archive=$(nix-build .\/target\/shell.nix -A dockerImage --argstr name \"$binary_name\")         docker load &lt;\"$image_archive\"       '';     })   ];   # Libraries essential to build the service binaries.   buildInputs = with pkgs; [     # Enable Rust cross-compilation support.     rustCrossHook   ];   # Prettify shell prompt.   shellHook = ''     ${pkgs.crossBashPrompt}     echo \"Welcome to the Cargo docker images builder demo shell!\"     echo \"\"     echo \"Usage:\"     echo \"\"     echo \"$ cargo-nix-docker-image &lt;executable-name>\"     echo \"\"     echo \"Have a nice day!\"   '';   \/* Service docker image definition     Usage:      ```shell     cargo-nix-docker-image executable-name>     ```   *\/   passthru.dockerImage = (     {       # Cargo workspace member name       name     , tag ? \"latest\"     }:     pkgs.pkgsBuildHost.dockerTools.buildLayeredImage {       inherit tag name;        contents = with pkgs; [         coreutils         bashInteractive         dockerTools.caCertificates         # Actual service binary compiled by Cargo         (copyBinaryFromCargoBuild {           inherit name;           targetDir = .\/.;           buildInputs = [             openssl.dev           ];         })         # Utilites like ldd to help image debugging         stdenv.cc.libc_bin       ];        config = {         Cmd = [ name ];         WorkingDir = \"\/\";         Expose = 8080;       };     }   ); }<\/code><\/pre>\n<p>\u041e\u043d \u0443\u0436\u0435 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0445\u0438\u0442\u0440\u044b\u0439, \u0442\u0443\u0442 shell.nix \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432 \u0434\u0432\u0443\u0445 \u0438\u043f\u043e\u0441\u0442\u0430\u0441\u044f\u0445: \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043a\u0430\u043a \u0430\u043d\u0430\u043b\u043e\u0433 Dockerfile. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043e\u0431\u0440\u0430\u0437 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0430 \u0448\u0430\u0433\u0430:<\/p>\n<pre><code class=\"bash\"># \u0417\u0430\u0439\u0442\u0438 \u0432 \u0448\u0435\u043b\u043b \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346932","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346932"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346932\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}