summaryrefslogtreecommitdiff
path: root/private/nix
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-12-09 18:28:42 +0100
committerEugen Wissner <belka@caraus.de>2020-12-09 18:28:42 +0100
commit2910a89d6c59b997a3896f05c6ad7fb65c26f813 (patch)
tree3d3edebdf32b0c972e8449b82be2c10742395d6c /private/nix
parentbe64bc6dbb9d0f717f7cbdd83d9371de979d4c63 (diff)
downloadslackbuilder-2910a89d6c59b997a3896f05c6ad7fb65c26f813.tar.gz
Add autoupdater
Diffstat (limited to 'private/nix')
-rw-r--r--private/nix/README65
-rw-r--r--private/nix/config/rc.nix83
-rw-r--r--private/nix/doinst.sh25
-rw-r--r--private/nix/nix.SlackBuild118
-rw-r--r--private/nix/nix.info10
-rw-r--r--private/nix/slack-desc19
6 files changed, 320 insertions, 0 deletions
diff --git a/private/nix/README b/private/nix/README
new file mode 100644
index 0000000..dcfdc63
--- /dev/null
+++ b/private/nix/README
@@ -0,0 +1,65 @@
+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).
+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
+
+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.
+
+ # groupadd nix-users
+ # 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.
+
+ # 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
+
+ # 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
+
+For setup a user to use nix, add him to the nix-users group and load these
+lines on login (via $HOME/.profile):
+
+ 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/nix.SlackBuild
diff --git a/private/nix/config/rc.nix b/private/nix/config/rc.nix
new file mode 100644
index 0000000..8285293
--- /dev/null
+++ b/private/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/private/nix/doinst.sh b/private/nix/doinst.sh
new file mode 100644
index 0000000..032197f
--- /dev/null
+++ b/private/nix/doinst.sh
@@ -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
diff --git a/private/nix/nix.SlackBuild b/private/nix/nix.SlackBuild
new file mode 100644
index 0000000..871e5c5
--- /dev/null
+++ b/private/nix/nix.SlackBuild
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# Slackware build script for nix
+
+# Copyright 2015 Pragmatic Cypher <slackbuilds@server.ky>
+# Copyright 2020 Eugen Wissner, Dachau, Germany
+# 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:-2.3.9}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+
+if [ -z "$ARCH" ]; then
+ case "$( uname -m )" in
+ i?86) ARCH=i586 ;;
+ arm*) ARCH=arm ;;
+ *) ARCH=$( uname -m ) ;;
+ esac
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -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 \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/$PRGNAM-$VERSION \
+ --sysconfdir=/etc \
+ --with-sandbox-shell=/bin/bash \
+ --build=$ARCH-slackware-linux \
+ --host=$ARCH-slackware-linux
+
+make
+make install DESTDIR=$PKG
+
+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
+mkdir -p $PKG/nix/var/nix/daemon-socket
+
+rm -fr $PKG/etc/init.d
+rm -fr $PKG/usr/lib/systemd
+
+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/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
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
diff --git a/private/nix/nix.info b/private/nix/nix.info
new file mode 100644
index 0000000..477c931
--- /dev/null
+++ b/private/nix/nix.info
@@ -0,0 +1,10 @@
+PRGNAM="nix"
+VERSION="2.3.9"
+HOMEPAGE="http://nixos.org/nix"
+DOWNLOAD="http://nixos.org/releases/nix/nix-2.3.9/nix-2.3.9.tar.xz"
+MD5SUM="1b8b35a2c7870b320598bb7179e8fb13"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES="editline libseccomp"
+MAINTAINER="Pragmatic Cypher"
+EMAIL="slackbuilds@server.ky"
diff --git a/private/nix/slack-desc b/private/nix/slack-desc
new file mode 100644
index 0000000..4fac728
--- /dev/null
+++ b/private/nix/slack-desc
@@ -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: