[Nix-dev] Custom Channel with Custom Modules

Tomasz Czyż tomasz.czyz at gmail.com
Sat Apr 2 22:11:46 CEST 2016


+1 for that question, I would like to know the answer as well.

2016-04-01 16:34 GMT+00:00 Paul Cooley <Paul.Cooley at bazaarvoice.com>:

> We are creating a custom channel with our private artifacts for NixOS.
> This includes setting up users, custom daemons, and etc.
> While I have the channel running without a issue, I DO have problems
> installing daemon services via nixos/configuration.nix.
>
> Keep in mind all this is destined for AWS EC2.
>
> The custom channel will be used alongside the NixOS stable channel. That's
> the background, so to speak.
>
> Now, when I try and install a module, I get a number of errors regarding
> configs, and etc. Here's the code.
>
> { config, bv-nix, ... }:
>
>
> with config;
>
>
> let
>
>    cfg = config.services.bv-users;
>
> in
>
> with bv-nix;
>
>
> {
>
>   ###### interface
>
>
>   options = {
>
>     services.bv-users = {
>
>         enable = mkOption {
>
>             default = true;
>
>             type = with types; bool;
>
>             description = "Enable the service to run.";
>
>         };
>
>
>         groupName = mkOption {
>
>             default = "polloi";
>
>             type = with types; uniq string;
>
>             description = "The group name in nexus";
>
>         };
>
>     };
>
>   };
>
>
>   ###### implementation
>
>     config = mkIf cfg.enable {
>
>         jobs.bv-users = {
>
>             description = "Start the BV User daemon for
> group ${cfg.groupName}.";
>
>             startOn = "started network-interfaces";
>
>             exec = ''/var/setuid-wrappers/sudo -u root
> -- ${bv-users}/bin/key_service.py'';
>
>         };
>
>         security.sudo.enable = true;
>
>     };
>
>
> }
>
> The nixos configuration.nix looks like this:
>
> {
>
>   imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-init.nix>
> <bv-nix/pkgs/bv-users/bv-user-daemon.nix> ];
>
>   ec2.hvm = true;
>
>   services.bv-users.enable = true;
>
>   services.bv-users.groupName = "polloi";
>
> }
>
>
> I've tried various incarnations and looked through the documentation and
> source code, but I'm obviously missing something. One of the errors I get
> from doing a rebuild are:
>
> error: while evaluating the attribute ‘config.system.build.toplevel’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/nixos/lib/eval-config.nix:53:5:
>
> while evaluating the attribute ‘config’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:86:25:
>
> while evaluating ‘yieldConfig’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:73:29,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:72:16:
>
> while evaluating ‘mergeModules’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:173:26,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:63:17:
>
> while evaluating ‘mergeModules'’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:177:36,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:174:5:
>
> while evaluating ‘concatMap’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/lists.nix:62:18,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:213:9:
>
> while evaluating anonymous function at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/lists.nix:170:7,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:63:38:
>
> while evaluating ‘closeModules’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:90:27,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:58:16:
>
> while evaluating anonymous function at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/lists.nix:49:25,
> called from undefined position:
>
> while evaluating anonymous function at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:92:49,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/lists.nix:49:28:
>
> while evaluating ‘unifyModuleSyntax’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:107:34,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:98:11:
>
> while evaluating ‘applyIfFunction’ at
> /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:127:29,
> called
> from /nix/store/21ldmqrpq104n0aq3b8qzdpwamdzza9n-nixos/nixos/nixpkgs/lib/modules.nix:98:39:
>
> undefined variable ‘config’ at
> /nix/store/k86a1d8cyzhn8kj4gsq1nc12vn301f22-user-environment/bv-nix/pkgs/bv-users/bv-user-daemon.nix:8:8
>
> I obviously don't understand what need to be in the channel's default.nix
> to set up imports from the nixos channel so this can work. Or perhaps I'm
> doing something completely wrong. Either way, I'd appreciate comments. I
> plan to write up the results of this particular journey so I can add them
> to the nixos wiki. A lot of companies out there will need custom channels,
> custom module, and custom packages, that cannot be added into the public
> github repository. Therefore I think this a worthwhile endeavor.
>
> Cheers.
> _________________________
>
> [image: Bazaarvoice]
>
> Paul Cooley
> Senior Dev Ops Engineer
> o:   m: 281-435-2328
> e: paul.cooley at bazaarvoice.com
> Site <http://www.bazaarvoice.com/>  |  Blog
> <http://www.bazaarvoice.com/blog>  |  Twitter
> <http://twitter.com/Bazaarvoice>
>
>
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>


-- 
Tomasz Czyż
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160402/7205e606/attachment-0001.html 


More information about the nix-dev mailing list