Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use an existing devShell with nix2docker? #136

Open
arichtman opened this issue Jun 3, 2024 · 0 comments
Open

How to use an existing devShell with nix2docker? #136

arichtman opened this issue Jun 3, 2024 · 0 comments

Comments

@arichtman
Copy link

Hi - thanks so much for the work on nix2docker.

I was wondering if there was a good way to use an existing derivation, namely one made by mkShell.
I'm able to pass the derivation to copyToRoot, but it doesn't seem to symlink anything to /bin, nor put it on $PATH.
I can do it clunkily by interpolating the Nix store location, but this seems like a hack?

{
  description = "A third-party-build container image";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/6132b0f6e344ce2fe34fc051b72fb46e34f668e0";
    nix2container = {
      url = "github:nlewo/nix2container/20aad300c925639d5d6cbe30013c8357ce9f2a2e";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = {nixpkgs, nix2container, self, ... }:
let
  pkgs = import nixpkgs {
    system = "x86_64-linux";
  };
in
rec {
  packages = {
    n2c-image = nix2container.packages.${pkgs.system}.nix2container.buildImage {
      name = "nix-image";
      tag = "n2c";
      copyToRoot = devShell;
      config = {
        Cmd = ["${pkgs.hello}/bin/hello"];
      };
    };
  };
    devShell = pkgs.mkShell {
      buildInputs = [ pkgs.hello ];
  };
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant