Giter Club home page Giter Club logo

Comments (3)

domenkozar avatar domenkozar commented on June 15, 2024

See #40

from arion.

roberth avatar roberth commented on June 15, 2024

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.

from arion.

paumr avatar paumr commented on June 15, 2024

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).

from arion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.