Skip to content

Commit

Permalink
feat(nixos): add default.nix for NixOS support
Browse files Browse the repository at this point in the history
- Improved and formatted BUILDING_Linux.md
- Added default.nix for building Nelson on NixOS
- Modified CMakeLists.txt in modules/tests_manager
  • Loading branch information
Nelson-numerical-software committed Dec 26, 2024
1 parent d8f22ae commit d44595c
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#==============================================================================
# This .gitignore for Nelson

result/
build/
chocolatey/nelson/*.nupkg
nelson*.snap
Expand Down
41 changes: 37 additions & 4 deletions BUILDING_Linux.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
# Building on Linux
# Building Nelson on Linux

- You can also see [ccpp.yml](https://github.com/nelson-lang/nelson/blob/master/.github/workflows/ccpp.yml) file to help you to see dependencies. This file is up-to-date about how to build Nelson on each platform.
This guide provides instructions on how to build Nelson on Linux.
For the most up-to-date information on dependencies and build instructions, refer to the [ccpp.yml](https://github.com/nelson-lang/nelson/blob/master/.github/workflows/ccpp.yml) file.

- [ArchLinux package](https://aur.archlinux.org/packages/nelson-git)
## ArchLinux

Nelson is available as an ArchLinux package. You can install it using `paru`:

```bash
paru nelson
```

- You can also build nelson with a micromamba environment
## NixOS

To build Nelson on NixOS, you can use the provided [default.nix](https://github.com/nelson-lang/nelson/blob/master/default.nix) file.

### Using the Latest Master Version

To fetch the latest master version and build Nelson:
replace sha256 by desired/latest sha256 commit.

### Building Nelson

To build Nelson using the default.nix file:

```bash
nix-build
```

### Evaluate Nelson

```bash
nix-shell
./result/bin/nelson
```

### Install in your environment:

```bash
nix-env -i ./result
```

## You can also build nelson with a micromamba environment

After installing micromamba

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `urlencode`: Replace special characters in URLs with escape characters.
- `docroot`: Utility to retrieve or define the root directory of Nelson Help.
- `ismodule`: second input argument `isprotected` added.
- `editor('editor_command', cmd)` allows to change text editor in Nelson (for example: VS Code)
- `editor('editor_command', cmd)` allows to change text editor in Nelson (for example: VS Code).
- NixOS 24.11 packaging (see [BUILDING_Linux.md](https://github.com/nelson-lang/nelson/blob/master/BUILDING_Linux.md)).

### Changed

Expand Down
72 changes: 72 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation {
name = "nelson";
version = "master";

# Source URL for the Nelson source code
src = pkgs.fetchFromGitHub {
owner = "nelson-lang";
repo = "nelson";
rev = "master";
sha256 = "sha256-DbmwDShdBjQXtpXjJ2QyApYxt7g7P13ap1uN3L0MPPc="; # Replace with the actual checksum
};

buildInputs = [
];

nativeBuildInputs = [
pkgs.gcc # C++ compiler
pkgs.cmake # Build system
pkgs.gnumake # Make utility
pkgs.zlib # Compression library
pkgs.boost # Boost libraries
pkgs.openssl # SSL support
pkgs.gfortran # Fortran compiler (if needed for certain modules)
pkgs.eigen # Eigen library
pkgs.mpi # MPI support
pkgs.hdf5 # HDF5 support
pkgs.curl # cURL support
pkgs.libgit2 # Git support
pkgs.libsndfile # Sound file support
pkgs.portaudio # PortAudio support
pkgs.lapack # LAPACK support
pkgs.openblas # OpenBLAS support
pkgs.libjack2 # JACK support
pkgs.taglib # TagLib support
pkgs.alsa-oss # ALSA support
pkgs.alsa-lib # ALSA support
pkgs.matio # MATIO support
pkgs.libcxx # C++ standard library
pkgs.pkg-config # pkg-config for detecting dependencies
pkgs.qt5.full # Qt for GUI support
pkgs.qt5.wrapQtAppsHook # Wrapper for Qt applications
];

buildPhase = ''
cmake . -DLGPL_ONLY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$out
cmake --build . -- -j $(nproc)
'';

installPhase = ''
make install
'';

# Wrap the application with Qt environment variables
postInstall = ''
wrapQtApp $out/bin/nelson
'';

checkPhase = ''
'';

doCheck = false;

meta = {
description = "Nelson programming language";
homepage = "https://github.com/nelson-lang/nelson";
license = pkgs.lib.licenses.lgpl3Plus;
maintainers = with pkgs.lib.maintainers; [ Nelson-numerical-software ];
};

}
5 changes: 5 additions & 0 deletions modules/tests_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ install(
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/modules/${module_name}"
FILES_MATCHING
PATTERN "*.m")
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/modules/${module_name}"
FILES_MATCHING
PATTERN "*.m")
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/help
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/modules/${module_name}"
Expand Down

0 comments on commit d44595c

Please sign in to comment.