{"action":"created","issue":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5246","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5246/labels{/name}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5246/comments","events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5246/events","html_url":"https://github.com/NixOS/nixpkgs/pull/5246","id":51190335,"number":5246,"title":"Create service abstraction layer (proposal, prototype)","user":{"login":"offlinehacker","id":585547,"avatar_url":"https://avatars.githubusercontent.com/u/585547?v=3","gravatar_id":"","url":"https://api.github.com/users/offlinehacker","html_url":"https://github.com/offlinehacker","followers_url":"https://api.github.com/users/offlinehacker/followers","following_url":"https://api.github.com/users/offlinehacker/following{/other_user}","gists_url":"https://api.github.com/users/offlinehacker/gists{/gist_id}","starred_url":"https://api.github.com/users/offlinehacker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/offlinehacker/subscriptions","organizations_url":"https://api.github.com/users/offlinehacker/orgs","repos_url":"https://api.github.com/users/offlinehacker/repos","events_url":"https://api.github.com/users/offlinehacker/events{/privacy}","received_events_url":"https://api.github.com/users/offlinehacker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":41,"created_at":"2014-12-06T17:48:01Z","updated_at":"2015-01-13T21:24:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/5246","html_url":"https://github.com/NixOS/nixpkgs/pull/5246","diff_url":"https://github.com/NixOS/nixpkgs/pull/5246.diff","patch_url":"https://github.com/NixOS/nixpkgs/pull/5246.patch"},"body":"Idea\r\n------\r\n\r\nLet's abstract services, so they can be used independently by different process manager like supervisord, docker,... and not only by systemd.\r\n\r\nPreface\r\n----------\r\n\r\nI really like nixos and module definition schema, and i really like to write nixos services. As a developer i want to make these services portable betwene systems independently of process managers if that is possible for speciffic service. Current systemd interface is not right approach and only results in hacks to support its interface(like https://github.com/kiberpipa/nix-rehash/tree/master/nix-services).\r\n\r\nProblems with using systemd interface\r\n---------------------------------------------------\r\n\r\nProblem with using systemd interface as a base for service definitions for other process managers is that service definitions use all features of systemd, even that other process managers do not support them. There are not sufficient nixos options to support lack or presence of if:\r\n\r\n- process manager can handle forking services\r\n- process manager handles logs\r\n- process manager handler logs from syslog\r\n- ... your use case ...\r\n\r\nImplementation\r\n--------------------\r\n\r\nPrototype implementation present in this pull request wants to solve this by abstracting services out of nixos. The reason for abstracting out is that services will not be only used in nixos, but also in other scearios with other process manager and with abscence of nixos on different systems, distros, process virtualization solutions like docker.\r\n\r\nBecause of lack of better idea i defined `sal`(service abstraction layer) interface abstracted into new `service` directory tree. There, service options/configurations are defined and process manager options are present. Real implementation of this schema is present in nixos systemd, which uses `sal` as a base for services.\r\n\r\nI should mention that proposed solution is not usefull for all services and is not ment to replace systemd interface, which is by the way really nice and has a lot of features.\r\n\r\nAlternative implemenations\r\n------------------------------------\r\n\r\nMore straightforward solution would be to make something like `users.services` interface, for defining services. This has a downside, and does not take in account which features different process managers support.\r\n\r\nI would really need this now\r\n-------------------------------------\r\n\r\nI want to ask you, whether you like the proposed implementation or if you have any better idea how to implement this. I would really like to solve the problem, because i need it to make user services and docker implementation using this or similar interface. Without this i can only make hacked implementations(that people use and depend on), like https://github.com/kiberpipa/nix-rehash/tree/master/nix-services, that i later don't want to support, because of hackiness involved.\r\n\r\n**So please review the prototype and please propose better implementations and let's make nix services as portable as possible :)**\r\n\r\n@edolstra @rbvermaa @nbp @iElectric @lethalman @wmertens"},"comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments/69822875","html_url":"https://github.com/NixOS/nixpkgs/pull/5246#issuecomment-69822875","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/5246","id":69822875,"user":{"login":"offlinehacker","id":585547,"avatar_url":"https://avatars.githubusercontent.com/u/585547?v=3","gravatar_id":"","url":"https://api.github.com/users/offlinehacker","html_url":"https://github.com/offlinehacker","followers_url":"https://api.github.com/users/offlinehacker/followers","following_url":"https://api.github.com/users/offlinehacker/following{/other_user}","gists_url":"https://api.github.com/users/offlinehacker/gists{/gist_id}","starred_url":"https://api.github.com/users/offlinehacker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/offlinehacker/subscriptions","organizations_url":"https://api.github.com/users/offlinehacker/orgs","repos_url":"https://api.github.com/users/offlinehacker/repos","events_url":"https://api.github.com/users/offlinehacker/events{/privacy}","received_events_url":"https://api.github.com/users/offlinehacker/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T21:24:15Z","updated_at":"2015-01-13T21:24:15Z","body":"Do you have some ideas how services with different process managers(nixos+systemd, supervisord, docker+fig...) could be tested on all of them(format of tests, debugging of tests,...) ? Testing is really critical feature that has to be in service abstraction layer."}}