sys-apps/openrc: stable 0.41.2 for ia64, bug #684900
[gentoo.git] / sys-apps / nix / nix-2.2.1-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools flag-o-matic readme.gentoo-r1 user
7
8 DESCRIPTION="A purely functional package manager"
9 HOMEPAGE="https://nixos.org/nix"
10
11 SRC_URI="http://nixos.org/releases/${PN}/${P}/${P}.tar.xz"
12 LICENSE="LGPL-2.1"
13 SLOT="0"
14 #keywords are blocked by boost-1.66
15 #KEYWORDS="~amd64 ~x86"
16 IUSE="+etc_profile +gc doc s3 sodium"
17
18 # sys-apps/busybox is needed for sandbox mount of /bin/sh
19 RDEPEND="
20         app-arch/brotli
21         app-arch/bzip2
22         app-arch/xz-utils
23         sys-apps/busybox[static]
24         dev-db/sqlite
25         dev-libs/editline:0=
26         dev-libs/openssl:0=
27         >=dev-libs/boost-1.66:0=[context]
28         net-misc/curl
29         sys-libs/libseccomp
30         sys-libs/zlib
31         gc? ( dev-libs/boehm-gc[cxx] )
32         doc? ( dev-libs/libxml2
33                 dev-libs/libxslt
34                 app-text/docbook-xsl-stylesheets
35         )
36         s3? ( dev-libs/aws-sdk-cpp )
37         sodium? ( dev-libs/libsodium:0= )
38 "
39 DEPEND="${RDEPEND}
40         >=sys-devel/bison-2.6
41         >=sys-devel/flex-2.5.35
42 "
43
44 PATCHES=(
45         "${FILESDIR}"/${PN}-1.11.6-systemd.patch
46         "${FILESDIR}"/${PN}-1.11.6-respect-CXXFLAGS.patch
47         "${FILESDIR}"/${PN}-1.11.6-respect-LDFLAGS.patch
48         "${FILESDIR}"/${PN}-2.0-user-path.patch
49 )
50
51 DISABLE_AUTOFORMATTING=yes
52 DOC_CONTENTS=" Quick start user guide on Gentoo:
53
54 [as root] enable nix-daemon service:
55         [systemd] # systemctl enable nix-daemon
56         [openrc]  # rc-update add nix-daemon
57 [as a user] relogin to get environment and profile update
58 [as a user] fetch nixpkgs update:
59         \$ nix-channel --update
60 [as a user] install nix packages:
61         \$ nix-env -i mc
62 [as a user] configure environment:
63         Somewhere in .bash_profile you might want to set
64         LOCALE_ARCHIVE=\$HOME/.nix-profile/lib/locale/locale-archive
65         but please read https://github.com/NixOS/nixpkgs/issues/21820
66
67 Next steps:
68         nix package manager user manual: http://nixos.org/nix/manual/
69 "
70
71 pkg_setup() {
72         enewgroup nixbld
73         for i in {1..10}; do
74                 # we list 'nixbld' twice to
75                 # both assign a primary group for user
76                 # and add a user to /etc/group
77                 enewuser nixbld${i} -1 -1 /var/empty nixbld,nixbld
78         done
79 }
80
81 src_prepare() {
82         default
83
84         eautoreconf
85 }
86
87 src_configure() {
88         if ! use s3; then
89                 # Disable automagic depend: bug #670256
90                 export ac_cv_header_aws_s3_S3Client_h=no
91         fi
92         econf \
93                 --localstatedir="${EPREFIX}"/nix/var \
94                 $(use_enable gc) \
95                 --with-sandbox-shell=/bin/busybox
96 }
97
98 src_compile() {
99         local make_vars=(
100                 OPTIMIZE=0 # disable hardcoded -O3
101                 V=1 # verbose build
102         )
103         emake "${make_vars[@]}"
104 }
105
106 src_install() {
107         # TODO: emacs highlighter
108         default
109
110         readme.gentoo_create_doc
111
112         # here we use an eager variant of something that
113         # is lazily done by nix-daemon and root nix-env
114
115         # TODO: will need a tweak for prefix
116         keepdir             /nix/store
117         fowners root:nixbld /nix/store
118         fperms 1775         /nix/store
119
120         keepdir             /nix/var/nix/channel-cache
121         fperms 0777         /nix/var/nix/channel-cache
122
123         keepdir             /nix/var/nix/profiles/per-user
124         fperms 1777         /nix/var/nix/profiles/per-user
125
126         # setup directories nix-daemon: /etc/profile.d/nix-daemon.sh
127         keepdir             /nix/var/nix/gcroots/per-user
128         fperms 1777         /nix/var/nix/gcroots/per-user
129
130         newinitd "${FILESDIR}"/nix-daemon.initd nix-daemon
131
132         if ! use etc_profile; then
133                 rm "${ED}"/etc/profile.d/nix.sh || die
134                 rm "${ED}"/etc/profile.d/nix-daemon.sh || die
135         fi
136 }
137
138 pkg_postinst() {
139         if ! use etc_profile; then
140                 ewarn "${EROOT}etc/profile.d/nix.sh was removed (due to USE=-etc_profile)."
141         fi
142
143         readme.gentoo_print_elog
144 }