summaryrefslogtreecommitdiff
path: root/sys-apps/nix/nix-2.34.6.ebuild
blob: 0b0e72271a6ad8f6cd64985417659197e91f8219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Copyright 2022-2026 BaldEagleOS Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8

inherit linux-info meson readme.gentoo-r1 tmpfiles toolchain-funcs

DESCRIPTION="A purely functional package manager"
HOMEPAGE="https://nixos.org/nix"

SRC_URI="https://github.com/NixOS/nix/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="LGPL-2.1"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+etc-profile doc libressl"

RDEPEND="
	app-arch/brotli
	app-arch/bzip2
	app-arch/xz-utils
	app-misc/jq
	app-text/lowdown-nix
	dev-cpp/gtest
	dev-db/sqlite
	dev-libs/editline:0=
	amd64? ( dev-libs/libcpuid:0= )
	!libressl? ( dev-libs/openssl:0= )
	libressl? ( dev-libs/libressl:0= )
	>=dev-libs/boost-1.66:0=[context]
	net-misc/curl
	sys-apps/busybox[static]
	sys-libs/libseccomp
	dev-libs/libsodium
	dev-libs/blake3
	sys-libs/zlib
	doc? (
		dev-libs/libxml2
		dev-libs/libxslt
		app-text/docbook-xsl-stylesheets
	)
	virtual/libcrypt[static-libs]
"
# add users and groups
RDEPEND+="
	acct-group/nixbld
"
for i in {1..64}; do
	RDEPEND+="
		>=acct-user/nixbld${i}-1
	"
done
DEPEND="${RDEPEND}
	app-text/mdbook
	app-text/mdbook-linkcheck
	dev-cpp/nlohmann_json
	dev-cpp/rapidcheck
	>=sys-devel/bison-2.6
	>=sys-devel/flex-2.5.35
	dev-libs/libgit2
	dev-cpp/toml11
	dev-perl/DBI
	dev-perl/DBD-SQLite
"

# Upstream does not bundle .m4 files, extract from upstreams:
# dev-util/pkgconfig: m4/pkg.m4
# dev-build/autoconf-archive: m4/ax_boost_base.m4, m4/ax_require_defined.m4
DEPEND+="
	dev-build/autoconf-archive
	virtual/pkgconfig
"

DISABLE_AUTOFORMATTING=yes
DOC_CONTENTS=" Quick start user guide on Gentoo:

[as root] enable nix-daemon service:
	[systemd] # systemctl enable nix-daemon && systemctl start nix-daemon
	[openrc]  # rc-update add nix-daemon && /etc/init.d/nix-daemon start
[as a user] relogin to get environment and profile update
[as a user] fetch nixpkgs update:
	\$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
	\$ nix-channel --update
[as a user] install nix packages:
	\$ nix-env -i mc
[as a user] configure environment:
	Somewhere in .bash_profile you might want to set
	LOCALE_ARCHIVE=\$HOME/.nix-profile/lib/locale/locale-archive
	but please read https://github.com/NixOS/nixpkgs/issues/21820

Next steps:
	nix package manager user manual: http://nixos.org/nix/manual/
"

pkg_pretend() {
	# USER_NS is used to run builders in a default setting in linux:
	#     https://nixos.wiki/wiki/Nix#Sandboxing
	local CONFIG_CHECK="~USER_NS"
	check_extra_config
}

src_prepare() {
	default

	# inject our copy of lowdown-nix
	export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}${EPREFIX}/usr/$(get_libdir)/lowdown-nix/lib/pkgconfig"
	export PATH="$PATH:${EPREFIX}/usr/$(get_libdir)/lowdown-nix/bin"

	# inject rapidcheck extra includes
	export CXXFLAGS="${CXXFLAGS} -I${EPREFIX}/usr/include/rapidcheck/extras/gtest/include"
}

src_configure() {
	local emesonargs=(
		--localstatedir="${EPREFIX}"/nix/var
		-Dunit-tests=false
		-Djson-schema-checks=false
		$(meson_use doc doc-gen)
	)

	meson_src_configure
}

src_compile() {
	# Upstream does not support building without installation.
	# Rely on src_install's DESTDIR=.
	:
}

src_install() {
	default

	readme.gentoo_create_doc

	# Follow the steps of 'scripts/install-multi-user.sh:create_directories()'
	local dir dirs=(
		/nix
		/nix/var
		/nix/var/log
		/nix/var/log/nix
		/nix/var/log/nix/drvs
		/nix/var/nix{,/db,/gcroots,/profiles,/temproots,/userpool,/daemon-socket}
		/nix/var/nix/{gcroots,profiles}/per-user
	)
	for dir in "${dirs[@]}"; do
		keepdir "${dir}"
		fperms 0755 "${dir}"
	done

	keepdir             /nix/store
	fowners root:nixbld /nix/store
	fperms 1775         /nix/store

	newinitd "${FILESDIR}"/nix-daemon.initd nix-daemon

	if ! use etc-profile; then
		rm "${ED}"/etc/profile.d/nix.sh || die
	fi
}

pkg_postinst() {
	if ! use etc-profile; then
		ewarn "${EROOT}/etc/profile.d/nix.sh was removed (due to USE=-etc-profile)."
	fi

	readme.gentoo_print_elog
	tmpfiles_process nix-daemon.conf
}