From ceabe138cb72b28526a0329bcc81a4af9d3d65b9 Mon Sep 17 00:00:00 2001 From: Pragmatic Cypher Date: Fri, 11 May 2018 14:36:57 +0100 Subject: system/nix: Updated for version 2.0.2. Signed-off-by: David Spencer --- system/nix/README | 80 ++++++++++++++++++++++++++------------------- system/nix/config/rc.nix | 83 +++++++++++++++++++++++++++++++++++++++++++++++ system/nix/nix.SlackBuild | 22 +++++++------ system/nix/nix.info | 8 ++--- system/nix/rc.nix | 75 ------------------------------------------ 5 files changed, 146 insertions(+), 122 deletions(-) create mode 100644 system/nix/config/rc.nix delete mode 100644 system/nix/rc.nix diff --git a/system/nix/README b/system/nix/README index 49ae7c253a9ff..dcfdc6383e722 100644 --- a/system/nix/README +++ b/system/nix/README @@ -1,51 +1,65 @@ -Nix is a purely functional package manager. This means that it treats -packages like values in purely functional programming languages such as -Haskell -- they are built by functions that don't have side-effects, -and they never change after they have been built. Nix stores packages -in the Nix store, usually the directory /nix/store, where each package -has its own unique subdirectory such as +nix (functional package manager) - /nix/store/b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z-firefox-33.1/ +Nix is a purely functional package manager. This means that it treats packages +like values in purely functional programming languages such as Haskell -- they +are built by functions that don't have side-effects, and they never change +after they have been built. Nix stores packages in the Nix store, usually the +directory /nix/store, where each package has its own unique subdirectory such +as -where b6gvzjyb2pg0... is a unique identifier for the package that -captures all its dependencies (it's a cryptographic hash of the -package's build dependency graph). + /nix/store/b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z-firefox-33.1/ -Nix may be run in single or multi-user mode (which requires the -nix-daemon). To have the nix daemon start and stop with your host, -add to /etc/rc.d/rc.local: +where b6gvzjyb2pg0... is a unique identifier for the package that captures all +its dependencies (it's a cryptographic hash of the package's build dependency +graph). - if [ -x /etc/rc.d/rc.nix ]; then +Nix may be run in single or multi-user mode (which requires the nix-daemon). +The following sets up multi-user mode. + +To have the nix daemon start and stop with your host, add to /etc/rc.d/rc.local: + + if [ -x /etc/rc.d/rc.nix ]; then /etc/rc.d/rc.nix start - fi + fi and to /etc/rc.d/rc.local_shutdown (creating it if needed): - if [ -x /etc/rc.d/rc.nix ]; then + if [ -x /etc/rc.d/rc.nix ]; then /etc/rc.d/rc.nix stop - fi + fi + +The daemon requires users for building the nix packages, which should be added +under the 'nixbld' group. + + # groupadd -g 314 nixbld + # for n in $(seq 1 10); do useradd -c "Nix build user $n" \ + # -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(which nologin)" \ + # nixbld$n; done + +Restricting access to the daemon is acheived by setting file permissions for +the daemon's socket's folder. -The daemon requires users for building the nix packages, which should -be added under the 'nixbld' group. + # groupadd nix-users + # chgrp nix-users /nix/var/nix/daemon-socket + # chmod ug=rwx,o= /nix/var/nix/daemon-socket - groupadd -g 314 nixbld - for n in $(seq 1 10); do useradd -c "Nix build user $n" \ - -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(which nologin)" \ - nixbld$n; done +Correct permissions must also be set for the following profile directories to +give users access. -Restricting access to the daemon is acheived by setting file -permissions for the daemon's socket's folder. + # mkdir -p /nix/var/nix/profiles/per-user + # chgrp nix-users /nix/var/nix/profiles/per-user + # chmod go+wt /nix/var/nix/profiles/per-user - groupadd nix-users - chgrp nix-users /nix/var/nix/daemon-socket - chmod ug=rwx,o= /nix/var/nix/daemon-socket + # mkdir -p /nix/var/nix/gcroots/per-user + # chgrp nix-users /nix/var/nix/gcroots/per-user + # chmod go+wt /nix/var/nix/gcroots/per-user -Correct permissions must also be set for the following profile -directories to give users access. +For setup a user to use nix, add him to the nix-users group and load these +lines on login (via $HOME/.profile): - /nix/var/nix/profiles - /var/nix/profiles + export NIX_REMOTE=daemon + source /etc/profile.d/nix.sh If you have patches email me, or send a pull request via github: - https://github.com/PragmaticCypher/slackbuilds + https://github.com/PragmaticCypher/nix.SlackBuild diff --git a/system/nix/config/rc.nix b/system/nix/config/rc.nix new file mode 100644 index 0000000000000..82852934afca6 --- /dev/null +++ b/system/nix/config/rc.nix @@ -0,0 +1,83 @@ +#!/bin/sh + +# Short-Description: Create lightweight, portable, self-sufficient containers. +# Description: +# Docker is an open-source project to easily create lightweight, portable, +# self-sufficient containers from any application. The same container that a +# developer builds and tests on a laptop can run at scale, in production, on +# VMs, bare metal, OpenStack clusters, public clouds and more. + + +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin + +BASE=nix-daemon + +UNSHARE=/usr/bin/unshare +NIX=/usr/bin/$BASE +NIX_PIDFILE=/var/run/$BASE.pid +NIX_LOG=/var/log/nix.log +NIX_OPTS= + +if [ -f /etc/default/$BASE ]; then + . /etc/default/$BASE +fi + +# Check nix is present +if [ ! -x $NIX ]; then + echo "$NIX not present or not executable" + exit 1 +fi + +nix_start() { + echo "starting $BASE ..." + if [ -x ${NIX} ]; then + # If there is an old PID file (no nix-daemon running), clean it up: + if [ -r ${NIX_PIDFILE} ]; then + if ! ps axc | grep nix-daemon 1> /dev/null 2> /dev/null ; then + echo "Cleaning up old ${NIX_PIDFILE}." + rm -f ${NIX_PIDFILE} + fi + fi + nohup "${UNSHARE}" -m -- ${NIX} >> ${NIX_LOG} 2>&1 & + echo $! > ${NIX_PIDFILE} + fi +} + +# Stop nix: +nix_stop() { + echo "stopping $BASE ..." + # If there is no PID file, ignore this request... + if [ -r ${NIX_PIDFILE} ]; then + kill $(cat ${NIX_PIDFILE}) + fi + rm -f ${NIX_PIDFILE} +} + +# Restart docker: +nix_restart() { + nix_stop + nix_start +} + +case "$1" in +'start') + nix_start + ;; +'stop') + nix_stop + ;; +'restart') + nix_restart + ;; +'status') + if [ -f ${NIX_PIDFILE} ] && ps -o cmd $(cat ${NIX_PIDFILE}) | grep -q $BASE ; then + echo "status of $BASE: running" + else + echo "status of $BASE: stopped" + fi + ;; +*) + echo "usage $0 start|stop|restart|status" +esac + +exit 0 diff --git a/system/nix/nix.SlackBuild b/system/nix/nix.SlackBuild index 8925bc1230618..825db7c78a7c7 100644 --- a/system/nix/nix.SlackBuild +++ b/system/nix/nix.SlackBuild @@ -23,7 +23,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=nix -VERSION=${VERSION:-1.11.13} +VERSION=${VERSION:-2.0.2} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} @@ -72,9 +72,10 @@ find -L . \ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ ./configure \ - --mandir=/usr/man \ --prefix=/usr \ --libdir=/usr/lib${LIBDIRSUFFIX} \ + --mandir=/usr/man \ + --docdir=/usr/doc/$PRGNAM-$VERSION \ --sysconfdir=/etc \ --build=$ARCH-slackware-linux \ --host=$ARCH-slackware-linux @@ -82,7 +83,10 @@ CXXFLAGS="$SLKCFLAGS" \ make make install DESTDIR=$PKG -install -D --mode 0755 $CWD/rc.nix $PKG/etc/rc.d/rc.nix.new +find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +install -D --mode 0755 $CWD/config/rc.nix $PKG/etc/rc.d/rc.nix.new mkdir -p $PKG/nix mkdir -p $PKG/var/nix/profiles mkdir -p $PKG/nix/var/nix/profiles @@ -91,13 +95,7 @@ mkdir -p $PKG/nix/var/nix/daemon-socket rm -fr $PKG/etc/init.d rm -fr $PKG/usr/lib/systemd -mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/perl5/vendor_perl -mv $PKG/usr/lib${LIBDIRSUFFIX}/perl5/site_perl/**/**/* $PKG/usr/lib${LIBDIRSUFFIX}/perl5/vendor_perl -rm -r $PKG/usr/lib${LIBDIRSUFFIX}/perl5/site_perl - -if [ "$ARCH" = "x86_64" ]; then - mv $PKG/usr/lib/pkgconfig/ $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/ -fi +mv $PKG/usr/lib/pkgconfig/ $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/ find $PKG/usr/man -type f -exec gzip -9 {} \; for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done @@ -106,6 +104,10 @@ if [ "$ARCH" = "x86_64" ]; then rm -rf $PKG/usr/lib fi +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a COPYING README.md $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh diff --git a/system/nix/nix.info b/system/nix/nix.info index 936272b001479..92e48aae74414 100644 --- a/system/nix/nix.info +++ b/system/nix/nix.info @@ -1,10 +1,10 @@ PRGNAM="nix" -VERSION="1.11.13" +VERSION="2.0.2" HOMEPAGE="http://nixos.org/nix" -DOWNLOAD="http://nixos.org/releases/nix/nix-1.11.13/nix-1.11.13.tar.xz" -MD5SUM="7f12df0c0057ac6d057dee639269403f" +DOWNLOAD="http://nixos.org/releases/nix/nix-2.0.2/nix-2.0.2.tar.xz" +MD5SUM="1cd8ce214c1fd2792e445692c756f63e" DOWNLOAD_x86_64="" MD5SUM_x86_64="" -REQUIRES="perl-DBD-SQLite perl-WWW-Curl libseccomp" +REQUIRES="libsodium libseccomp" MAINTAINER="Pragmatic Cypher" EMAIL="slackbuilds@server.ky" diff --git a/system/nix/rc.nix b/system/nix/rc.nix deleted file mode 100644 index 86f54a25eac1e..0000000000000 --- a/system/nix/rc.nix +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh - -PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin - -BASE=nix-daemon - -UNSHARE=/usr/bin/unshare -NIX=/usr/bin/$BASE -NIX_PIDFILE=/var/run/$BASE.pid -NIX_LOG=/var/log/nix.log -NIX_OPTS= - -if [ -f /etc/default/$BASE ]; then - . /etc/default/$BASE -fi - -# Check nix is present -if [ ! -x $NIX ]; then - echo "$NIX not present or not executable" - exit 1 -fi - -nix_start() { - echo "starting $BASE ..." - if [ -x ${NIX} ]; then - # If there is an old PID file (no nix-daemon running), clean it up: - if [ -r ${NIX_PIDFILE} ]; then - if ! ps axc | grep nix-daemon 1> /dev/null 2> /dev/null ; then - echo "Cleaning up old ${NIX_PIDFILE}." - rm -f ${NIX_PIDFILE} - fi - fi - nohup "${UNSHARE}" -m -- ${NIX} >> ${NIX_LOG} 2>&1 & - echo $! > ${NIX_PIDFILE} - fi -} - -# Stop nix: -nix_stop() { - echo "stopping $BASE ..." - # If there is no PID file, ignore this request... - if [ -r ${NIX_PIDFILE} ]; then - kill $(cat ${NIX_PIDFILE}) - fi - rm -f ${NIX_PIDFILE} -} - -# Restart nix: -nix_restart() { - nix_stop - nix_start -} - -case "$1" in -'start') - nix_start - ;; -'stop') - nix_stop - ;; -'restart') - nix_restart - ;; -'status') - if [ -f ${NIX_PIDFILE} ] && ps -o cmd $(cat ${NIX_PIDFILE}) | grep -q $BASE ; then - echo "status of $BASE: running" - else - echo "status of $BASE: stopped" - fi - ;; -*) - echo "usage $0 start|stop|restart|status" -esac - -exit 0 -- cgit v1.2.3