nix: Added

This commit is contained in:
Eugen Wissner 2020-11-30 08:59:41 +01:00
parent c684e04e11
commit 49066ca33e
8 changed files with 381 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From d5c7efae3833b4c8d0012c5f9816ae4b6c28a3e7 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Thu, 6 Aug 2020 11:40:41 +0200
Subject: [PATCH] repl.cc: Check for HAVE_BOEHMGC
Fixes #3906.
(cherry picked from commit 59067f0f587f75908c4f990bcbab29340c7f7652)
---
src/nix/repl.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 04bc82cc0..0b696a340 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -31,8 +31,10 @@ extern "C" {
#include "command.hh"
#include "finally.hh"
+#if HAVE_BOEHMGC
#define GC_INCLUDE_NEW
#include <gc/gc_cpp.h>
+#endif
namespace nix {
@@ -44,7 +46,10 @@ namespace nix {
#define ESC_CYA "\033[36m"
#define ESC_END "\033[0m"
-struct NixRepl : gc
+struct NixRepl
+ #if HAVE_BOEHMGC
+ : gc
+ #endif
{
string curDir;
EvalState state;
--
2.28.0

65
nix/README Normal file
View File

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

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

17
nix/fix-Makefile.patch Normal file
View File

@ -0,0 +1,17 @@
Subject: Append CPPFLAGS to GLOBAL_*FLAGS, copy LDFLAGS into GLOBAL_LDFLAGS
Author: Kai Harries <kai.harries@gmail.com>
I (thk@) am not sure what this patch is needed for. I guess so that Debian
specific build options are respected?
--- a/Makefile
+++ b/Makefile
@@ -19,4 +19,8 @@ GLOBAL_CXXFLAGS += -g -Wall -include config.h
-include Makefile.config
+GLOBAL_CFLAGS += $(CPPFLAGS)
+GLOBAL_CXXFLAGS += $(CPPFLAGS)
+GLOBAL_LDFLAGS += $(LDFLAGS)
+
include mk/lib.mk

120
nix/nix.SlackBuild Normal file
View File

@ -0,0 +1,120 @@
#!/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:-2.0.2}
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 {} \;
patch -p1 -i $CWD/fix-Makefile.patch
patch -p1 -i $CWD/0001-repl.cc-Check-for-HAVE_BOEHMGC.patch
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}

10
nix/nix.info Normal file
View File

@ -0,0 +1,10 @@
PRGNAM="nix"
VERSION="2.0.2"
HOMEPAGE="http://nixos.org/nix"
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="libsodium libseccomp"
MAINTAINER="Pragmatic Cypher"
EMAIL="slackbuilds@server.ky"

19
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: