diff options
Diffstat (limited to 'nix')
-rw-r--r-- | nix/.SRCINFO | 23 | ||||
-rw-r--r-- | nix/PKGBUILD | 40 | ||||
-rw-r--r-- | nix/nix.install | 97 |
3 files changed, 160 insertions, 0 deletions
diff --git a/nix/.SRCINFO b/nix/.SRCINFO new file mode 100644 index 0000000..51e5041 --- /dev/null +++ b/nix/.SRCINFO | |||
@@ -0,0 +1,23 @@ | |||
1 | pkgbase = nix | ||
2 | pkgdesc = A purely functional package manager | ||
3 | pkgver = 2.2.2 | ||
4 | pkgrel = 2 | ||
5 | url = https://nixos.org/nix | ||
6 | install = nix.install | ||
7 | arch = i686 | ||
8 | arch = x86_64 | ||
9 | arch = armv7h | ||
10 | license = LGPL | ||
11 | makedepends = bzip2 | ||
12 | makedepends = openssl | ||
13 | depends = gc | ||
14 | depends = libsodium | ||
15 | depends = boost | ||
16 | depends = brotli | ||
17 | depends = editline | ||
18 | depends = dash-static | ||
19 | source = https://nixos.org/releases/nix/nix-2.2.2/nix-2.2.2.tar.xz | ||
20 | sha256sums = f80a1b4f9837a8d33209f0b7769d5038335459ff4303eccf3e9217a9eca8594c | ||
21 | |||
22 | pkgname = nix | ||
23 | |||
diff --git a/nix/PKGBUILD b/nix/PKGBUILD new file mode 100644 index 0000000..8005698 --- /dev/null +++ b/nix/PKGBUILD | |||
@@ -0,0 +1,40 @@ | |||
1 | # Maintainer: Alastair Pharo <asppsa at gmail dot com> | ||
2 | # Contributor: Felix Morgner <felix.morgner@gmail.com> | ||
3 | # Contributor: Vlad M. <vlad@archlinux.net> | ||
4 | # Contributor: Mario Rodas | ||
5 | # Contributor: Oozyslug <oozyslug at gmail dot com> | ||
6 | # Contributor: koral <koral at mailoo dot org> | ||
7 | # Contributor: Anders Bennehag | ||
8 | |||
9 | pkgname=nix | ||
10 | pkgver=2.2.2 | ||
11 | pkgrel=2 | ||
12 | pkgdesc="A purely functional package manager" | ||
13 | arch=('i686' 'x86_64' 'armv7h') | ||
14 | url="https://nixos.org/nix" | ||
15 | license=('LGPL') | ||
16 | depends=('gc' 'libsodium' 'boost' 'brotli' 'editline' 'dash-static') | ||
17 | makedepends=('bzip2' 'openssl') | ||
18 | install=nix.install | ||
19 | source=("https://nixos.org/releases/nix/nix-$pkgver/nix-$pkgver.tar.xz") | ||
20 | sha256sums=('f80a1b4f9837a8d33209f0b7769d5038335459ff4303eccf3e9217a9eca8594c') | ||
21 | |||
22 | prepare() { | ||
23 | cd "$pkgname-$pkgver" | ||
24 | } | ||
25 | |||
26 | build () { | ||
27 | cd "$pkgname-$pkgver" | ||
28 | ./configure --prefix=/usr \ | ||
29 | --libexecdir="/usr/lib/$pkgname" \ | ||
30 | --sysconfdir=/etc \ | ||
31 | --with-sandbox-shell=/usr/bin/dash-static \ | ||
32 | --enable-gc | ||
33 | make | ||
34 | } | ||
35 | |||
36 | package() { | ||
37 | cd "$pkgname-$pkgver" | ||
38 | make DESTDIR="$pkgdir" install | ||
39 | install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE" | ||
40 | } | ||
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 @@ | |||
1 | |||
2 | pre_install () { | ||
3 | # Check that the group and users don't already exist | ||
4 | if [[ -n $(cut -d: -f1 /etc/group | grep -w nixbld) ]]; then | ||
5 | echo "The nixbld group already exists. This install cannot proceed." | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | for i in {1..10}; do | ||
10 | if [[ -n $(cut -d: -f1 /etc/passwd | grep -w nixbld$i) ]]; then | ||
11 | echo "The nixbld$i user already exists. This install cannot proceed." | ||
12 | exit 1 | ||
13 | fi | ||
14 | done | ||
15 | } | ||
16 | |||
17 | create_users () { | ||
18 | # Create a nixbld group. | ||
19 | groupadd -r nixbld | ||
20 | |||
21 | # Create 10 nixbld{i} users | ||
22 | for i in {1..10}; do | ||
23 | useradd -g nixbld -G nixbld -r -N -M -d /var/empty -s /sbin/nologin nixbld$i | ||
24 | done | ||
25 | } | ||
26 | |||
27 | delete_users() { | ||
28 | # Remove the users | ||
29 | for i in {1..10}; do | ||
30 | userdel nixbld$i | ||
31 | done | ||
32 | |||
33 | # Remove the group | ||
34 | groupdel nixbld | ||
35 | } | ||
36 | |||
37 | create_store() { | ||
38 | # Create nix folders and set permissions | ||
39 | mkdir -p /nix/store | ||
40 | chown root.nixbld /nix/store | ||
41 | chmod 1775 /nix/store | ||
42 | mkdir -p -m 1777 /nix/var/nix/gcroots/per-user | ||
43 | mkdir -p -m 1777 /nix/var/nix/profiles/per-user | ||
44 | } | ||
45 | |||
46 | restore_store() { | ||
47 | # Restore folder permissions | ||
48 | chmod 755 /nix/store | ||
49 | chown root.root /nix/store | ||
50 | } | ||
51 | |||
52 | init_channels() { | ||
53 | # Initialize default nix channel | ||
54 | echo "Initializing default nix channel" | ||
55 | source /etc/profile.d/nix.sh | ||
56 | nix-channel --update | ||
57 | } | ||
58 | |||
59 | daemon_info() { | ||
60 | echo "To start the nix daemon, execute one of the following:" | ||
61 | echo | ||
62 | echo " systemctl enable nix-daemon.socket # Sets the daemon to start on next boot" | ||
63 | echo " systemctl enable --now nix-daemon.socket # Starts now and on next boot too" | ||
64 | echo | ||
65 | echo "Also, if this is a new install, you need to start a new login shell or otherwise" | ||
66 | echo | ||
67 | echo " source /etc/profile.d/nix.sh" | ||
68 | echo " source /etc/profile.d/nix-daemon.sh" | ||
69 | echo | ||
70 | echo "Once your environment is set-up, you will need to add some channels. You can see how" | ||
71 | echo "to do that here:" | ||
72 | echo " https://nixos.org/nix/manual/#sec-channels" | ||
73 | } | ||
74 | |||
75 | post_install() { | ||
76 | create_users | ||
77 | create_store | ||
78 | init_channels | ||
79 | daemon_info | ||
80 | } | ||
81 | |||
82 | pre_upgrade() { | ||
83 | systemctl stop nix-daemon.socket | ||
84 | systemctl stop nix-daemon | ||
85 | } | ||
86 | |||
87 | post_upgrade() { | ||
88 | delete_users | ||
89 | create_users | ||
90 | create_store | ||
91 | daemon_info | ||
92 | } | ||
93 | |||
94 | pre_remove() { | ||
95 | restore_store | ||
96 | delete_users | ||
97 | } | ||