system/nix: Added (package manager).

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Pragmatic Cypher 2015-10-28 23:39:04 +07:00 committed by Willy Sudiarto Raharjo
parent 85a7fa26ef
commit 2848fce4b4
6 changed files with 295 additions and 0 deletions

46
system/nix/README Normal file
View file

@ -0,0 +1,46 @@
nix (functional package manager)
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/store/b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z-firefox-33.1/
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 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:
if [ -x /etc/rc.d/rc.nix ]; then
/etc/rc.d/rc.nix start
fi
and to /etc/rc.d/rc.local_shutdown (creating it if needed):
if [ -x /etc/rc.d/rc.nix ]; then
/etc/rc.d/rc.nix stop
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.
chgrp nix-users /nix/var/nix/daemon-socket
chmod ug=rwx,o= /nix/var/nix/daemon-socket
Correct permissions must also be set for the following profile directories to give users access.
/nix/var/nix/profiles
/var/nix/profiles

83
system/nix/config/rc.nix Normal file
View file

@ -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

25
system/nix/doinst.sh Normal file
View file

@ -0,0 +1,25 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
preserve_perms() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD ${NEW}.incoming
cat $NEW > ${NEW}.incoming
mv ${NEW}.incoming $NEW
fi
config $NEW
}
preserve_perms etc/rc.d/rc.nix.new

112
system/nix/nix.SlackBuild Normal file
View file

@ -0,0 +1,112 @@
#!/bin/sh
# Slackware build script for nix
# Copyright 2015 Pragmatic Cypher <slackbuilds@server.ky>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=nix
VERSION=${VERSION:-1.10}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-${VERSION}.tar.xz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--mandir=/usr/man \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--build=$ARCH-slackware-linux \
--host=$ARCH-slackware-linux
make
make install DESTDIR=$PKG
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
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
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
if [ "$ARCH" = "x86_64" ]; then
rm -rf $PKG/usr/lib
fi
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

10
system/nix/nix.info Normal file
View file

@ -0,0 +1,10 @@
PRGNAM="nix"
VERSION="1.10"
HOMEPAGE="http://nixos.org/nix"
DOWNLOAD="https://hydra.nixos.org/build/25489769/download/4/nix-1.10.tar.xz"
MD5SUM="f34dcbdb2d3b9d1e111eaa4b7e52bf5d"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="perl-DBD-SQLite perl-WWW-Curl"
MAINTAINER="Pragmatic Cypher"
EMAIL="slackbuilds@server.ky"

19
system/nix/slack-desc Normal file
View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
nix: nix (package manager)
nix:
nix: The purely functional package manager.
nix:
nix:
nix:
nix:
nix:
nix:
nix:
nix: