gearman / gearmand

http://gearman.org/
Other
741 stars 138 forks source link

Add NixOS to supported Linux distributions #309

Closed p-alik closed 2 years ago

p-alik commented 4 years ago

This PR aims to support bootstrapping on NixOS

esabol commented 4 years ago

Do you have a Dockerfile for testing this, @p-alik ?

p-alik commented 4 years ago

No I haven't it yet, but I'll prepare once.

p-alik commented 4 years ago

On fddd82e8944974daf3ed32d15002c488a721dd7b docker build . succeeds with this Dockerfile:

FROM nixos/nix
WORKDIR /opt/gearmand
ADD . .
RUN nix-shell --packages autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx \
              --run "bash && ./bootstrap.sh -a && ./configure --with-mysql=no --with-postgresql=no --with-boost=$(nix-build --no-out-link '<nixpkgs>' -A boost) --with-boost-libdir=$(nix-build --no-out-link '<nixpkgs>' -A boost.out)/lib && make && make test"
esabol commented 4 years ago

On fddd82e docker build . succeeds with this Dockerfile:

FROM nixos/nix
WORKDIR /opt/gearmand
ADD . .
RUN nix-shell --packages autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx \
              --run "bash && ./bootstrap.sh -a && ./configure --with-mysql=no --with-postgresql=no --with-boost=$(nix-build --no-out-link '<nixpkgs>' -A boost) --with-boost-libdir=$(nix-build --no-out-link '<nixpkgs>' -A boost.out)/lib && make && make test"

Hi, @p-alik. Thank you for the above.

The extra configure arguments should not be needed. Something is broken if they are needed, IMHO.

Any idea as to why nix-env --install autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx fails with

warning: there are multiple derivations named 'git-2.26.2'; using the first one
error: selector 'libuuid' matches no derivations

If I remove libuuid from that list, I then get

error: selector 'python37Packages.sphinx' matches no derivations

Using nixos/nix:latest:

97a3ebb198b7:/# nix-env --install libuuid
error: selector 'libuuid' matches no derivations
97a3ebb198b7:/# nix-env --install python37Packages.sphinx
error: selector 'python37Packages.sphinx' matches no derivations
97a3ebb198b7:/# nix-env --version
nix-env (Nix) 2.3.6
p-alik commented 4 years ago

You could run nix-env -f '<nixpkgs>' --install -A autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx if you intend to use nix-env. As mentioned here nix-shell appears to me more appropriate for the purpose of development.

esabol commented 4 years ago

You could run nix-env -f '<nixpkgs>' --install -A autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx if you intend to use nix-env. As mentioned here nix-shell appears to me more appropriate for the purpose of development.

I can see their point for when it comes to distributing an image, but it doesn't fit how I test builds.

Your new nix-env command gives me the following errors:

error: packages '/nix/store/jijd3hi94w5nwzrd9ihvs34q69hx0vcd-boost-1.69.0/lib/libboost_context.so' and '/nix/store/j8dbv5w6jl34caywh2ygdy88knx1mdf7-nix-2.3.6/lib/libboost_context.so' have the same priority 5; use 'nix-env --set-flag priority NUMBER INSTALLED_PKGNAME' to change the priority of one of the conflicting packages (0 being the highest priority)
builder for '/nix/store/746clhr2530ra1xfsj67v7ly9v0hak15-user-environment.drv' failed with exit code 1
error: build of '/nix/store/746clhr2530ra1xfsj67v7ly9v0hak15-user-environment.drv' failed
esabol commented 4 years ago

I split up the nix-env and got it to work.

nix-env --install \
    autoconf \
    automake \
    bash \
    boost \
    git \
    gperf \
    libevent \
    libtool \
    openssl \
 && nix-env -f '<nixpkgs>' --install -A \
    gcc \
    m4 \
    libuuid \
    python37Packages.sphinx

I had to add m4 and gcc, by the way.

./configure can't find boost though, and the nix-build --no-out-link '<nixpkgs>' -A boost command does not work as non-root user.

error: could not set permissions on '/nix/var/nix/profiles/per-user' to 755: Operation not permitted

Wow, this nix package manager is super-annoying!

p-alik commented 4 years ago

Wow, this nix package manager is super-annoying!

In my opinion because you are trying to install all dependencies with nix-env. All will be fine, if you'll switch to nix-shell: nix-shell --packages autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx

esabol commented 4 years ago

Wow, this nix package manager is super-annoying!

In my opinion because you are trying to install all dependencies with nix-env. All will be fine, if you'll switch to nix-shell: nix-shell --packages autoconf automake bash boost git gperf libevent libtool libuuid python37Packages.sphinx

Only if you build gearmand as root, I think, and I don't want to do that.

p-alik commented 4 years ago

Only if you build gearmand as root, I think, and I don't want to do that.

You can run nix-shell (and nix-env --install as well) as usual user. What I've put into a Dockerfile is a subset of shell.nix, which I'm using to start nix-shell. It looks like:

let
  sources = import ./nix/sources.nix;
  pkgs = import sources.nixpkgs {};
in
pkgs.mkShell {
  buildInputs = [
    pkgs.boost
    pkgs.boost.dev
    pkgs.boost.out
    pkgs.file
    pkgs.libevent
    pkgs.libuuid
    pkgs.libtool
    pkgs.hiredis
    pkgs.python37Packages.sphinx
    pkgs.gperf
    pkgs.autoconf
    pkgs.automake
    # keep this line if you use bash
    pkgs.bashInteractive
  ];

  nativeBuilds = [
    pkgs.gcc8
    pkgs.pkgconfig
  ];

  shellHook =''
cat <<'HERE'
To build gearmand:

cd gearmand
./bootstrap.sh -a
./configure --with-mysql=no --with-postgresql=no --with-boost=$(nix-build --no-out-link '<nixpkgs>' -A boost) --with-boost-libdir=$(nix-build --no-out-link '<nixpkgs>' -A boost.out)/lib
HERE
'';
}
esabol commented 4 years ago

Only if you build gearmand as root, I think, and I don't want to do that.

You can run nix-shell (and nix-env --install as well) as usual user.

Well, it doesn't work for me, at least not using the nixos/nix image. The nix-* commands in that Docker image only work as root.

p-alik commented 4 years ago

There are differences between nix-docker and PC (VM surely also) environment:

These days Debian testing offers nix package manager.