From: Ismaƫl Bouya Date: Thu, 14 Feb 2019 13:23:37 +0000 (+0100) Subject: Add 'nix/' from commit 'ed04b08b9b4e7c4b8c882450536895592341edcc' X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FAUR.git;a=commitdiff_plain;h=0e3d6dde1abc6a21490653ae17bf43c047c4b3c0;hp=9ee19ca18f89e649f8c6500079b86bd3b6912014 Add 'nix/' from commit 'ed04b08b9b4e7c4b8c882450536895592341edcc' git-subtree-dir: nix git-subtree-mainline: 9ee19ca18f89e649f8c6500079b86bd3b6912014 git-subtree-split: ed04b08b9b4e7c4b8c882450536895592341edcc --- diff --git a/nix/.SRCINFO b/nix/.SRCINFO new file mode 100644 index 0000000..45cfdc5 --- /dev/null +++ b/nix/.SRCINFO @@ -0,0 +1,23 @@ +pkgbase = nix + pkgdesc = A purely functional package manager + pkgver = 2.2.1 + pkgrel = 1 + url = https://nixos.org/nix + install = nix.install + arch = i686 + arch = x86_64 + arch = armv7h + license = LGPL + makedepends = bzip2 + makedepends = gc + makedepends = openssl + depends = gc + depends = libsodium + depends = boost + depends = brotli + depends = readline + source = https://nixos.org/releases/nix/nix-2.2.1/nix-2.2.1.tar.xz + sha256sums = 85f8d3518060803e44e51b1a9ada1a39cea904b36a632ba1844043a0b63be515 + +pkgname = nix + diff --git a/nix/PKGBUILD b/nix/PKGBUILD new file mode 100644 index 0000000..daa8e74 --- /dev/null +++ b/nix/PKGBUILD @@ -0,0 +1,42 @@ +# Maintainer: Alastair Pharo +# Contributor: Felix Morgner +# Contributor: Vlad M. +# Contributor: Mario Rodas +# Contributor: Oozyslug +# Contributor: koral +# Contributor: Anders Bennehag + +pkgname=nix +pkgver=2.2.1 +pkgrel=1 +pkgdesc="A purely functional package manager" +arch=('i686' 'x86_64' 'armv7h') +url="https://nixos.org/nix" +license=('LGPL') +depends=('gc' 'libsodium' 'boost' 'brotli' 'readline') +makedepends=('bzip2' 'gc' 'openssl') +install=nix.install +source=("https://nixos.org/releases/nix/nix-$pkgver/nix-$pkgver.tar.xz") +sha256sums=('85f8d3518060803e44e51b1a9ada1a39cea904b36a632ba1844043a0b63be515') + + +prepare() { + cd "$pkgname-$pkgver" +} + +build () { + cd "$pkgname-$pkgver" + export EDITLINE_CFLAGS="-DREADLINE" + export EDITLINE_LIBS="/usr/lib/libreadline.so" + ./configure --prefix=/usr \ + --libexecdir="/usr/lib/$pkgname" \ + --sysconfdir=/etc \ + --enable-gc + make +} + +package() { + cd "$pkgname-$pkgver" + make DESTDIR="$pkgdir" install + install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/nix/nix.install b/nix/nix.install new file mode 100644 index 0000000..613cee6 --- /dev/null +++ b/nix/nix.install @@ -0,0 +1,97 @@ + +pre_install () { + # Check that the group and users don't already exist + if [[ -n $(cut -d: -f1 /etc/group | grep -w nixbld) ]]; then + echo "The nixbld group already exists. This install cannot proceed." + exit 1 + fi + + for i in {1..10}; do + if [[ -n $(cut -d: -f1 /etc/passwd | grep -w nixbld$i) ]]; then + echo "The nixbld$i user already exists. This install cannot proceed." + exit 1 + fi + done +} + +create_users () { + # Create a nixbld group. + groupadd -r nixbld + + # Create 10 nixbld{i} users + for i in {1..10}; do + useradd -g nixbld -G nixbld -r -N -M -d /var/empty -s /sbin/nologin nixbld$i + done +} + +delete_users() { + # Remove the users + for i in {1..10}; do + userdel nixbld$i + done + + # Remove the group + groupdel nixbld +} + +create_store() { + # Create nix folders and set permissions + mkdir -p /nix/store + chown root.nixbld /nix/store + chmod 1775 /nix/store + mkdir -p -m 1777 /nix/var/nix/gcroots/per-user + mkdir -p -m 1777 /nix/var/nix/profiles/per-user +} + +restore_store() { + # Restore folder permissions + chmod 755 /nix/store + chown root.root /nix/store +} + +init_channels() { + # Initialize default nix channel + echo "Initializing default nix channel" + source /etc/profile.d/nix.sh + nix-channel --update +} + +daemon_info() { + echo "To start the nix daemon, execute one of the following:" + echo + echo " systemctl enable nix-daemon.socket # Sets the daemon to start on next boot" + echo " systemctl enable --now nix-daemon.socket # Starts now and on next boot too" + echo + echo "Also, if this is a new install, you need to start a new login shell or otherwise" + echo + echo " source /etc/profile.d/nix.sh" + echo " source /etc/profile.d/nix-daemon.sh" + echo + echo "Once your environment is set-up, you will need to add some channels. You can see how" + echo "to do that here:" + echo " https://nixos.org/nix/manual/#sec-channels" +} + +post_install() { + create_users + create_store + init_channels + daemon_info +} + +pre_upgrade() { + systemctl stop nix-daemon.socket + systemctl stop nix-daemon +} + +post_upgrade() { + delete_users + create_users + create_store + daemon_info +} + +pre_remove() { + restore_store + delete_users +}