I am trying to setup a NIXOS server as NIS server.
ypbind-mt, ypserv and yp-tools seem to be minumum under Linux, if I understand the system correctly. But unfortunately only ypbind-mt has been ported.
So I started working on ypserve.
I did some research and if I understand the circumstances correctly, the most fitting way would be to turn the Linux package’s source code into a NixOS package by making a derivation that compiles the source code to be fitting with NixOS.
But I struggle getting
#include <rpcsvc/yp_prot.h>
to work.
I am not sure if I have been correct at choosing the NixOS package rpcsvc-proto as source for this incluse. Should I have used glibc? Or is there an other better fitting one?
Is my compilation configuration correct?
Or is my error somewhere else?
I have been searching for some time, but now I am entirely stuck at this #include problem.
Here the relevant files:
Excerpts from configuration.nix
[...]
# Use latest kernel.
boot.kernelPackages = pkgs.linuxPackages_latest;
[...]
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
gedit
# Recommended for develoment, e.g. code search:
git ripgrep
nix-index
# Compiler:
gcc
# libraries
gdbm
#rpclib
libtirpc # rpc
rpcsvc-proto
glibc#.dev
(glibcLocales.override { locales = [ "en_US.UTF-8" ]; })
ypbind-mt
#Not directly possible:
#ypserv
#yp-tools
];
[...]
system.stateVersion = "25.11";
}
In the folder ypserv (it is for the files that I use to make the derivation):
default.nix:
# default.nix
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
{
ypserv = pkgs.callPackage ./ypserv.nix { };
}
ypserv.nix:
# ypserv.nix
{
stdenv,
fetchFromGitHub,
fetchzip,
gdbm,
#gcc, # Doesn't seem to be necessary.
libtirpc,
rpcsvc-proto
}:
stdenv.mkDerivation {
pname = "ypserv";
version = "4.2";
#src = fetchFromGitHub {
# owner = "thkukuk";
# repo = "ypserv";
# rev = "4.2";
# sha256 = "sha256-qio4zCbOj8VjSPkP5oxI07GOd2WTLmGq2d72gZpOjXY=";
#};
src = fetchzip {
url = "https://github.com/thkukuk/ypserv/releases/download/v4.2/ypserv-4.2.tar.xz";
sha256 = "sha256-hUr1RKLSyEaitOJ7CBgKnVIDew97tkNnEk3uojrcHag=";
};
# NixOS counter part for "./configure CFLAGS=-I/usr/include/tirpc" under Linux
# Ensure the compiler finds the headers
NIX_CFLAGS_COMPILE = "-I${libtirpc.dev}/include/tirpc"; # Needed for #include <rpc/rpc.h>
# How to get #include <rpcsvc/yp_prot.h> working?
# Ensure the linker finds the library
#NIX_LDFLAGS = "-ltirpc"; # Seems not to be necessary if libtirpc is listed in nativeBuildInputs
nativeBuildInputs = [
libtirpc
rpcsvc-proto
#pkg-config # Often needed to find headers
];
buildInputs = [
gdbm
#gcc
libtirpc
rpcsvc-proto
];
}
Console command and output:
[servertestuser5@nixos:~/packaging_existing_software/ypserv]$ nix-build -A ypserv
unpacking 'https://github.com/NixOS/nixpkgs/tarball/nixos-24.05' into the Git cache...
this derivation will be built:
/nix/store/wf8680ykmgc2vawq2fz2dr72dnbdq4dw-ypserv-4.2.drv
building '/nix/store/wf8680ykmgc2vawq2fz2dr72dnbdq4dw-ypserv-4.2.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/hjf5na4iyr50dcwf8qg989wcbr0242iq-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
patching script interpreter paths in ./configure
./configure: interpreter directive changed from "#! /bin/sh" to "/nix/store/1jzhbwq5rjjaqa75z88ws2b424vh7m53-bash-5.2p32/bin/sh"
configure flags: --disable-dependency-tracking --prefix=/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2
checking for a BSD-compatible install... /nix/store/n9gh8gxx5xx51ihgll2l20ar9b2vmgzy-coreutils-9.5/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /nix/store/n9gh8gxx5xx51ihgll2l20ar9b2vmgzy-coreutils-9.5/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... none
checking for library containing strerror... none required
checking how to run the C preprocessor... gcc -E
checking whether make sets $(MAKE)... (cached) yes
checking for ranlib... ranlib
checking for grep that handles long lines and -e... /nix/store/8nss7h1yk4jihkmr4xj5ihrbdkv4y1wy-gnugrep-3.11/bin/grep
checking for egrep... /nix/store/8nss7h1yk4jihkmr4xj5ihrbdkv4y1wy-gnugrep-3.11/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for __attribute__... yes
checking for -fpie... yes
checking whether byte ordering is bigendian... no
checking size of long... 8
checking for mawk... no
checking for gawk... /nix/store/jziybc6yn78sf0bbh0kmmx50bxjsnr15-gawk-5.2.2/bin/gawk
checking for bash... /nix/store/1jzhbwq5rjjaqa75z88ws2b424vh7m53-bash-5.2p32/bin/bash
checking for gmake... no
checking for make... /nix/store/0554jm1l1qw1pcfqsliw91hnifn11w8m-gnumake-4.4.1/bin/make
checking for aliases... /etc/mail/aliases
checking for --with-dbmliborder...
checking for gdbm_open in -lgdbm... yes
checking for crypt in -lcrypt... no
checking crypt.h usability... no
checking crypt.h presence... no
checking for crypt.h... no
checking for pkg-config... no
checking for libnsl... no
checking for yp_match in -lnsl... no
checking for libtirpc... no
checking for getrpcport... no
checking for rpcb_getaddr... no
checking for libsystemd >= 209... no
checking for res_gethostbyname in -lresolv... no
checking for gethostbyname in -lresolv+... no
checking for xsltproc... no
checking for xmllint... /bin/true
checking for XML catalog (/etc/xml/catalog)... not found
checking for xmlcatalog... no
checking for DocBook XML DTD V4.3 in XML catalog... not found
checking for DocBook XSL Stylesheets in XML catalog... not found
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating etc/Makefile
config.status: creating ypserv/Makefile
config.status: creating ypxfr/Makefile
config.status: creating yppush/Makefile
config.status: creating makedbm/Makefile
config.status: creating mknetid/Makefile
config.status: creating revnetgroup/Makefile
config.status: creating rpc.yppasswdd/Makefile
config.status: creating rpc.ypxfrd/Makefile
config.status: creating yphelper/Makefile
config.status: creating scripts/Makefile
config.status: creating scripts/ypxfr_1perhour
config.status: creating scripts/ypxfr_1perday
config.status: creating scripts/ypxfr_2perday
config.status: creating scripts/pwupdate
config.status: creating scripts/create_printcap
config.status: creating scripts/match_printcap
config.status: creating scripts/ypinit
config.status: creating scripts/ypMakefile
config.status: creating config.h
config.status: executing depfiles commands
Configuration:
Source code location: .
Compiler: gcc
Compiler flags: -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes
Preprocessor: gcc -E
Preprocessor flags:
Libraries: -lgdbm
Awk: /nix/store/jziybc6yn78sf0bbh0kmmx50bxjsnr15-gawk-5.2.2/bin/gawk
Shell: /nix/store/1jzhbwq5rjjaqa75z88ws2b424vh7m53-bash-5.2p32/bin/bash
NIS map dir: /var/yp
Install path prefix: /nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2
Install ypserv.conf in: /nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc
Allow root password: yes
Use FQDN as master name: 1
Notify systemd: 0
Running phase: buildPhase
build flags: SHELL=/nix/store/1jzhbwq5rjjaqa75z88ws2b424vh7m53-bash-5.2p32/bin/bash
/nix/store/0554jm1l1qw1pcfqsliw91hnifn11w8m-gnumake-4.4.1/bin/make all-recursive
make[1]: Entering directory '/build/source'
Making all in etc
make[2]: Entering directory '/build/source/etc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/build/source/etc'
Making all in lib
make[2]: Entering directory '/build/source/lib'
gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o log_msg.o log_msg.c
gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o ypserv_conf.o ypserv_conf.c
gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o ypxfrd_xdr.o ypxfrd_xdr.c
gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o ypproc_match_2.o ypproc_match_2.c
In file included from ypproc_match_2.c:22:
yp.h:10:10: fatal error: rpcsvc/yp_prot.h: No such file or directory
10 | #include <rpcsvc/yp_prot.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:603: ypproc_match_2.o] Error 1
make[2]: Leaving directory '/build/source/lib'
make[1]: *** [Makefile:394: all-recursive] Error 1
make[1]: Leaving directory '/build/source'
make: *** [Makefile:335: all] Error 2
error: Cannot build '/nix/store/wf8680ykmgc2vawq2fz2dr72dnbdq4dw-ypserv-4.2.drv'.
Reason: builder failed with exit code 2.
Output paths:
/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2
Last 25 log lines:
>
> Running phase: buildPhase
> build flags: SHELL=/nix/store/1jzhbwq5rjjaqa75z88ws2b424vh7m53-bash-5.2p32/bin/bash
> /nix/store/0554jm1l1qw1pcfqsliw91hnifn11w8m-gnumake-4.4.1/bin/make all-recursive
> make[1]: Entering directory '/build/source'
> Making all in etc
> make[2]: Entering directory '/build/source/etc'
> make[2]: Nothing to be done for 'all'.
> make[2]: Leaving directory '/build/source/etc'
> Making all in lib
> make[2]: Entering directory '/build/source/lib'
> gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o log_msg.o log_msg.c
> gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o ypserv_conf.o ypserv_conf.c
> gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o ypxfrd_xdr.o ypxfrd_xdr.c
> gcc -DHAVE_CONFIG_H -D_REENTRANT=1 -DCONFDIR=\"/nix/store/1vmr70c5hfpih640q5jmbvg0bbdnd6gd-ypserv-4.2/etc\" -DYPMAPDIR=\"/var/yp\" -DUSE_SD_NOTIFY=0 -I. -I.. -I.. -I.. -I. -fpie -Werror -g -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wstrict-prototypes -c -o ypproc_match_2.o ypproc_match_2.c
> In file included from ypproc_match_2.c:22:
> yp.h:10:10: fatal error: rpcsvc/yp_prot.h: No such file or directory
> 10 | #include <rpcsvc/yp_prot.h>
> | ^~~~~~~~~~~~~~~~~~
> compilation terminated.
> make[2]: *** [Makefile:603: ypproc_match_2.o] Error 1
> make[2]: Leaving directory '/build/source/lib'
> make[1]: *** [Makefile:394: all-recursive] Error 1
> make[1]: Leaving directory '/build/source'
> make: *** [Makefile:335: all] Error 2
For full logs, run:
nix-store -l /nix/store/wf8680ykmgc2vawq2fz2dr72dnbdq4dw-ypserv-4.2.drv