From 857f41c32f610c42754877da9f4506b8f1991c4a Mon Sep 17 00:00:00 2001 From: chn Date: Sat, 12 Apr 2025 15:16:05 +0800 Subject: [PATCH] =?UTF-8?q?packages:=20=E7=A7=BB=E5=8A=A8src?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake/src.nix | 58 +++++++++++++++++++++++++---- modules/packages/mathematica.nix | 5 +-- packages/default.nix | 22 ++++++----- packages/mirism-old.nix | 13 +------ packages/pslist.nix | 9 +---- packages/vasp/gnu/default.nix | 1 - packages/vasp/intel/default.nix | 63 ++++++++++++-------------------- packages/vasp/nvidia/default.nix | 21 ++--------- packages/vasp/source.nix | 7 ---- packages/vaspkit.nix | 21 +++-------- packages/vesta.nix | 4 +- 11 files changed, 102 insertions(+), 122 deletions(-) delete mode 100644 packages/vasp/source.nix diff --git a/flake/src.nix b/flake/src.nix index abfa8dff..5290bfe3 100644 --- a/flake/src.nix +++ b/flake/src.nix @@ -31,17 +31,27 @@ version = "3.1.2"; hash = "sha256-f2cu+itsoNs03paOW1dmsUsbPa3iEtL4oIPGAKETRc4="; }; - vtst = + vasp = { - patch = pkgs.fetchzip + vasp = pkgs.requireFile { - url = "http://theory.cm.utexas.edu/code/vtstcode-204.tgz"; - sha256 = "00qpqiabl568fwqjnmwqwr0jwg7s56xd9lv9lw8q4qxqy19cpg62"; + name = "vasp.6.4.3.tgz"; + # nix-prefetch-url file://$(pwd)/vasp.6.4.3.tgz + sha256 = "1x14dixils77rr4c6yqmxkvyzgfz6906badsw2shksd3y9ryfc7y"; + message = "Source file not found."; }; - script = pkgs.fetchzip + vtst = { - url = "http://theory.cm.utexas.edu/code/vtstscripts.tgz"; - sha256 = "18gsw2850ig1mg4spp39i0ygfcwx0lqnamysn5whiax22m8d5z67"; + patch = pkgs.fetchzip + { + url = "http://theory.cm.utexas.edu/code/vtstcode-204.tgz"; + sha256 = "00qpqiabl568fwqjnmwqwr0jwg7s56xd9lv9lw8q4qxqy19cpg62"; + }; + script = pkgs.fetchzip + { + url = "http://theory.cm.utexas.edu/code/vtstscripts.tgz"; + sha256 = "18gsw2850ig1mg4spp39i0ygfcwx0lqnamysn5whiax22m8d5z67"; + }; }; }; huginn = pkgs.dockerTools.pullImage @@ -95,4 +105,38 @@ sha256 = "Tq4AzQgde2KIWKA1k6JlxvdphGG9JluHMZjVw0fBUeQ="; }; }; + # nix-store --query --hash $(nix store add-path . --name 'mirism') + mirism-old = pkgs.requireFile + { + name = "mirism"; + sha256 = "0f50pvdafhlmrlbf341mkp9q50v4ld5pbx92d2w1633f18zghbzf"; + hashMode = "recursive"; + message = "Source file not found."; + }; + pslist = + { + version = "1.4.0"; + src = pkgs.fetchzip + { + url = "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/pslist/1.4.0-4/pslist_1.4.0.orig.tar.xz"; + sha256 = "1sp1h7ccniz658ms331npffpa9iz8llig43d9mlysll420nb3xqv"; + }; + }; + vaspkit = rec + { + version = "1.5.1"; + potcar = pkgs.requireFile + { + name = "POTCAR"; + sha256 = "01adpp9amf27dd39m8svip3n6ax822vsyhdi6jn5agj13lis0ln3"; + hashMode = "recursive"; + message = "POTCAR not found."; + }; + vaspkit = pkgs.fetchurl + { + url = "mirror://sourceforge/vaspkit/Binaries/vaspkit.${version}.linux.x64.tar.gz"; + sha256 = "1cbj1mv7vx18icwlk9d2vfavsfd653943xg2ywzd8b7pb43xrfs1"; + }; + }; + mathematica = pkgs.mathematica.src; } diff --git a/modules/packages/mathematica.nix b/modules/packages/mathematica.nix index 02ebd177..af339970 100644 --- a/modules/packages/mathematica.nix +++ b/modules/packages/mathematica.nix @@ -6,8 +6,5 @@ inputs: default = null; }; config = let inherit (inputs.config.nixos.packages) mathematica; in inputs.lib.mkIf (mathematica != null) - { - nixos.packages.packages._packages = [ (inputs.pkgs.mathematica.overrideAttrs - (prev: { postInstall = (prev.postInstall or "") + "ln -s ${prev.src} $out/src"; })) ]; - }; + { nixos.packages.packages._packages = [ inputs.pkgs.mathematica ]; }; } diff --git a/packages/default.nix b/packages/default.nix index ed0f6c4f..57c6862f 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -8,7 +8,11 @@ inputs: rec src = inputs.topInputs.misskey; extraIntegritySha256 = inputs.topInputs.self.src.misskey; }; - vaspkit = inputs.pkgs.callPackage ./vaspkit.nix { inherit (inputs.localLib) attrsToList; }; + vaspkit = inputs.pkgs.callPackage ./vaspkit.nix + { + inherit (inputs.localLib) attrsToList; + src = inputs.topInputs.self.src.vaspkit; + }; v-sim = inputs.pkgs.callPackage ./v-sim.nix { src = inputs.topInputs.v-sim; }; concurrencpp = inputs.pkgs.callPackage ./concurrencpp.nix { src = inputs.topInputs.concurrencpp; }; matplotplusplus = inputs.pkgs.callPackage ./matplotplusplus.nix @@ -18,11 +22,12 @@ inputs: rec }; zpp-bits = inputs.pkgs.callPackage ./zpp-bits.nix { src = inputs.topInputs.zpp-bits; }; nameof = inputs.pkgs.callPackage ./nameof.nix { src = inputs.topInputs.nameof; }; - pslist = inputs.pkgs.callPackage ./pslist.nix {}; + pslist = inputs.pkgs.callPackage ./pslist.nix { src = inputs.topInputs.self.src.pslist; }; tgbot-cpp = inputs.pkgs.callPackage ./tgbot-cpp.nix { src = inputs.topInputs.tgbot-cpp; }; mirism-old = inputs.pkgs.callPackage ./mirism-old.nix { inherit cppcoro nameof tgbot-cpp date; + src = inputs.topInputs.self.src.mirism-old; nghttp2 = inputs.pkgs.callPackage "${inputs.topInputs."nixpkgs-23.05"}/pkgs/development/libraries/nghttp2" { enableAsioLib = true; stdenv = inputs.pkgs.gcc12Stdenv; }; stdenv = inputs.pkgs.gcc12Stdenv; @@ -31,26 +36,23 @@ inputs: rec date = inputs.pkgs.callPackage ./date.nix { src = inputs.topInputs.date; }; blurred-wallpaper = inputs.pkgs.callPackage ./blurred-wallpaper.nix { src = inputs.topInputs.blurred-wallpaper; }; slate = inputs.pkgs.callPackage ./slate.nix { src = inputs.topInputs.slate; }; - vasp = rec + vasp = { - src = inputs.pkgs.callPackage ./vasp/source.nix {}; gnu = inputs.pkgs.callPackage ./vasp/gnu { inherit (inputs.pkgs.llvmPackages) openmp; - inherit src; + src = inputs.topInputs.self.src.vasp.vasp; hdf5 = inputs.pkgs.hdf5.override { mpiSupport = true; fortranSupport = true; cppSupport = false; }; }; nvidia = inputs.pkgs.callPackage ./vasp/nvidia { inherit (nvhpcPackages) stdenv hdf5 mpi; - inherit src; - vtst = inputs.topInputs.self.src.vtst.patch; + src = inputs.topInputs.self.src.vasp; wannier90 = inputs.pkgs.wannier90.overrideAttrs { buildFlags = [ "dynlib" ]; }; }; intel = inputs.pkgs.callPackage ./vasp/intel { - inherit src; - vtst = inputs.topInputs.self.src.vtst.patch; + src = inputs.topInputs.self.src.vasp; inherit (inputs.pkgs.intelPackages_2023) stdenv; mpi = inputs.pkgs.openmpi.override { @@ -67,7 +69,7 @@ inputs: rec }; wannier90 = inputs.pkgs.wannier90.overrideAttrs { buildFlags = [ "dynlib" ]; }; }; - vtst = inputs.pkgs.callPackage ./vasp/vtst.nix { src = inputs.topInputs.self.src.vtst.script; }; + vtst = inputs.pkgs.callPackage ./vasp/vtst.nix { src = inputs.topInputs.self.src.vasp.vtst.script; }; }; mumax = inputs.pkgs.callPackage ./mumax.nix { src = inputs.topInputs.mumax; }; biu = inputs.pkgs.callPackage ./biu diff --git a/packages/mirism-old.nix b/packages/mirism-old.nix index 9e5b14db..72364e5d 100644 --- a/packages/mirism-old.nix +++ b/packages/mirism-old.nix @@ -1,17 +1,9 @@ { - lib, stdenv, requireFile, + lib, stdenv, requireFile, src, boost, nghttp2, brotli, nameof, cppcoro, tgbot-cpp, libbacktrace, fmt, date -}: stdenv.mkDerivation rec +}: stdenv.mkDerivation { name = "mirism"; - # nix-store --query --hash $(nix store add-path . --name 'mirism') - src = requireFile - { - inherit name; - sha256 = "0f50pvdafhlmrlbf341mkp9q50v4ld5pbx92d2w1633f18zghbzf"; - hashMode = "recursive"; - message = "Source file not found."; - }; buildInputs = [ boost nghttp2.dev brotli nameof cppcoro tgbot-cpp libbacktrace fmt date ]; buildPhase = '' @@ -24,7 +16,6 @@ runHook preInstall mkdir -p $out/bin cp build/{ng01,beta} $out/bin - ln -s ${src} $out/src runHook postInstall ''; } diff --git a/packages/pslist.nix b/packages/pslist.nix index aa3de55e..e638deeb 100644 --- a/packages/pslist.nix +++ b/packages/pslist.nix @@ -1,14 +1,9 @@ # http://launchpadlibrarian.net/632309499/pslist_1.4.0-4_all.deb # https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/pslist/1.4.0-4/pslist_1.4.0.orig.tar.xz -{ lib, stdenv, fetchzip, perl, procps }: stdenv.mkDerivation +{ stdenv, src, perl, procps }: stdenv.mkDerivation { pname = "pslist"; - version = "1.4.0"; - src = fetchzip - { - url = "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/pslist/1.4.0-4/pslist_1.4.0.orig.tar.xz"; - sha256 = "1sp1h7ccniz658ms331npffpa9iz8llig43d9mlysll420nb3xqv"; - }; + inherit (src) version src; buildInstall = [ perl procps ]; installPhase = '' diff --git a/packages/vasp/gnu/default.nix b/packages/vasp/gnu/default.nix index 9034d913..883330aa 100644 --- a/packages/vasp/gnu/default.nix +++ b/packages/vasp/gnu/default.nix @@ -24,7 +24,6 @@ let vasp = stdenvNoCC.mkDerivation for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i done - ln -s ${src} $out/src ''; }; in writeShellApplication diff --git a/packages/vasp/intel/default.nix b/packages/vasp/intel/default.nix index a9e7603d..0bc30068 100644 --- a/packages/vasp/intel/default.nix +++ b/packages/vasp/intel/default.nix @@ -1,43 +1,28 @@ -{ - stdenv, src, writeShellScriptBin, lib, - rsync, which, wannier90, hdf5, vtst, mpi, mkl -}: +{ stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl }: let vasp = stdenv.mkDerivation - { - name = "vasp-intel"; - inherit src; - patches = [ ../vtst.patch ]; - configurePhase = - '' - cp ${./makefile.include} makefile.include - chmod +w makefile.include - cp ${../constr_cell_relax.F} src/constr_cell_relax.F - cp -r ${vtst}/vtstcode6.4.3/* src - chmod -R +w src - ''; - buildInputs = [ hdf5 wannier90 mkl ]; - nativeBuildInputs = [ rsync which mpi ]; - installPhase = - '' - mkdir -p $out/bin - for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done - mkdir $out/src - ln -s ${src} $out/src/vasp - ln -s ${vtst} $out/src/vtst - ''; - - # NIX_DEBUG = "7"; - - # enable parallel build - enableParallelBuilding = true; - DEPS = "1"; - - # vasp directly include headers under ${mkl}/include/fftw - MKLROOT = mkl; - - # tell openmpi use ifx - OMPI_F90 = "ifx"; - }; +{ + name = "vasp-intel"; + src = src.vasp; + patches = [ ../vtst.patch ]; + configurePhase = + '' + cp ${./makefile.include} makefile.include + chmod +w makefile.include + cp ${../constr_cell_relax.F} src/constr_cell_relax.F + cp -r ${src.vtst.patch}/vtstcode6.4.3/* src + chmod -R +w src + ''; + buildInputs = [ hdf5 wannier90 mkl ]; + nativeBuildInputs = [ rsync which mpi ]; + installPhase = + '' + mkdir -p $out/bin + for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done + ''; + # NIX_DEBUG = "7"; + enableParallelBuilding = true; + env = { DEPS = "1"; MKLROOT = mkl; OMPI_F90 = "ifx"; }; +}; in writeShellScriptBin "vasp-intel" '' export PATH=${vasp}/bin:${mpi}/bin''${PATH:+:$PATH} diff --git a/packages/vasp/nvidia/default.nix b/packages/vasp/nvidia/default.nix index 6bca88e0..4cadac45 100644 --- a/packages/vasp/nvidia/default.nix +++ b/packages/vasp/nvidia/default.nix @@ -1,18 +1,15 @@ -{ - stdenv, src, writeShellScriptBin, - rsync, which, wannier90, hdf5, vtst, mkl, mpi -}: +{ stdenv, src, writeShellScriptBin, rsync, which, wannier90, hdf5, mkl, mpi }: let vasp = stdenv.mkDerivation { name = "vasp-nvidia"; - inherit src; + src = src.vasp; patches = [ ../vtst.patch ]; configurePhase = '' cp ${./makefile.include} makefile.include chmod +w makefile.include cp ${../constr_cell_relax.F} src/constr_cell_relax.F - cp -r ${vtst}/vtstcode6.4.3/* src + cp -r ${src.vtst.patch}/vtstcode6.4.3/* src chmod -R +w src ''; buildInputs = [ hdf5 wannier90 mkl ]; @@ -21,20 +18,10 @@ let vasp = stdenv.mkDerivation '' mkdir -p $out/bin for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done - mkdir $out/src - ln -s ${src} $out/src/vasp - ln -s ${vtst} $out/src/vtst ''; - # enable parallel build enableParallelBuilding = true; - env = - { - DEPS = "1"; - # vasp directly include headers under ${mkl}/include/fftw - MKLROOT = mkl; - QD = "${stdenv.cc.cc}/Linux_x86_64/${stdenv.cc.cc.version}/compilers/extras/qd"; - }; + env = { DEPS = "1"; MKLROOT = mkl; QD = "${stdenv.cc.cc}/Linux_x86_64/${stdenv.cc.cc.version}/compilers/extras/qd"; }; }; in writeShellScriptBin "vasp-nvidia" '' diff --git a/packages/vasp/source.nix b/packages/vasp/source.nix deleted file mode 100644 index 37cbc352..00000000 --- a/packages/vasp/source.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ requireFile }: requireFile -{ - name = "vasp.6.4.3.tgz"; - # nix-prefetch-url file://$(pwd)/vasp.6.4.3.tgz - sha256 = "1x14dixils77rr4c6yqmxkvyzgfz6906badsw2shksd3y9ryfc7y"; - message = "Source file not found."; -} diff --git a/packages/vaspkit.nix b/packages/vaspkit.nix index c99b29fb..cd73ecab 100644 --- a/packages/vaspkit.nix +++ b/packages/vaspkit.nix @@ -1,22 +1,11 @@ -{ stdenv, fetchurl, requireFile, autoPatchelfHook, makeWrapper, python3, attrsToList, gnused }: +{ stdenv, src, autoPatchelfHook, makeWrapper, python3, attrsToList, gnused }: let - potcar = requireFile - { - name = "POTCAR"; - sha256 = "01adpp9amf27dd39m8svip3n6ax822vsyhdi6jn5agj13lis0ln3"; - hashMode = "recursive"; - message = "POTCAR not found."; - }; - unwrapped = stdenv.mkDerivation rec + unwrapped = stdenv.mkDerivation { pname = "vaspkit-unwrapped"; - version = "1.5.1"; + inherit (src) version; + src = src.vaspkit; buildInputs = [ autoPatchelfHook stdenv.cc.cc ]; - src = fetchurl - { - url = "mirror://sourceforge/vaspkit/Binaries/vaspkit.${version}.linux.x64.tar.gz"; - sha256 = "1cbj1mv7vx18icwlk9d2vfavsfd653943xg2ywzd8b7pb43xrfs1"; - }; installPhase = '' runHook preInstall @@ -26,7 +15,7 @@ let ''; }; python = python3.withPackages (pythonPackages: with pythonPackages; [ numpy scipy matplotlib ]); - envirmentVariables = + envirmentVariables = let inherit (src) potcar; in { LDA_PATH = "${potcar}/PAW_LDA"; PBE_PATH = "${potcar}/PAW_PBE"; diff --git a/packages/vesta.nix b/packages/vesta.nix index 538727bb..152c8425 100644 --- a/packages/vesta.nix +++ b/packages/vesta.nix @@ -1,9 +1,7 @@ { lib, stdenv, fetchurl, autoPatchelfHook, wrapGAppsHook, makeWrapper, src, glib, gtk2, xorg, libGLU, gtk3, writeShellScript, gsettings-desktop-schemas, xdg-utils, webkitgtk, jdk -}: - -stdenv.mkDerivation +}: stdenv.mkDerivation { pname = "vesta"; inherit (src) src version;