Re: [Nix-dev] How to override/replace part of a service definition?
Hi Michael, On Sun, Feb 22, 2015 at 2:45 PM, Michael Alan Dorman mdor...@jaunder.io wrote: All the documentation I can find about overriding things seems focuses on packages, but what I'm interested in overriding is the systemd pre-start-script. I tried what seemed obvious: { config, ... }: let cfg = config.services.couchdb; in { systemd.services.couchdb.preStart = '' […] ''; } But that appears to have had an *additive* effect---that is, a copy of the modified text appears *after* the existing, non-working, definition. First, you can double check the content of this option without building a system, with $ nixos-option systemd.services.couchdb.preStart The *additive* effect is a feature, which is used in many cases, such as defining fileSystems, systemd.services, and many more. This gives the ability to have a module system where multiple modules can register them-self concurrently in other modules. You can override other modules definitions, almost as you expected, by using mkOverride int value, which has a convenient short-cut named mkForce value, with the force int-priority. This way, you mention that one definition override all the others, as thus ignore all the definitions with a default priority. These properties are briefly described in the Manual [1], and in the Wiki [2]. [1] https://nixos.org/nixos/manual/sec-writing-modules.html#sec-option-definitions [2] https://nixos.org/wiki/NixOS:Modules -- Nicolas Pierron http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/ ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev
[Nix-dev] How to override/replace part of a service definition?
I'm very new to NixOS; perhaps this isn't the correct venue to ask this sort of question, in which case I would appreciate guidance about where better to ask. In trying to use the couchdb package, I found a couple of issues with its pre-start script[1]. My PR (https://github.com/NixOS/nixpkgs/pull/6283) has not yet been merged, and until such time as it is, I would like to override things locally so it will work without manual intervention after each reboot. All the documentation I can find about overriding things seems focuses on packages, but what I'm interested in overriding is the systemd pre-start-script. I tried what seemed obvious: { config, ... }: let cfg = config.services.couchdb; in { systemd.services.couchdb.preStart = '' mkdir -p `dirname ${cfg.uriFile}`; mkdir -p `dirname ${cfg.logFile}`; mkdir -p ${cfg.databaseDir}; mkdir -p ${cfg.viewIndexDir}; touch ${cfg.configFile} touch -a ${cfg.logFile} if [ $(id -u) = 0 ]; then chown ${cfg.user}:${cfg.group} `dirname ${cfg.uriFile}`; (-f ${cfg.uriFile} chown ${cfg.user}:${cfg.group} ${cfg.uriFile}) || true chown ${cfg.user}:${cfg.group} ${cfg.databaseDir} chown ${cfg.user}:${cfg.group} ${cfg.viewIndexDir} chown ${cfg.user}:${cfg.group} ${cfg.configFile} chown ${cfg.user}:${cfg.group} ${cfg.logFile} fi ''; } But that appears to have had an *additive* effect---that is, a copy of the modified text appears *after* the existing, non-working, definition. Any specific remedies, or pointers to specific bits of documentation I've missed---I believe I've combed the wiki pretty thoroughly---would be much appreciated. Mike. 1. After rebooting, checking the service status provides you with: Feb 22 08:42:49 aching systemd[1]: Starting CouchDB Server... Feb 22 08:42:49 aching systemd[1]: couchdb.service: control process exited, code=exited status=1 Feb 22 08:42:49 aching systemd[1]: Failed to start CouchDB Server. Feb 22 08:42:49 aching systemd[1]: Unit couchdb.service entered failed state. Feb 22 08:42:49 aching systemd[1]: couchdb.service failed. Feb 22 08:42:49 aching couchdb-pre-start[1464]: chown: cannot access ‘/var/run/couchdb/couchdb.uri’: No such file or directory Simple inspection reveals commands being run under -e that are not being careful in examining their environment. ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev