File nim.spec of Package nim
Name: nim
Version: 2.2.4
Release: 0%{?dist}
Summary: A statically typed compiled systems programming language
License: MIT
Group: Development/Languages/Other
URL: https://nim-lang.org/
Source0: https://nim-lang.org/download/nim-%{version}.tar.xz
Source1: atlas-latest.tar
Source2: sat-latest.tar
BuildRequires: binutils-devel
BuildRequires: ca-certificates
BuildRequires: ca-certificates-mozilla
# Nim needs support for both __builtin_saddll_overflow and
# -std=c++14, therefore gcc 6.2+ is required.
BuildRequires: gcc-c++ >= 6.2
BuildRequires: git
BuildRequires: libopenssl-devel
BuildRequires: netcfg
BuildRequires: sqlite3-devel
BuildRequires: timezone
BuildRequires: valgrind
BuildRequires: pkgconfig(libpcre2-posix)
Requires: gcc
Recommends: nodejs
Recommends: git
Recommends: libpcre2-8-0
Suggests: clang
ExclusiveArch: x86_64
%description
Nim is a statically typed compiled systems programming language. It
combines successful concepts from mature languages like Python, Ada
and Modula.
Efficient:
* Nim generates native dependency-free executables, not dependent on
a virtual machine, which are small and allow easy redistribution.
* The Nim compiler and the generated executables support all major
platforms like Windows, Linux, BSD and macOS.
* Nim's memory management is deterministic and customizable with
destructors and move semantics, inspired by C++ and Rust. It is
well-suited for embedded, hard-realtime systems.
* Modern concepts like zero-overhead iterators and compile-time
evaluation of user-defined functions, in combination with the
preference of value-based datatypes allocated on the stack, lead
to extremely performant code.
* Support for various backends: it compiles to C, C++ or JavaScript
so that Nim can be used for all backend and frontend needs.
Expressive:
* Nim is self-contained: the compiler and the standard library are
implemented in Nim.
* Nim has a powerful macro system which allows direct manipulation
of the AST, offering nearly unlimited opportunities.
Elegant:
* Macros cannot change Nim's syntax because there is no need for it
— the syntax is flexible enough.
* Modern type system with local type inference, tuples, generics and
sum types.
* Statements are grouped by indentation but can span multiple lines.
%prep
%setup -q -a 1 -a 2
for i in *-latest;do mv "$i" "dist/${i//-latest/}";done
mkdir -p dist/atlas/dist
cp -a dist/sat dist/atlas/dist/sat
%build
export CFLAGS="%{optflags}"
export NIMFLAGS="$(echo '%{optflags}' | sed 's/\([^[:space:]]\+\)/--passC:\1/g')"
export NIMFLAGS="$NIMFLAGS %{?jobs:--parallelBuild:%{jobs}}"
# force NimMain to always be N_LIB_PRIVATE for WinDlls
sed -i '/^ *WinNimDllMain = NimMainInner & "N_LIB_EXPORT " & NimMainProc$/s/N_LIB_EXPORT/N_LIB_PRIVATE/' compiler/cgen.nim
./build.sh
./bin/nim c $NIMFLAGS -d:release koch
./koch boot $NIMFLAGS -d:release
./koch tools $NIMFLAGS -d:release
# TODO: build docs
# ./koch docs
%check
%install
# extract everything into a staging location, as Nim devels like to
# add/remove things in an unusual way and we want to find out what
# is added/removed/modified on future versions to avoid errors
# while packaging it
TARGET="%{buildroot}/_pending"
./koch install $TARGET
# some binaries aren't installed at target location by koch
cp ./bin/* $TARGET/nim/bin/
mkdir -p \
%{buildroot}%{_bindir}/ \
%{buildroot}%{_libdir}/nim \
%{buildroot}%{_sysconfdir}/nim \
%{buildroot}%{_docdir}/nim
# remove things that aren't needed
rm $TARGET/nim/lib/pure/unidecode/gen.py
# fix endlines
sed -i 's/\r$//' $TARGET/nim/doc/nimdoc.css
# move executables to final location (or delete what isn't needed)
# rm $TARGET/nim/bin/atlas
# rm $TARGET/nim/bin/testament
rm $TARGET/nim/nim.nimble
mv $TARGET/nim/bin %{buildroot}%{_libdir}/nim/
NimBinDir=%{buildroot}%{_libdir}/nim/bin
find "$NimBinDir" -maxdepth 1 -type f -executable -not -name nim-gdb -exec strip --strip-all {} \;
find "$NimBinDir" -maxdepth 1 -type f -executable -exec ln -rs {} %{buildroot}%{_bindir} \;
mv $TARGET/nim/compiler* %{buildroot}%{_libdir}/nim/
mv $TARGET/nim/lib %{buildroot}%{_libdir}/nim/
mv $TARGET/nim/doc %{buildroot}%{_docdir}/nim/
mv $TARGET/nim/config/* %{buildroot}%{_sysconfdir}/nim/
# completions
cd %{_builddir}/%{name}-%{version}
for comp in tools/*.bash-completion; do
install -Dm 644 "${comp}" "%{buildroot}%{_datadir}/bash-completion/completions/$(basename "${comp%%.bash-completion}")"
done
for comp in tools/*.zsh-completion; do
install -Dm 644 "${comp}" "%{buildroot}%{_datadir}/zsh/site-functions/_$(basename "${comp%%.zsh-completion}")"
done
# tweaks
sed -i "1s:#!/usr/bin/env bash:#!/usr/bin/bash:" "$NimBinDir/nim-gdb"
%files
%dir %{_sysconfdir}/nim
%config %{_sysconfdir}/nim/*
%{_bindir}/*
%{_libdir}/nim
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/*
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_*
%license copying.txt
%doc %{_docdir}/nim
%changelog