Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:luc14n0
nix
nix.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File nix.spec of Package nix
# # spec file for package nix # # Copyright (c) 2023 SUSE LLC # Copyright (c) 2023 Luciano Santos <luc14n0@opensuse.org> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # # TODO # # 1) Patch files instead of overwriting and concatenating/appending # 2) Outweight providing Nix Store with pre-installed nix. # 3) Install SELinux policy. # Nix's configure script relies on bashisms %define _buildshell /bin/bash %define _nixprefix /nix %bcond_without cpuid %bcond_with docs %bcond_without garb_col %bcond_without sandbox %bcond_with tests Name: nix Version: 2.18.0 Release: 0 Summary: The purely functional package manager # nix-bash-completions and nix-zsh-completions are BSD-3-Clause License: LGPL-2.1 AND BSD-3-Clause URL: https://nixos.org/ #GitHub: https://github.com/NixOS/nix Source: %{name}-%{version}.tar #GitHub: https://github.com/hedning/nix-bash-completions Source1: nix-bash-completions.tar #GitHub: https://github.com/nix-community/nix-zsh-completions Source2: nix-zsh-completions.tar Source10: environment.conf Source11: nix.conf Source12: sysusers.conf Source13: tmpfiles.conf Source14: user-tmpfiles.conf #================================ # Build Dependencies Requirements #================================ BuildRequires: autoconf BuildRequires: autoconf-archive BuildRequires: automake BuildRequires: (gcc-c++ >= 11 or gcc11-c++) BuildRequires: libboost_context-devel >= 1.66.0 BuildRequires: pkgconfig BuildRequires: pkgconfig(libarchive) >= 3.1.2 BuildRequires: pkgconfig(libbrotlidec) BuildRequires: pkgconfig(libbrotlienc) BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libcrypto) >= 1.1.1 BuildRequires: pkgconfig(libeditline) >= 1.14.0 BuildRequires: pkgconfig(libsodium) BuildRequires: pkgconfig(lowdown) >= 0.9.0 BuildRequires: pkgconfig(nlohmann_json) >= 3.9 BuildRequires: pkgconfig(sqlite3) >= 3.6.19 #==================================== # Conditional Dependency Requirements #==================================== %if 0%{?sle_version} >= 150400 && 0%{?sle_version} < 160000 BuildRequires: boost-devel %endif %if %{with garb_col} BuildRequires: pkgconfig(bdw-gc) %endif %if %{with sandbox} BuildRequires: pkgconfig(libseccomp) %endif %if %{with cpuid} BuildRequires: pkgconfig(libcpuid) %endif %if %{with tests} BuildRequires: gtest # https://github.com/emil-e/rapidcheck # BuildRequires: rapidcheck %endif #==================== # Looked-for Binaries #==================== # /usr/bin/bash BuildRequires: bash # /usr/bin/bison BuildRequires: bison >= 2.6 # /usr/bin/flex BuildRequires: flex >= 2.5.35 # /usr/bin/dot BuildRequires: graphviz # /usr/bin/jq BuildRequires: jq # /usr/bin/lsof BuildRequires: lsof #=================================== # Additional Dependency Requirements #=================================== BuildRequires: busybox-static BuildRequires: systemd-rpm-macros BuildRequires: sysuser-tools %sysusers_requires Requires(post): util-linux-systemd Requires: busybox-static Requires: nix-prefix %description Nix is a powerful package manager for Linux and other Unix systems that makes package management reliable and reproducible. To get started, in a terminal, use: $ sudo usermod -aG nix-users $USER $ sudo systemctl start nix-daemon $ systemd-tmpfiles --user --create $ nix-channel --update $ nix-env -iA nixpkgs.hello $ hello %package prefix Summary: Nix prefix directory / subvolume Requires(post): util-linux-systemd BuildArch: noarch %description prefix This package provides the %{_nixprefix} directory, or a subvolume, if in a Btrfs system. %package devel Summary: Nix development files Requires: %{name} >= %{version} %description devel Development files to work with Nix package manager. %package bash-completion Summary: Bash Completion for Nix BuildRequires: bash-completion Requires: bash-completion Requires: %{name} = %{version} Supplements: (%{name} and bash-completion) BuildArch: noarch %description bash-completion Bash command line completion support for the Nix package manager. %package fish-completion Summary: Fish Completion for Nix BuildRequires: fish Requires: fish Requires: %{name} = %{version} Supplements: (%{name} and fish) BuildArch: noarch %description fish-completion Fish command line completion support for the Nix package manager. %package zsh-completion Summary: Zsh Completion for Nix BuildRequires: zsh Requires: zsh Requires: %{name} = %{version} Supplements: (%{name} and zsh) BuildArch: noarch %description zsh-completion Zsh command line completion support for the Nix package manager. ############################################################################### # P R E P D I R E C T I V E ############################################################################### %prep %setup -q -D -a1 -a2 # # SED for the win # Since we pass --libdir=%%{_libdir}/nix to configure, we need to fix where # pkgconfig modules end up in. # sed -i '/pkgconfig/ s,$(libdir),%{_libdir},' \ src/lib{cmd,expr,main,store}/local.mk #======================= # Strip unneeded shebang #======================= sed -i -r '/#!(\/usr)?\/bin\/env bash/ s/!/#/' ./nix-bash-completions/_nix ############################################################################### # B U I L D D I R E C T I V E ############################################################################### %build if [ ! -f %{_bindir}/g++ ]; then %define __gxx %(ls -1 %{_bindir}/g++-[0-9][0-9] | tail -1) export CXX=%{__gxx} fi autoreconf -vfi %configure \ --libdir=%{_libdir}/nix \ --localstatedir=%{_nixprefix}/var \ --sysconfdir=%{_sysconfdir} \ --with%{!?with_sandbox:out}-sandbox-shell=%{_bindir}/busybox-static \ --%{?with_garb_col:en}%{!?with_garb_col:dis}able-gc \ --%{?with_sandbox:en}%{!?with_sandbox:dis}able-seccomp-sandboxing \ --%{?with_cpuid:en}%{!?with_cpuid:dis}able-cpuid \ --%{?with_docs:en}%{!?with_docs:dis}able-doc-gen \ --%{?with_tests:en}%{!?with_tests:dis}able-tests \ ; %make_build %sysusers_generate_pre %{SOURCE12} %{name} %{name}.conf ############################################################################### # I N S T A L L D I R E C T I V E ############################################################################### %install %make_install #====================== # Environment variables #====================== install -v -m 0644 -D %{SOURCE10} \ %{buildroot}%{_sysconfdir}/profile.d/nix-env.sh #============== # /etc/nix.conf #============== install -v -m 0644 -D -t %{buildroot}%{_sysconfdir}/nix/ %{SOURCE11} #========= # Sysusers #========= install -v -m 0644 -D %{SOURCE12} %{buildroot}%{_sysusersdir}/nix.conf #========= # Tmpfiles #========= install -v -m 644 -D %{SOURCE13} %{buildroot}%{_tmpfilesdir}/nix.conf install -v -m 644 -D %{SOURCE14} %{buildroot}%{_user_tmpfilesdir}/nix.conf mkdir -p %{buildroot}%{_nixprefix}/store mkdir -p %{buildroot}%{_nixprefix}/var/nix/daemon-socket mkdir -p %{buildroot}%{_nixprefix}/var/nix/db mkdir -p %{buildroot}%{_nixprefix}/var/nix/gcroots/auto mkdir -p %{buildroot}%{_nixprefix}/var/nix/gcroots/per-user mkdir -p %{buildroot}%{_nixprefix}/var/nix/profiles/per-user mkdir -p %{buildroot}%{_nixprefix}/var/nix/temproots mkdir -p %{buildroot}%{_nixprefix}/var/nix/userpool install -v -m 0644 -D /dev/null \ %{buildroot}%{_nixprefix}/var/nix/gcroots/profiles #================ # Bash completion #================ # Supersede upstream's Bash completion script with @hedning's. It provides # completion support not only for the nix command, but also for all nix-foo # commands. install -v -m 0644 -D ./nix-bash-completions/_nix \ %{buildroot}%{_datadir}/bash-completion/completions/nix #=============== # Zsh completion #=============== install -v -m 0644 -D -t %{buildroot}%{_datadir}/zsh/site-functions/ \ ./nix-zsh-completions/_nix-* # TODO: # There's ./nix-zsh-completions/nix-zsh-completions.plugin.zsh that defines # ni='nix-env -iA' and ns='nix-env -qaP' aliases, and prompt_nix_shell_precmd() # to prepend [nix-shell] to the shell prompt when in a nix-shell environment. ############################################################################### # S C R I P T L E T S ############################################################################### %pre -f %{name}.pre %if 0%{?sle_version} < 160000 %service_add_pre nix-daemon.service nix-daemon.socket %endif %post %{_sbindir}/ldconfig %tmpfiles_create %{_tmpfilesdir}/nix.conf %tmpfiles_create %{_tmpfilesdir}/nix-daemon.conf %tmpfiles_create %{_user_tmpfilesdir}/nix.conf %if 0%{?sle_version} < 160000 %service_add_post nix-daemon.service nix-daemon.socket %preun %service_del_preun nix-daemon.service nix-daemon.socket %postun %service_del_postun nix-daemon.service nix-daemon.socket %endif %{_sbindir}/ldconfig %pre prefix if [ "$1" -eq 1 ]; then # ## Add a /nix subvolume before installing Nix, if in a Btrfs file system ## And add a corresponding FSTAB entry # fstab=/etc/fstab root_fstype="$(findmnt -no FSTYPE /)" nix_fstype="$(findmnt -no FSTYPE /nix)" mountdir="$(mktemp --dry-run -d -p /mnt -t btrfs-nix-pre-XXXXXXXXXX)" tmpfstab="$(mktemp --dry-run -t fstab.XXXXXXXXXX)" if [ -s "${fstab}" ]; then root_uuid="$( awk ' /[[:blank:]]\/[[:blank:]]/{ split($1, uuid, "="); print uuid[2] } ' "${fstab}")" var_uuid="$( awk ' /[[:blank:]]\/var[[:blank:]]/{ split($1, uuid, "="); print uuid[2] } ' "${fstab}")" fi trap ' findmnt -m "${mountdir}" > /dev/null 2>&1 \ && umount "${mountdir}" > /dev/null 2>&1 rmdir --ignore-fail-on-non-empty "${mountdir}" findmnt -no FSTYPE /nix > /dev/null 2>&1 \ || rmdir --ignore-fail-on-non-empty /nix rm -f "${tmpfstab}" ' EXIT HUP INT QUIT TERM if [ btrfs = "${root_fstype:-x}" -a btrfs != "${nix_fstype:-x}" ]; then mkdir -p "${mountdir}" if [ -d "${mountdir}" ]; then printf "[Nix] Creating /nix Btrfs subvolume: " mkdir -p /nix mount UUID="${root_uuid}" -o subvolid=0 "${mountdir}" \ && btrfs subvolume create "${mountdir}"/@/nix > /dev/null 2>&1 \ && mount UUID="${root_uuid}" -o subvol=@/nix /nix cp "${fstab}" "${tmpfstab}" test "${var_uuid}" = "${root_uuid}" \ && ! grep -q '[[:blank:]]/nix[[:blank:]]' "${fstab}" \ && sed -n '/[[:blank:]]\/var[[:blank:]]/ s/var/nix/gp' "${fstab}" \ >> "${fstab}" diff "${tmpfstab}" "${fstab}" > /dev/null 2>&1 test $? -eq 1 && printf "SUCCESS\n" || printf "FAIL\n" fi fi exit fi %postun prefix if [ "$1" -eq 0 ]; then # ## Remove the /nix subvolume before unstalling Nix, if in a Btrfs file system ## And remove the currestponding FSTAB entry # fstab=/etc/fstab root_fstype="$(findmnt -no FSTYPE /)" nix_fstype="$(findmnt -no FSTYPE /nix)" mountdir="$(mktemp --dry-run -d -p /mnt -t btrfs-nix-preun-XXXXXXXXXX)" tmpfstab="$(mktemp --dry-run -t fstab.XXXXXXXXXX)" if [ -s "${fstab}" ]; then root_uuid="$(awk '/[[:blank:]]\/[[:blank:]]/{ split($1, uuid, "="); print uuid[2] }' "${fstab}")" var_uuid="$(awk '/[[:blank:]]\/var[[:blank:]]/{ split($1, uuid, "="); print uuid[2] }' "${fstab}")" fi trap ' findmnt -m "${mountdir}" > /dev/null 2>&1 \ && umount "${mountdir}" > /dev/null 2>&1 rmdir --ignore-fail-on-non-empty "${mountdir}" > /dev/null 2>&1 rm -f "${tmpfstab}" ' EXIT HUP INT QUIT TERM if [ btrfs = "${root_fstype}" ] && [ btrfs = "${nix_fstype}" ]; then mkdir -p "${mountdir}" if [ -d "${mountdir}" ]; then printf "[Nix] Deleting /nix Btrfs subvolume: " umount /nix \ && mount UUID="${root_uuid}" -o subvolid=0 "${mountdir}" \ && btrfs subvolume delete "${mountdir}"/@/nix > /dev/null 2>&1 cp "${fstab}" "${tmpfstab}" grep -q '[[:blank:]]/nix[[:blank:]]' "${fstab}" \ && sed -i '/[[:blank:]]\/nix[[:blank:]]/d' "${fstab}" diff "${tmpfstab}" "${fstab}" > /dev/null 2>&1 test $? -eq 1 && echo "SUCCESS" || echo "FAIL" fi fi exit fi ############################################################################### # F I L E S D I R E C T I V E ############################################################################### %files %license COPYING %doc CONTRIBUTING.md README.md %{_bindir}/nix %{_bindir}/nix-build %{_bindir}/nix-channel %if %{with garb_col} %{_bindir}/nix-collect-garbage %endif %{_bindir}/nix-copy-closure %{_bindir}/nix-daemon %{_bindir}/nix-env %{_bindir}/nix-hash %{_bindir}/nix-instantiate %{_bindir}/nix-prefetch-url %{_bindir}/nix-shell %{_bindir}/nix-store %config(noreplace) %{_sysconfdir}/nix/nix.conf %config %{_sysconfdir}/profile.d/nix.fish %config %{_sysconfdir}/profile.d/nix.sh %config %{_sysconfdir}/profile.d/nix-daemon.fish %config %{_sysconfdir}/profile.d/nix-daemon.sh %config(noreplace) %{_sysconfdir}/profile.d/nix-env.sh %exclude %{_sysconfdir}/init/nix-daemon.conf # Private unstable libs %{_libdir}/nix/libnixcmd.so %{_libdir}/nix/libnixexpr.so %{_libdir}/nix/libnixfetchers.so %{_libdir}/nix/libnixmain.so %{_libdir}/nix/libnixstore.so %{_libdir}/nix/libnixutil.so %{_libexecdir}/nix/build-remote %{_sysusersdir}/%{name}.conf %{_tmpfilesdir}/nix.conf %{_tmpfilesdir}/nix-daemon.conf %{_user_tmpfilesdir}/nix.conf %{_unitdir}/nix-daemon.service %{_unitdir}/nix-daemon.socket %dir %{_sysconfdir}/nix %dir %{_libdir}/nix %dir %{_libexecdir}/nix # Created by tmpfiles config file %dir %{_nixprefix}/var %dir %{_nixprefix}/var/nix %dir %{_nixprefix}/var/nix/gcroots %ghost %{_nixprefix}/var/nix/gcroots/profiles #=========== # Nix Prefix #=========== %files prefix %dir %{_nixprefix} #========================================== # Development headers and Pkgconfig modules #========================================== %files devel %{_includedir}/nix/config.h %{_includedir}/nix/*.hh %{_includedir}/nix/*/*.hh %{_libdir}/pkgconfig/nix-cmd.pc %{_libdir}/pkgconfig/nix-expr.pc %{_libdir}/pkgconfig/nix-main.pc %{_libdir}/pkgconfig/nix-store.pc %dir %{_includedir}/nix/ %dir %{_includedir}/nix/build/ %dir %{_includedir}/nix/builtins/ %dir %{_includedir}/nix/flake/ %dir %{_includedir}/nix/value/ #==================== # Nix Bash Completion #==================== %files bash-completion %{_datadir}/bash-completion/completions/nix #==================== # Nix Fish Completion #==================== %files fish-completion %dir %{_datadir}/fish/vendor_completions.d %{_datadir}/fish/vendor_completions.d/nix.fish #=================== # Nix Zsh Completion #=================== %files zsh-completion %dir %{_datadir}/zsh/site-functions %{_datadir}/zsh/site-functions/_nix %{_datadir}/zsh/site-functions/_nix-* %{_datadir}/zsh/site-functions/run-help-nix %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor