Skip to content

Conversation

p-alik
Copy link
Collaborator

@p-alik p-alik commented Sep 8, 2020

This PR aims to support bootstrapping on NixOS

@esabol esabol changed the title add NisOS to supported Linux distirutions add NixOS to supported Linux distirutions Sep 8, 2020
@esabol esabol changed the title add NixOS to supported Linux distirutions Add NixOS to supported Linux distributions Sep 9, 2020
@esabol
Copy link
Member

esabol commented Sep 9, 2020

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

@p-alik
Copy link
Collaborator Author

p-alik commented Sep 10, 2020

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

@p-alik
Copy link
Collaborator Author

p-alik commented Sep 20, 2020

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"

@esabol
Copy link
Member

esabol commented Sep 24, 2020

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
Copy link
Collaborator Author

p-alik commented Sep 25, 2020

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
Copy link
Member

esabol commented Sep 25, 2020

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
Copy link
Member

esabol commented Sep 25, 2020

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
Copy link
Collaborator Author

p-alik commented Sep 25, 2020

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
Copy link
Member

esabol commented Sep 25, 2020

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
Copy link
Collaborator Author

p-alik commented Sep 25, 2020

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
Copy link
Member

esabol commented Sep 25, 2020

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
Copy link
Collaborator Author

p-alik commented Sep 26, 2020

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

  • docker
ba10e3ca04d6:/# ls -l `which nix-env`
lrwxrwxrwx   12 root     root             3 Jun 10 16:45 /root/.nix-profile/bin/nix-env -> nix
ba10e3ca04d6:/# ls -l `which nix`
-r-xr-xr-x    2 root     root       1816736 Jan  1  1970 /root/.nix-profile/bin/nix
  • nix-PC
$ nixos-version 
20.03.2648.69af91469be (Markhor)
$ ll `which nix-env`
lrwxrwxrwx 1 root root 65 Jan  1  1970 /run/current-system/sw/bin/nix-env -> /nix/store/jrl2jxaqzq7si48crdk69brbv6bgqfs7-nix-2.3.6/bin/nix-env

These days Debian testing offers nix package manager.

@SpamapS SpamapS merged commit 4ae0c43 into gearman:master Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants