From 097ad8118e2243ebb957d38db8ffc7f8838ade66 Mon Sep 17 00:00:00 2001 From: minco Date: Thu, 7 May 2026 17:40:59 +0900 Subject: [PATCH] add openmodelica --- configuration.nix | 6 ++- flake.nix | 26 +++++++++-- hardware-configuration.nix | 5 +- home.nix | 48 +++++++++++-------- nixpkgs/openmodelica.nix | 94 ++++++++++++++++++++++++++++++++++++++ pkgs/programming.nix | 13 +++++- pkgs/util.nix | 2 + services/virtual.nix | 22 +++++++++ 8 files changed, 189 insertions(+), 27 deletions(-) create mode 100644 nixpkgs/openmodelica.nix diff --git a/configuration.nix b/configuration.nix index 42f495d..90f8d6a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -30,6 +30,9 @@ in ]; nixpkgs.config.allowUnfree = true; + nixpkgs.config.permittedInsecurePackages = [ + "qtwebkit-5.212.0-alpha4" + ]; services.nfs.server = { enable = true; @@ -61,7 +64,7 @@ in services.resolved = { enable = true; - dnssec = "allow-downgrade"; + dnssec = "false"; }; networking.nameservers = [ "1.1.1.1" @@ -207,6 +210,7 @@ in # List packages installed in system profile. # You can use https://search.nixos.org/ to find more packages (and options). environment.systemPackages = with pkgs; [ + openmodelica vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. pkg-config wget diff --git a/flake.nix b/flake.nix index fda783b..855a266 100644 --- a/flake.nix +++ b/flake.nix @@ -17,19 +17,39 @@ }; outputs = - { self, nixpkgs, home-manager, split-monitor-workspaces, ... }@inputs: + { + self, + nixpkgs, + home-manager, + split-monitor-workspaces, + ... + }@inputs: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; - config = { allowUnfree = true; }; + config = { + allowUnfree = true; + }; }; - in { + in + { nixosConfigurations.haskell = nixpkgs.lib.nixosSystem { inherit system; 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; diff --git a/hardware-configuration.nix b/hardware-configuration.nix index 51ac21e..c8b28a4 100644 --- a/hardware-configuration.nix +++ b/hardware-configuration.nix @@ -35,6 +35,10 @@ ]; boot.extraModulePackages = [ ]; + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.18.22") ( + lib.mkDefault pkgs.linuxPackages_6_18 + ); + # 1050 passthrough boot.extraModprobeConfig = "" @@ -100,7 +104,6 @@ "defaults" "ssd" "noatime" - "noauto" ]; }; diff --git a/home.nix b/home.nix index 37defbc..433ca84 100644 --- a/home.nix +++ b/home.nix @@ -1,4 +1,9 @@ -{ inputs, split-monitor-workspaces, pkgs, ... }: +{ + inputs, + split-monitor-workspaces, + pkgs, + ... +}: { imports = [ @@ -20,26 +25,29 @@ "Xft.dpi" = 172; }; - home.packages = let - fonts = import ./pkgs/fonts.nix { inherit pkgs; }; - minecraft = import ./pkgs/minecraft.nix { inherit pkgs; }; - misc = import ./pkgs/misc.nix { inherit pkgs; }; - network = import ./pkgs/network.nix { inherit pkgs; }; - programming = import ./pkgs/programming.nix { inherit pkgs; }; - tools = import ./pkgs/tools.nix { inherit pkgs; }; - util = import ./pkgs/util.nix { inherit pkgs; }; - games = import ./pkgs/games.nix { inherit pkgs; }; - unstable = import (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; - sha256 = "1ijgd8hy1ii0k0s48yhnzw09c7zdjnp1fq8wfj7jgajwmlfwy3xg"; - }) { system = "x86_64-linux"; }; - unstables = import ./pkgs/unstable.nix { - inherit pkgs; - inherit unstable; - }; + nixpkgs.config.permittedInsecurePackages = [ "qtwebkit-5.212.0-alpha4" ]; - in fonts ++ minecraft ++ misc ++ network ++ programming ++ tools ++ util - ++ games ++ unstables; + home.packages = + let + fonts = import ./pkgs/fonts.nix { inherit pkgs; }; + minecraft = import ./pkgs/minecraft.nix { inherit pkgs; }; + misc = import ./pkgs/misc.nix { inherit pkgs; }; + network = import ./pkgs/network.nix { inherit pkgs; }; + programming = import ./pkgs/programming.nix { inherit pkgs; }; + tools = import ./pkgs/tools.nix { inherit pkgs; }; + util = import ./pkgs/util.nix { inherit pkgs; }; + games = import ./pkgs/games.nix { inherit pkgs; }; + unstable = import (builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"; + sha256 = "1ijgd8hy1ii0k0s48yhnzw09c7zdjnp1fq8wfj7jgajwmlfwy3xg"; + }) { system = "x86_64-linux"; }; + unstables = import ./pkgs/unstable.nix { + inherit pkgs; + inherit unstable; + }; + + in + fonts ++ minecraft ++ misc ++ network ++ programming ++ tools ++ util ++ games ++ unstables; programs.direnv.enable = true; programs.direnv.nix-direnv.enable = true; diff --git a/nixpkgs/openmodelica.nix b/nixpkgs/openmodelica.nix new file mode 100644 index 0000000..218e5b1 --- /dev/null +++ b/nixpkgs/openmodelica.nix @@ -0,0 +1,94 @@ +{ + 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/programming.nix b/pkgs/programming.nix index a211526..39ca856 100644 --- a/pkgs/programming.nix +++ b/pkgs/programming.nix @@ -2,7 +2,8 @@ { pkgs, ... }: -with pkgs; [ +with pkgs; +[ radare2 # (python3.withPackages (python-pkgs: with python-pkgs; [ jupyter-client ])) # gdb @@ -22,7 +23,14 @@ with pkgs; [ gh platformio python313Packages.r2pipe - (python313.withPackages(ps: with ps; [ jupyter-client pynvim wand ipykernel ])) + (python313.withPackages ( + ps: with ps; [ + jupyter-client + pynvim + wand + ipykernel + ] + )) python313Packages.pip nodejs go @@ -62,4 +70,5 @@ with pkgs; [ libllvm bun jetbrains.rider + julia-bin ] diff --git a/pkgs/util.nix b/pkgs/util.nix index 0fde0cf..cc0271a 100644 --- a/pkgs/util.nix +++ b/pkgs/util.nix @@ -107,4 +107,6 @@ with pkgs; pev virtiofsd exfatprogs + python313Packages.scrapy + atopile ] diff --git a/services/virtual.nix b/services/virtual.nix index f729499..836a05b 100644 --- a/services/virtual.nix +++ b/services/virtual.nix @@ -17,6 +17,28 @@ lxc.enable = true; }; + users.users.root.subUidRanges = [ + { + startUid = 1000; + count = 1; + } + { + startUid = 1000000; + count = 65536; + } + ]; + + users.users.root.subGidRanges = [ + { + startGid = 1000; + count = 1; + } + { + startGid = 1000000; + count = 65536; + } + ]; + programs.virt-manager.enable = true; virtualisation.virtualbox.host.enable = true; }