[Nix-dev] Questions about ruby app nixpkg

Panagiotis Atmatzidis atma at convalesco.org
Fri Oct 21 13:18:32 CEST 2016


Hi,

I made a nix pkg for ruby web application. I used "bundix" and bundleEnv to handle dependencies. My "installPhase" looks like this:

----
installPhase = ''
     mkdir -p $out/{bin,etc/apibox}
     cp . -r  $out/etc/apibox
     makeWrapper ${env}/bin/pumactl $out/bin/pumactl
'';
----

You can see the the derivation on github[1]. My systemd expression:

----
{ pkgs, ... }:

{ systemd.services.apibox = {
   description = "Start apibox";
   serviceConfig = {
     Type = "forking";
     ExecStart = "${pkgs.apibox}/bin/pumactl -F ${pkgs.apibox}/etc/config/puma.rb start";
     ExecStop  = "${pkgs.apibox}/bin/pumactl -F ${pkgs.apibox}/etc/config/puma.rb stop";
     Restart   = "on-failure";
   };
   wantedBy = [ "default.target" ];
 };

 systemd.services.apibox.enable = true;
}
----

Nix created the following 'ExecStart' line: /nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/bin/pumactl -F /nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/etc/config/puma.rb start

The problem is that " /nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/etc/config/puma.rb" doesn't exist:

---
[root at nixbox:~]# ls  /nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/etc/config/puma.rb
ls: cannot access '/nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/etc/config/puma.rb': No such file or directory
[root at nixbox:~]# find /nix -name puma.rb
/nix/store/jh9l7zzyy1xg3m49h98zk2lfx8ldvdff-apibox-v0.0.2-src/config/puma.rb
/nix/store/9x4mwwwl5yniyr640rx7w9zm87dc2df7-ruby2.3.1-puma-3.6.0/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma.rb
/nix/store/9x4mwwwl5yniyr640rx7w9zm87dc2df7-ruby2.3.1-puma-3.6.0/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/rack/handler/puma.rb
[root at nixbox:~]# find /nix -name pumactl
/nix/store/8w73j2wzwjamvm0ck55dh6s4jx0ky8dl-system-path/bin/pumactl
/nix/store/9x4mwwwl5yniyr640rx7w9zm87dc2df7-ruby2.3.1-puma-3.6.0/bin/pumactl
/nix/store/9x4mwwwl5yniyr640rx7w9zm87dc2df7-ruby2.3.1-puma-3.6.0/lib/ruby/gems/2.3.0/bin/pumactl
/nix/store/9x4mwwwl5yniyr640rx7w9zm87dc2df7-ruby2.3.1-puma-3.6.0/lib/ruby/gems/2.3.0/gems/puma-3.6.0/bin/pumactl
/nix/store/5a086wv9r988d40jnvp7rqlxzsy8nm2q-apibox-0.0.2/bin/pumactl
/nix/store/5a086wv9r988d40jnvp7rqlxzsy8nm2q-apibox-0.0.2/lib/ruby/gems/2.3.0/bin/pumactl
/nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/bin/pumactl
---

So apparently "cp . -r  $out/etc/apibox" and "makeWrapper ${env}/bin/pumactl $out/bin/pumactl" create two different paths. 

I have the following questions:

1) Why does nix create 2 paths for pumactl:
    a) /nix/store/a15kcwkchplhcy7cv5q570lbpr0fchq4-apibox-0.0.2/bin/pumactl
    b) /nix/store/5a086wv9r988d40jnvp7rqlxzsy8nm2q-apibox-0.0.2/bin/pumactl

2) What is the best way to point to the proper configuration file ?

Thanks for your time!

[1]: https://github.com/atmosx/nixpkgs/blob/399d81ac112495abbaaeedaabfe1a047b3c4c00b/pkgs/development/misc/apibox/default.nix


Panagiotis (atmosx) Atmatzidis

email:	atma at convalesco.org
URL:	http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

"Everyone thinks of changing the world, but no one thinks of changing himself.” - Leo Tolstoy



More information about the nix-dev mailing list