From 6ca3a89910e49268e5bcf8fc4ece231fdae14e69 Mon Sep 17 00:00:00 2001 From: minco Date: Thu, 7 May 2026 21:42:20 +0900 Subject: [PATCH] add openmodelica --- configuration.nix | 40 ++++++++++------- flake.nix | 10 +++++ nixpkgs/openmodelica.nix | 95 ++++++++++++++++++++++++++++++++++++++++ pkgs/util.nix | 1 + 4 files changed, 130 insertions(+), 16 deletions(-) create mode 100644 nixpkgs/openmodelica.nix diff --git a/configuration.nix b/configuration.nix index 9d5fe3f..2719bc2 100644 --- a/configuration.nix +++ b/configuration.nix @@ -6,8 +6,7 @@ let myRizin = pkgs.rizin.passthru.withPlugins (plugins: [ plugins.jsdec plugins.rz-ghidra ]); -in -{ +in { imports = [ ./hardware-configuration.nix ./services/virtual.nix @@ -19,23 +18,21 @@ in services.logind.lidSwitch = "suspend"; nixpkgs.config.allowUnfree = true; - - boot.kernel.sysctl = { - "net.ipv4.ip_forward" = 1; - }; + + boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; }; #boot.loader.grub.device = "/dev/nvme1n1p1"; boot.loader = { - systemd-boot.enable = false; - efi = { - canTouchEfiVariables = true; - efiSysMountPoint = "/boot/efi"; - }; - grub = { - enable = true; - device = "nodev"; - efiSupport = true; - useOSProber = true; + systemd-boot.enable = false; + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot/efi"; + }; + grub = { + enable = true; + device = "nodev"; + efiSupport = true; + useOSProber = true; }; }; @@ -113,9 +110,20 @@ in myRizin libgit2 inputs.helix.packages."${pkgs.system}".helix + openmodelica ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.trusted-users = [ "root" "allen" ]; + + nix.settings = { + substituters = + [ "https://allen-nixpkgs.cachix.org" "https://cache.nixos.org" ]; + trusted-public-keys = [ + "allen-nixpkgs.cachix.org-1:GS5qDYVloEiC6oeJQNijR3hsMKPqDSGbYUz35qtbMpg=" + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + ]; + }; environment.variables = { LD_LIBRARY_PATH = lib.makeLibraryPath [ diff --git a/flake.nix b/flake.nix index efb45cf..c861ec6 100644 --- a/flake.nix +++ b/flake.nix @@ -16,6 +16,15 @@ specialArgs = { inherit inputs; }; modules = [ ./configuration.nix + + ({ pkgs, ... }: { + # Define the overlay inline or in a separate file + nixpkgs.overlays = [ + (final: prev: { + openmodelica = final.callPackage ./nixpkgs/openmodelica.nix { }; + }) + ]; + }) home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -27,3 +36,4 @@ }; }; } + diff --git a/nixpkgs/openmodelica.nix b/nixpkgs/openmodelica.nix new file mode 100644 index 0000000..86a635b --- /dev/null +++ b/nixpkgs/openmodelica.nix @@ -0,0 +1,95 @@ +{ + pkgs ? import { }, +}: +let + desktopItem = pkgs.makeDesktopItem { + name = "openmodelica"; + desktopName = "OpenModelica Connection Editor"; + exec = "OMEdit"; + icon = "openmodelica"; + categories = [ + "Development" + "Science" + "Education" + ]; + comment = "Modelica-based modeling and simulation environment"; + }; +in + +with pkgs; +stdenv.mkDerivation { + name = "openmodelica-bin"; + version = "custom"; + src = pkgs.fetchgit { + url = "https://github.com/OpenModelica/OpenModelica.git"; + rev = "959f964dadf1b928f03e3c2f74b8f816f95df1ef"; + fetchSubmodules = true; + sha256 = "sha256-3rFIrg7+t/eX2mq21v9AcYhV3Adloa8Sae9uRGtbyrY="; + }; + + nativeBuildInputs = with pkgs; [ + cmake + gfortran + pkg-config + qt6.wrapQtAppsHook + autoPatchelfHook + flex + autoconf + automake + libtool + ninja + ]; + + configurePhase = '' + cmake -S . -B build_cmake -GNinja -DOM_USE_CCACHE=OFF -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX=$out + ''; + + buildPhase = '' + cmake --build build_cmake --parallel $NIX_BUILD_CORES --target install + ''; + + installPhase = '' + cmake --install build_cmake --prefix $out + runHook postInstall + ''; + + postInstall = '' + if [ -d "$out/lib64" ]; then + mkdir -p $out/lib + cp -rn $out/lib64/* $out/lib/ + rm -rf $out/lib64 + fi + + mkdir -p $out/share/applications + cp ${desktopItem}/share/applications/* $out/share/applications/ + + # If you have an icon file in your source, install it too + # mkdir -p $out/share/icons/hicolor/scalable/apps + # cp $src/path/to/icon.svg $out/share/icons/hicolor/scalable/apps/openmodelica.svg + ''; + + buildInputs = with pkgs; [ + # Compilers and Build Tools + + # Dependencies + boost + hwloc + jdk + lapack + blas + hdf5 + expat + omniorb + curl + ncurses + readline + openscenegraph + qt6.qt5compat + qt6.qtbase + qt6.qtwebengine + qt6.qtdeclarative + qt6.qttools + lapack-reference + ]; +} + diff --git a/pkgs/util.nix b/pkgs/util.nix index 6008c2e..2a0fb4b 100644 --- a/pkgs/util.nix +++ b/pkgs/util.nix @@ -72,4 +72,5 @@ with pkgs; [ gptfdisk openocd probe-rs-tools + cachix ]