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

environment.systemPackages ignored #65

Closed
paumr opened this issue Jul 31, 2019 · 3 comments
Closed

environment.systemPackages ignored #65

paumr opened this issue Jul 31, 2019 · 3 comments

Comments

@paumr
Copy link
Contributor

paumr commented Jul 31, 2019

{ pkgs, ... }:
{
  docker-compose.services = {
    webserver = { config, pkgs, ... }: {
      nixos.configuration = {config, pkgs, ...}: {
          boot.isContainer = true;
          environment.systemPackages = with pkgs; [
            tree
          ];
      };
      service = {
        command = [  "sh" "-c" "tree" ];
        useHostStore = true;
      };
    };
  };
}

Since environment.systemPackages seems to be ignored, what's the recommended way to manage dependencies?

@domenkozar
Copy link
Contributor

See #40

@roberth
Copy link
Member

roberth commented Jul 31, 2019

There's multiple ways one might make use of NixOS configuration to create a docker image. You can run your service as a NixOS service and enable nixos.useSystemd to set the docker command to systemd. That's the most predictable way to use NixOS. Alternatively you can wire up service.command or image.command like this for example.

If you're not using NixOS by calling its init systemd, there's always a chance that you need something that's normally taken care of by NixOS, like installing certain packages or background services (such as cleaning tmp, reaping zombies etc etc).

So it really depends on your use case. I currently recommend nixos.useSystemd for most cases but if you need to deploy lightweight images, you'll have to use the image options to do some things manually instead. Proper images are a recent addition to Arion, so your mileage may vary with that feature.

@paumr
Copy link
Contributor Author

paumr commented Jul 31, 2019

Alright, thanks!

If someone runs into a similar issue, here's a working example:

{ pkgs, ... }:
{
  docker-compose.services = {
    webserver = { config, pkgs, ... }: {
      nixos.configuration = {config, pkgs, ...}: {
        boot.isContainer = true;
        environment.systemPackages = with pkgs; [
          # will be evaluated if service.command isn't set
          tree
        ];
        system.build.someEntryFun = pkgs.writeScript "someEntryFun" ''
          #!${pkgs.bash}/bin/bash
          ${pkgs.cowsay}/bin/cowsay "dependencies in this script are fetched automatically"
        '';
      };
      nixos.useSystemd = true;
      service = {
        command = [ config.nixos.build.someEntryFun ];
        useHostStore = true;
      };
    };
  };
}

if nixos.command is commented out calling docker exec -it <some-hash> tree will be possible (working since #40).

@paumr paumr closed this as completed Jul 31, 2019
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

3 participants