summaryrefslogtreecommitdiff
path: root/Omni/Bild
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-01-02 16:20:21 -0500
committerBen Sima <ben@bsima.me>2025-01-02 16:20:21 -0500
commit0fb4ae72c5754761fd7666e4274f4beef0484c32 (patch)
treed8820c808f31f287c3fcc266c02e3a26ddcdfbc3 /Omni/Bild
parent3790d334c994db7a0e1eac9c130c2b1316c78c35 (diff)
Switch to alejandra for nix formatting
I mostly wanted a formatter that would format `inherit` blocks vertically, because otherwise they are super hard to read when diffing or even just editing. Both alejandra and the new nixos/nixfmt format verically like this, but alejandra has slightly better format (I guess) and for some reason nixfmt did not respect my `GLOBIGNORE` setting when doing `nixfmt **/*.nix` so it was trying to format stuff in `_/nix`, and failed. So anyway I went with alejandra. - https://github.com/kamadorueda/alejandra - https://discourse.nixos.org/t/enforcing-nix-formatting-in-nixpkgs/49506
Diffstat (limited to 'Omni/Bild')
-rw-r--r--Omni/Bild/Builder.nix291
-rw-r--r--Omni/Bild/CcacheWrapper.nix18
-rw-r--r--Omni/Bild/Constants.nix2
-rw-r--r--Omni/Bild/Deps.nix10
-rw-r--r--Omni/Bild/Deps/C.nix2
-rw-r--r--Omni/Bild/Deps/Haskell.nix1
-rw-r--r--Omni/Bild/Deps/accelerate.nix13
-rw-r--r--Omni/Bild/Deps/bitsandbytes.nix131
-rw-r--r--Omni/Bild/Deps/guile-opengl.nix60
-rw-r--r--Omni/Bild/Deps/inspekt3d.nix23
-rw-r--r--Omni/Bild/Deps/interegular.nix13
-rw-r--r--Omni/Bild/Deps/lion-pytorch.nix15
-rw-r--r--Omni/Bild/Deps/llm-ollama.nix27
-rw-r--r--Omni/Bild/Deps/llm-sentence-transformers.nix27
-rw-r--r--Omni/Bild/Deps/ludic.nix34
-rw-r--r--Omni/Bild/Deps/nostr-rs-relay.nix12
-rw-r--r--Omni/Bild/Deps/outlines.nix23
-rw-r--r--Omni/Bild/Deps/perscache.nix17
-rw-r--r--Omni/Bild/Functions.nix13
-rw-r--r--Omni/Bild/Haskell.nix61
-rw-r--r--Omni/Bild/Nixpkgs.nix13
-rw-r--r--Omni/Bild/Python.nix16
-rw-r--r--Omni/Bild/Sources.nix242
23 files changed, 598 insertions, 466 deletions
diff --git a/Omni/Bild/Builder.nix b/Omni/Bild/Builder.nix
index b4e6780..09e478b 100644
--- a/Omni/Bild/Builder.nix
+++ b/Omni/Bild/Builder.nix
@@ -1,11 +1,14 @@
-/* This is the library of nix builders. Some rules to follow:
- - Keep this code as minimal as possible. I'd rather write Haskell than Nix,
- wouldn't you?
- - Try to reuse as much upstream Nix as possible.
+/*
+This is the library of nix builders. Some rules to follow:
+- Keep this code as minimal as possible. I'd rather write Haskell than Nix,
+ wouldn't you?
+- Try to reuse as much upstream Nix as possible.
*/
-{ analysisJSON, bild }:
-with bild;
-let
+{
+ analysisJSON,
+ bild,
+}:
+with bild; let
analysis = builtins.fromJSON analysisJSON;
# common bash functions for the builder
@@ -16,158 +19,166 @@ let
}
'';
- build = _: target:
- let
- name = target.out;
- root = builtins.getEnv "CODEROOT";
- mainModule = target.mainModule;
- compileLine = lib.strings.concatStringsSep " "
- ([ target.compiler ] ++ target.compilerFlags);
+ build = _: target: let
+ name = target.out;
+ root = builtins.getEnv "CODEROOT";
+ mainModule = target.mainModule;
+ compileLine =
+ lib.strings.concatStringsSep " "
+ ([target.compiler] ++ target.compilerFlags);
- allSources = target.srcs ++ [ target.quapath ];
+ allSources = target.srcs ++ [target.quapath];
- isEmpty = x: x == null || x == [ ];
+ isEmpty = x: x == null || x == [];
- skip = [ "_" ".direnv" ];
- filter = file: type:
- if lib.lists.elem (builtins.baseNameOf file) skip then
- false
- # TODO: this means any new directory will cause a rebuild. this bad. i
- # should recurse into the directory and match against the srcs. for now I
- # just use preBuild to delete empty dirs
- else if type == "directory" then
- true
- else if type == "regular" then
- lib.trivial.pipe file [
- (f: lib.strings.removePrefix "${root}/" f)
- (f: lib.lists.elem f allSources)
- ]
- else
- false;
+ skip = ["_" ".direnv"];
+ filter = file: type:
+ if lib.lists.elem (builtins.baseNameOf file) skip
+ then false
+ # TODO: this means any new directory will cause a rebuild. this bad. i
+ # should recurse into the directory and match against the srcs. for now I
+ # just use preBuild to delete empty dirs
+ else if type == "directory"
+ then true
+ else if type == "regular"
+ then
+ lib.trivial.pipe file [
+ (f: lib.strings.removePrefix "${root}/" f)
+ (f: lib.lists.elem f allSources)
+ ]
+ else false;
- # remove empty directories, leftover from the src filter
- preBuild = "find . -type d -empty -delete";
+ # remove empty directories, leftover from the src filter
+ preBuild = "find . -type d -empty -delete";
- src = lib.sources.cleanSourceWith {
- inherit filter;
- src = lib.sources.cleanSource root;
- };
+ src = lib.sources.cleanSourceWith {
+ inherit filter;
+ src = lib.sources.cleanSource root;
+ };
- langdeps_ = if isEmpty target.langdeps then
- [ ]
+ langdeps_ =
+ if isEmpty target.langdeps
+ then []
else
lib.attrsets.attrVals target.langdeps (lib.attrsets.getAttrFromPath
- (lib.strings.splitString "." target.packageSet) bild);
+ (lib.strings.splitString "." target.packageSet)
+ bild);
- sysdeps_ = if isEmpty target.sysdeps then
- [ ]
- else
- lib.attrsets.attrVals target.sysdeps pkgs;
+ sysdeps_ =
+ if isEmpty target.sysdeps
+ then []
+ else lib.attrsets.attrVals target.sysdeps pkgs;
- rundeps_ = if isEmpty target.rundeps then
- [ ]
- else
- lib.attrsets.attrVals target.rundeps pkgs;
+ rundeps_ =
+ if isEmpty target.rundeps
+ then []
+ else lib.attrsets.attrVals target.rundeps pkgs;
- CODEROOT = ".";
+ CODEROOT = ".";
- builders = {
- base = stdenv.mkDerivation rec {
- inherit name src CODEROOT preBuild;
- buildInputs = langdeps_ ++ sysdeps_;
- installPhase = "install -D ${name} $out/bin/${name}";
- buildPhase = compileLine;
- };
+ builders = {
+ base = stdenv.mkDerivation rec {
+ inherit name src CODEROOT preBuild;
+ buildInputs = langdeps_ ++ sysdeps_;
+ installPhase = "install -D ${name} $out/bin/${name}";
+ buildPhase = compileLine;
+ };
- haskell = stdenv.mkDerivation rec {
- inherit name src CODEROOT preBuild;
- nativeBuildInputs = [ makeWrapper ];
- buildInputs = sysdeps_ ++ [
+ haskell = stdenv.mkDerivation rec {
+ inherit name src CODEROOT preBuild;
+ nativeBuildInputs = [makeWrapper];
+ buildInputs =
+ sysdeps_
+ ++ [
(haskell.ghcWith (p: (lib.attrsets.attrVals target.langdeps p)))
];
- buildPhase = compileLine;
- installPhase = ''
- install -D ${name} $out/bin/${name}
- wrapProgram $out/bin/${name} \
- --prefix PATH : ${lib.makeBinPath rundeps_}
- '';
- };
+ buildPhase = compileLine;
+ installPhase = ''
+ install -D ${name} $out/bin/${name}
+ wrapProgram $out/bin/${name} \
+ --prefix PATH : ${lib.makeBinPath rundeps_}
+ '';
+ };
- c = stdenv.mkDerivation rec {
- inherit name src CODEROOT preBuild;
- buildInputs = langdeps_ ++ sysdeps_;
- installPhase = "install -D ${name} $out/bin/${name}";
- buildPhase = lib.strings.concatStringsSep " " [
- compileLine
- (if isEmpty langdeps_ then
- ""
- else
- "$(pkg-config --cflags ${
- lib.strings.concatStringsSep " " target.langdeps
- })")
- (if isEmpty sysdeps_ then
- ""
- else
- "$(pkg-config --libs ${
- lib.strings.concatStringsSep " " target.sysdeps
- })")
- ];
- };
+ c = stdenv.mkDerivation rec {
+ inherit name src CODEROOT preBuild;
+ buildInputs = langdeps_ ++ sysdeps_;
+ installPhase = "install -D ${name} $out/bin/${name}";
+ buildPhase = lib.strings.concatStringsSep " " [
+ compileLine
+ (
+ if isEmpty langdeps_
+ then ""
+ else "$(pkg-config --cflags ${
+ lib.strings.concatStringsSep " " target.langdeps
+ })"
+ )
+ (
+ if isEmpty sysdeps_
+ then ""
+ else "$(pkg-config --libs ${
+ lib.strings.concatStringsSep " " target.sysdeps
+ })"
+ )
+ ];
+ };
- python = python.buildPythonApplication rec {
- inherit name src CODEROOT;
- nativeBuildInputs = [ makeWrapper ];
- propagatedBuildInputs = langdeps_ ++ sysdeps_ ++ rundeps_;
- buildInputs = sysdeps_;
- nativeCheckInputs = [ pkgs.ruff python.packages.mypy ];
- checkPhase = ''
- . ${commonBash}
- cp ${../../pyproject.toml} ./pyproject.toml
- check ruff format --exclude 'setup.py' --check .
- # ignore EXE here to support run.sh shebangs
- check ruff check \
- --ignore EXE \
- --exclude 'setup.py' \
- --exclude '__init__.py' \
- .
- touch ./py.typed
- check python -m mypy \
- --explicit-package-bases \
- --no-error-summary \
- --exclude 'setup\.py$' \
- .
- '';
- installCheck = ''
- . ${commonBash}
- check python -m ${mainModule} test
- '';
- preBuild = ''
- # remove empty directories, leftover from the src filter
- find . -type d -empty -delete
- # initialize remaining dirs as python modules
- find . -type d -exec touch {}/__init__.py \;
- # generate a minimal setup.py
- cat > setup.py << EOF
- from setuptools import find_packages, setup
- setup(
- name="${name}",
- entry_points={"console_scripts":["${name} = ${mainModule}:main"]},
- version="0.0.0",
- url="git://simatime.com/omni.git",
- author="dev",
- author_email="dev@simatime.com",
- description="nil",
- packages=find_packages(),
- install_requires=[],
- )
- EOF
- '';
- pythonImportsCheck = [ mainModule ]; # sanity check
- };
+ python = python.buildPythonApplication rec {
+ inherit name src CODEROOT;
+ nativeBuildInputs = [makeWrapper];
+ propagatedBuildInputs = langdeps_ ++ sysdeps_ ++ rundeps_;
+ buildInputs = sysdeps_;
+ nativeCheckInputs = [pkgs.ruff python.packages.mypy];
+ checkPhase = ''
+ . ${commonBash}
+ cp ${../../pyproject.toml} ./pyproject.toml
+ check ruff format --exclude 'setup.py' --check .
+ # ignore EXE here to support run.sh shebangs
+ check ruff check \
+ --ignore EXE \
+ --exclude 'setup.py' \
+ --exclude '__init__.py' \
+ .
+ touch ./py.typed
+ check python -m mypy \
+ --explicit-package-bases \
+ --no-error-summary \
+ --exclude 'setup\.py$' \
+ .
+ '';
+ installCheck = ''
+ . ${commonBash}
+ check python -m ${mainModule} test
+ '';
+ preBuild = ''
+ # remove empty directories, leftover from the src filter
+ find . -type d -empty -delete
+ # initialize remaining dirs as python modules
+ find . -type d -exec touch {}/__init__.py \;
+ # generate a minimal setup.py
+ cat > setup.py << EOF
+ from setuptools import find_packages, setup
+ setup(
+ name="${name}",
+ entry_points={"console_scripts":["${name} = ${mainModule}:main"]},
+ version="0.0.0",
+ url="git://simatime.com/omni.git",
+ author="dev",
+ author_email="dev@simatime.com",
+ description="nil",
+ packages=find_packages(),
+ install_requires=[],
+ )
+ EOF
+ '';
+ pythonImportsCheck = [mainModule]; # sanity check
};
- in builders.${target.builder};
+ };
+ in
+ builders.${target.builder};
# the bild caller gives us the Analysis type, which is a hashmap, but i need to
# return a single drv, so just take the first one for now. ideally i would only
# pass Target, one at a time, (perhaps parallelized in haskell land) and then i
# wouldn't need all of this let nesting
-in builtins.head (lib.attrsets.mapAttrsToList build analysis)
+in
+ builtins.head (lib.attrsets.mapAttrsToList build analysis)
diff --git a/Omni/Bild/CcacheWrapper.nix b/Omni/Bild/CcacheWrapper.nix
index 644c2f6..26e6fc3 100644
--- a/Omni/Bild/CcacheWrapper.nix
+++ b/Omni/Bild/CcacheWrapper.nix
@@ -1,6 +1,4 @@
-self: super:
-
-let
+self: super: let
# this should come from config.programs.ccache.cacheDir but I can't figure out
# how to access that from a nixpkgs overlay, so just hardcode the default
ccacheDir = "/var/cache/ccache";
@@ -9,11 +7,13 @@ let
# deadnix: skip
fixwebkit = pkg:
self.useCcacheStdenv (pkg.overrideAttrs (attrs: rec {
- preConfigure = attrs.preConfigure + ''
- # not sure which of these works so just do them both
- export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
- ninjaFlagsArray+=("-l$NIX_BUILD_CORES")
- '';
+ preConfigure =
+ attrs.preConfigure
+ + ''
+ # not sure which of these works so just do them both
+ export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
+ ninjaFlagsArray+=("-l$NIX_BUILD_CORES")
+ '';
}));
in {
ccacheWrapper = super.ccacheWrapper.override {
@@ -42,7 +42,7 @@ in {
'';
};
- useCcacheStdenv = pkg: pkg.override { stdenv = super.ccacheStdenv; };
+ useCcacheStdenv = pkg: pkg.override {stdenv = super.ccacheStdenv;};
cudann = self.useCcacheStdenv super.cudann;
llvm = self.useCcacheStdenv super.llvm;
diff --git a/Omni/Bild/Constants.nix b/Omni/Bild/Constants.nix
index 776f580..f54de97 100644
--- a/Omni/Bild/Constants.nix
+++ b/Omni/Bild/Constants.nix
@@ -1 +1 @@
-{ ghcCompiler = "ghc966"; }
+{ghcCompiler = "ghc966";}
diff --git a/Omni/Bild/Deps.nix b/Omni/Bild/Deps.nix
index 3414418..0b23f9f 100644
--- a/Omni/Bild/Deps.nix
+++ b/Omni/Bild/Deps.nix
@@ -1,6 +1,4 @@
-_self: super:
-
-{
+_self: super: {
# Needs upgrading for guile 3
# inspekt3d = super.callPackage ./Deps/inspekt3d.nix {};
@@ -28,9 +26,9 @@ _self: super:
llm = super.overrideSrc super.llm super.sources.llm;
- nostr-rs-relay = super.callPackage ./Deps/nostr-rs-relay.nix { };
+ nostr-rs-relay = super.callPackage ./Deps/nostr-rs-relay.nix {};
- ollama = super.ollama.override { acceleration = "cuda"; };
+ ollama = super.ollama.override {acceleration = "cuda";};
- radicale = super.radicale.overrideAttrs (_old: { doCheck = false; });
+ radicale = super.radicale.overrideAttrs (_old: {doCheck = false;});
}
diff --git a/Omni/Bild/Deps/C.nix b/Omni/Bild/Deps/C.nix
index 3f670cd..833fc40 100644
--- a/Omni/Bild/Deps/C.nix
+++ b/Omni/Bild/Deps/C.nix
@@ -1 +1 @@
-[ "libsodium" ]
+["libsodium"]
diff --git a/Omni/Bild/Deps/Haskell.nix b/Omni/Bild/Deps/Haskell.nix
index 04f3a74..5d6abbb 100644
--- a/Omni/Bild/Deps/Haskell.nix
+++ b/Omni/Bild/Deps/Haskell.nix
@@ -1,6 +1,5 @@
# This is the global set of Haskell packages which gets deployed to Hoogle, and
# is available for selecting.
-
[
"MonadRandom"
"QuickCheck"
diff --git a/Omni/Bild/Deps/accelerate.nix b/Omni/Bild/Deps/accelerate.nix
index be1d2fd..55a8609 100644
--- a/Omni/Bild/Deps/accelerate.nix
+++ b/Omni/Bild/Deps/accelerate.nix
@@ -1,10 +1,16 @@
-{ fetchFromGitHub, buildPythonPackage, numpy, packaging, psutil, pyyaml, torch
+{
+ fetchFromGitHub,
+ buildPythonPackage,
+ numpy,
+ packaging,
+ psutil,
+ pyyaml,
+ torch,
}:
-
buildPythonPackage rec {
name = "accelerate";
version = "0.15.0";
- propagatedBuildInputs = [ numpy packaging psutil pyyaml torch ];
+ propagatedBuildInputs = [numpy packaging psutil pyyaml torch];
doCheck = false;
src = fetchFromGitHub {
owner = "huggingface";
@@ -13,4 +19,3 @@ buildPythonPackage rec {
sha256 = "sha256-agfbOaa+Nm10HZkd2Y7zR3R37n+vLNsxCyxZax6O3Lo=";
};
}
-
diff --git a/Omni/Bild/Deps/bitsandbytes.nix b/Omni/Bild/Deps/bitsandbytes.nix
index eb32aac..c336559 100644
--- a/Omni/Bild/Deps/bitsandbytes.nix
+++ b/Omni/Bild/Deps/bitsandbytes.nix
@@ -1,7 +1,17 @@
-{ lib, buildPythonPackage, fetchFromGitHub, python, pythonOlder, pytestCheckHook
-, setuptools, torch, einops, lion-pytorch, scipy, symlinkJoin }:
-
-let
+{
+ lib,
+ buildPythonPackage,
+ fetchFromGitHub,
+ python,
+ pythonOlder,
+ pytestCheckHook,
+ setuptools,
+ torch,
+ einops,
+ lion-pytorch,
+ scipy,
+ symlinkJoin,
+}: let
pname = "bitsandbytes";
version = "0.38.0";
@@ -24,63 +34,68 @@ let
[
cuda_cudart # cuda_runtime.h cuda_runtime_api.h
cuda_nvcc
- ] ++ cuda-common-redist;
+ ]
+ ++ cuda-common-redist;
};
cuda-redist = symlinkJoin {
name = "cuda-redist-${cudaVersion}";
paths = cuda-common-redist;
};
-
-in buildPythonPackage {
- inherit pname version;
- format = "pyproject";
-
- disabled = pythonOlder "3.7";
-
- src = fetchFromGitHub {
- owner = "TimDettmers";
- repo = pname;
- rev = "refs/tags/${version}";
- hash = "sha256-gGlbzTDvZNo4MhcYzLvWuB2ec7q+Qt5/LtTbJ0Rc+Kk=";
- };
-
- postPatch = ''
- substituteInPlace Makefile --replace "/usr/bin/g++" "g++" --replace "lib64" "lib"
- substituteInPlace bitsandbytes/cuda_setup/main.py \
- --replace "binary_path = package_dir / binary_name" \
- "binary_path = Path('$out/${python.sitePackages}/${pname}')/binary_name"
- '' + lib.optionalString torch.cudaSupport ''
- substituteInPlace bitsandbytes/cuda_setup/main.py \
- --replace "/usr/local/cuda/lib64" "${cuda-native-redist}/lib"
- '';
-
- CUDA_HOME = "${cuda-native-redist}";
-
- preBuild = if torch.cudaSupport then
- with torch.cudaPackages;
- let
- cudaVersion = lib.concatStrings
- (lib.splitVersion torch.cudaPackages.cudaMajorMinorVersion);
- in "make CUDA_VERSION=${cudaVersion} cuda${cudaMajorVersion}x"
- else
- "make CUDA_VERSION=CPU cpuonly";
-
- nativeBuildInputs = [ setuptools ]
- ++ lib.optionals torch.cudaSupport [ cuda-native-redist ];
- buildInputs = lib.optionals torch.cudaSupport [ cuda-redist ];
-
- propagatedBuildInputs = [ torch ];
-
- doCheck = false; # tests require CUDA and also GPU access
- nativeCheckInputs = [ pytestCheckHook einops lion-pytorch scipy ];
-
- pythonImportsCheck = [ "bitsandbytes" ];
-
- meta = with lib; {
- homepage = "https://github.com/TimDettmers/bitsandbytes";
- description = "8-bit CUDA functions for PyTorch";
- license = licenses.mit;
- maintainers = with maintainers; [ bcdarwin ];
- };
-}
+in
+ buildPythonPackage {
+ inherit pname version;
+ format = "pyproject";
+
+ disabled = pythonOlder "3.7";
+
+ src = fetchFromGitHub {
+ owner = "TimDettmers";
+ repo = pname;
+ rev = "refs/tags/${version}";
+ hash = "sha256-gGlbzTDvZNo4MhcYzLvWuB2ec7q+Qt5/LtTbJ0Rc+Kk=";
+ };
+
+ postPatch =
+ ''
+ substituteInPlace Makefile --replace "/usr/bin/g++" "g++" --replace "lib64" "lib"
+ substituteInPlace bitsandbytes/cuda_setup/main.py \
+ --replace "binary_path = package_dir / binary_name" \
+ "binary_path = Path('$out/${python.sitePackages}/${pname}')/binary_name"
+ ''
+ + lib.optionalString torch.cudaSupport ''
+ substituteInPlace bitsandbytes/cuda_setup/main.py \
+ --replace "/usr/local/cuda/lib64" "${cuda-native-redist}/lib"
+ '';
+
+ CUDA_HOME = "${cuda-native-redist}";
+
+ preBuild =
+ if torch.cudaSupport
+ then
+ with torch.cudaPackages; let
+ cudaVersion =
+ lib.concatStrings
+ (lib.splitVersion torch.cudaPackages.cudaMajorMinorVersion);
+ in "make CUDA_VERSION=${cudaVersion} cuda${cudaMajorVersion}x"
+ else "make CUDA_VERSION=CPU cpuonly";
+
+ nativeBuildInputs =
+ [setuptools]
+ ++ lib.optionals torch.cudaSupport [cuda-native-redist];
+ buildInputs = lib.optionals torch.cudaSupport [cuda-redist];
+
+ propagatedBuildInputs = [torch];
+
+ doCheck = false; # tests require CUDA and also GPU access
+ nativeCheckInputs = [pytestCheckHook einops lion-pytorch scipy];
+
+ pythonImportsCheck = ["bitsandbytes"];
+
+ meta = with lib; {
+ homepage = "https://github.com/TimDettmers/bitsandbytes";
+ description = "8-bit CUDA functions for PyTorch";
+ license = licenses.mit;
+ maintainers = with maintainers; [bcdarwin];
+ };
+ }
diff --git a/Omni/Bild/Deps/guile-opengl.nix b/Omni/Bild/Deps/guile-opengl.nix
index af01082..cb625e6 100644
--- a/Omni/Bild/Deps/guile-opengl.nix
+++ b/Omni/Bild/Deps/guile-opengl.nix
@@ -1,32 +1,40 @@
-{ stdenv, lib, fetchurl, pkg-config, guile, libGL, libGLU, freeglut }:
-
-let
+{
+ stdenv,
+ lib,
+ fetchurl,
+ pkg-config,
+ guile,
+ libGL,
+ libGLU,
+ freeglut,
+}: let
name = "guile-opengl-${version}";
version = "0.1.0";
-in stdenv.mkDerivation {
- inherit name;
+in
+ stdenv.mkDerivation {
+ inherit name;
- src = fetchurl {
- url = "mirror://gnu/guile-opengl/${name}.tar.gz";
- sha256 = "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim";
- };
+ src = fetchurl {
+ url = "mirror://gnu/guile-opengl/${name}.tar.gz";
+ sha256 = "13qfx4xh8baryxqrv986l848ygd0piqwm6s2s90pxk9c0m9vklim";
+ };
- patchPhase = ''
- substituteInPlace glx/runtime.scm \
- --replace '(dynamic-link "libGL")' '(dynamic-link "${libGL}/lib/libGL.so")'
- substituteInPlace glu/runtime.scm \
- --replace '(dynamic-link "libGLU")' '(dynamic-link "${libGLU}/lib/libGLU.so")'
- substituteInPlace glut/runtime.scm \
- --replace '(dynamic-link "libglut")' '(dynamic-link "${freeglut}/lib/libglut.so")'
- '';
+ patchPhase = ''
+ substituteInPlace glx/runtime.scm \
+ --replace '(dynamic-link "libGL")' '(dynamic-link "${libGL}/lib/libGL.so")'
+ substituteInPlace glu/runtime.scm \
+ --replace '(dynamic-link "libGLU")' '(dynamic-link "${libGLU}/lib/libGLU.so")'
+ substituteInPlace glut/runtime.scm \
+ --replace '(dynamic-link "libglut")' '(dynamic-link "${freeglut}/lib/libglut.so")'
+ '';
- nativeBuildInputs = [ pkg-config guile libGL libGLU freeglut ];
+ nativeBuildInputs = [pkg-config guile libGL libGLU freeglut];
- meta = with lib; {
- description = "Guile bindings for the OpenGL graphics API";
- homepage = "https://www.gnu.org/software/guile-opengl/";
- license = licenses.gpl3Plus;
- maintainers = with maintainers; [ vyp ];
- platforms = platforms.all;
- };
-}
+ meta = with lib; {
+ description = "Guile bindings for the OpenGL graphics API";
+ homepage = "https://www.gnu.org/software/guile-opengl/";
+ license = licenses.gpl3Plus;
+ maintainers = with maintainers; [vyp];
+ platforms = platforms.all;
+ };
+ }
diff --git a/Omni/Bild/Deps/inspekt3d.nix b/Omni/Bild/Deps/inspekt3d.nix
index 3146350..de3db4e 100644
--- a/Omni/Bild/Deps/inspekt3d.nix
+++ b/Omni/Bild/Deps/inspekt3d.nix
@@ -1,15 +1,24 @@
-{ stdenv, lib, autoreconfHook, pkg-config, guile, guile-opengl, mesa
-, glibcLocales, libfive, sources }:
-
+{
+ stdenv,
+ lib,
+ autoreconfHook,
+ pkg-config,
+ guile,
+ guile-opengl,
+ mesa,
+ glibcLocales,
+ libfive,
+ sources,
+}:
stdenv.mkDerivation {
name = "inspekt3d-unstable";
src = sources.inspekt3d;
version = "unstable-2018-10-17";
- nativeBuildInputs = [ pkg-config autoreconfHook ];
- buildInputs = [ guile glibcLocales mesa ];
- propagatedBuildInputs = [ guile-opengl libfive ];
+ nativeBuildInputs = [pkg-config autoreconfHook];
+ buildInputs = [guile glibcLocales mesa];
+ propagatedBuildInputs = [guile-opengl libfive];
preBuild = ''
substituteInPlace inspekt3d/library.scm \
@@ -24,7 +33,7 @@ stdenv.mkDerivation {
description = "Lightweight 3D viewer for Libfive written in Guile Scheme";
homepage = "https://sr.ht/~morgansmith/inspekt3d";
license = licenses.gpl3;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
platforms = platforms.all;
};
}
diff --git a/Omni/Bild/Deps/interegular.nix b/Omni/Bild/Deps/interegular.nix
index 24065d8..b46f4c8 100644
--- a/Omni/Bild/Deps/interegular.nix
+++ b/Omni/Bild/Deps/interegular.nix
@@ -1,5 +1,8 @@
-{ lib, sources, buildPythonPackage }:
-
+{
+ lib,
+ sources,
+ buildPythonPackage,
+}:
buildPythonPackage rec {
pname = "interegular";
version = sources.interegular.rev;
@@ -7,15 +10,15 @@ buildPythonPackage rec {
src = sources.interegular;
- propagatedBuildInputs = [ ];
+ propagatedBuildInputs = [];
doCheck = false; # no tests currently
- pythonImportsCheck = [ "interegular" ];
+ pythonImportsCheck = ["interegular"];
meta = with lib; {
description = "Allows to check regexes for overlaps.";
homepage = "https://github.com/MegaIng/interegular";
license = licenses.mit;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
};
}
diff --git a/Omni/Bild/Deps/lion-pytorch.nix b/Omni/Bild/Deps/lion-pytorch.nix
index 7b06e78..e8fcf3d 100644
--- a/Omni/Bild/Deps/lion-pytorch.nix
+++ b/Omni/Bild/Deps/lion-pytorch.nix
@@ -1,5 +1,10 @@
-{ lib, buildPythonPackage, pythonOlder, fetchFromGitHub, torch }:
-
+{
+ lib,
+ buildPythonPackage,
+ pythonOlder,
+ fetchFromGitHub,
+ torch,
+}:
buildPythonPackage rec {
pname = "lion-pytorch";
version = "0.1.2";
@@ -13,15 +18,15 @@ buildPythonPackage rec {
hash = "sha256-9hdpRJvCpv3PeC7f0IXpHt6i+e6LiT0QUl5jeDGelQE=";
};
- propagatedBuildInputs = [ torch ];
+ propagatedBuildInputs = [torch];
- pythonImportsCheck = [ "lion_pytorch" ];
+ pythonImportsCheck = ["lion_pytorch"];
doCheck = false; # no tests currently
meta = with lib; {
description = "Optimizer tuned by Google Brain using genetic algorithms";
homepage = "https://github.com/lucidrains/lion-pytorch";
license = licenses.mit;
- maintainers = with maintainers; [ bcdarwin ];
+ maintainers = with maintainers; [bcdarwin];
};
}
diff --git a/Omni/Bild/Deps/llm-ollama.nix b/Omni/Bild/Deps/llm-ollama.nix
index e2b6a66..15b26cc 100644
--- a/Omni/Bild/Deps/llm-ollama.nix
+++ b/Omni/Bild/Deps/llm-ollama.nix
@@ -1,5 +1,13 @@
-{ buildPythonPackage, fetchFromGitHub, lib, llm, ollama, pytestCheckHook
-, setuptools, pythonOlder, }:
+{
+ buildPythonPackage,
+ fetchFromGitHub,
+ lib,
+ llm,
+ ollama,
+ pytestCheckHook,
+ setuptools,
+ pythonOlder,
+}:
buildPythonPackage rec {
pname = "llm-ollama";
version = "0.3.0";
@@ -14,27 +22,26 @@ buildPythonPackage rec {
hash = "sha256-Ar0Ux8BNGY0i764CEk7+48J6jnndlRIIMPZ9tFpXiy4=";
};
- nativeBuildInputs = [ setuptools ];
+ nativeBuildInputs = [setuptools];
- buildInputs = [ llm ollama ];
+ buildInputs = [llm ollama];
- propagatedBuildInputs = [ ollama ];
+ propagatedBuildInputs = [ollama];
disabledTests = [
# wants to mkdir in the /homeless-shelter
"test_registered_models"
];
- nativeCheckInputs = [ pytestCheckHook ];
+ nativeCheckInputs = [pytestCheckHook];
- pythonImportsCheck = [ "llm_ollama" ];
+ pythonImportsCheck = ["llm_ollama"];
meta = with lib; {
homepage = "https://github.com/taketwo/llm-ollama";
- description =
- "LLM plugin providing access to local Ollama models usting HTTP API";
+ description = "LLM plugin providing access to local Ollama models usting HTTP API";
changelog = "https://github.com/taketwo/llm-ollama/releases/tag/${version}";
license = licenses.asl20;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
};
}
diff --git a/Omni/Bild/Deps/llm-sentence-transformers.nix b/Omni/Bild/Deps/llm-sentence-transformers.nix
index 4d63c83..f6766ee 100644
--- a/Omni/Bild/Deps/llm-sentence-transformers.nix
+++ b/Omni/Bild/Deps/llm-sentence-transformers.nix
@@ -1,5 +1,13 @@
-{ buildPythonPackage, fetchFromGitHub, lib, llm, sentence-transformers
-, pytestCheckHook, setuptools, pythonOlder, }:
+{
+ buildPythonPackage,
+ fetchFromGitHub,
+ lib,
+ llm,
+ sentence-transformers,
+ pytestCheckHook,
+ setuptools,
+ pythonOlder,
+}:
buildPythonPackage rec {
pname = "llm-sentence-transformers";
version = "0.2";
@@ -14,11 +22,11 @@ buildPythonPackage rec {
hash = "sha256-1NlKPWekdVLrNkIMWXLCRWn54RlAEuEDWMCDnQHNkBc=";
};
- nativeBuildInputs = [ setuptools ];
+ nativeBuildInputs = [setuptools];
- buildInputs = [ llm sentence-transformers ];
+ buildInputs = [llm sentence-transformers];
- propagatedBuildInputs = [ sentence-transformers ];
+ propagatedBuildInputs = [sentence-transformers];
# fails because of some pydantic warnings
doCheck = false;
@@ -27,16 +35,15 @@ buildPythonPackage rec {
"test_sentence_transformers"
];
- nativeCheckInputs = [ pytestCheckHook ];
+ nativeCheckInputs = [pytestCheckHook];
- pythonImportsCheck = [ "llm_sentence_transformers" ];
+ pythonImportsCheck = ["llm_sentence_transformers"];
meta = with lib; {
homepage = "https://github.com/taketwo/llm-sentence-transformers";
description = "LLM plugin for embeddings using sentence-transformers";
- changelog =
- "https://github.com/taketwo/llm-sentence-transformers/releases/tag/${version}";
+ changelog = "https://github.com/taketwo/llm-sentence-transformers/releases/tag/${version}";
license = licenses.asl20;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
};
}
diff --git a/Omni/Bild/Deps/ludic.nix b/Omni/Bild/Deps/ludic.nix
index dfac06c..58936c7 100644
--- a/Omni/Bild/Deps/ludic.nix
+++ b/Omni/Bild/Deps/ludic.nix
@@ -1,7 +1,19 @@
-{ buildPythonPackage, fetchFromGitHub, lib, setuptools, pytestCheckHook
-, python-multipart, starlette, typeguard, pygments, pytest, pytest-cov, httpx
-, hatchling, hatch-vcs }:
-
+{
+ buildPythonPackage,
+ fetchFromGitHub,
+ lib,
+ setuptools,
+ pytestCheckHook,
+ python-multipart,
+ starlette,
+ typeguard,
+ pygments,
+ pytest,
+ pytest-cov,
+ httpx,
+ hatchling,
+ hatch-vcs,
+}:
buildPythonPackage rec {
pname = "ludic";
version = "0.5.2";
@@ -14,23 +26,23 @@ buildPythonPackage rec {
hash = "sha256-Zcob2ljyeiCqnCobkDP4ihRTxvs5OtQ4y5+Itsgs/0o=";
};
- nativeBuildInputs = [ setuptools hatchling hatch-vcs ];
+ nativeBuildInputs = [setuptools hatchling hatch-vcs];
- propagatedBuildInputs = [ python-multipart starlette typeguard pygments ];
+ propagatedBuildInputs = [python-multipart starlette typeguard pygments];
- disabledTestPaths = [ "tests/contrib/test_django.py" ];
+ disabledTestPaths = ["tests/contrib/test_django.py"];
- nativeCheckInputs = [ pytestCheckHook ];
+ nativeCheckInputs = [pytestCheckHook];
- checkInputs = [ pytest pytest-cov httpx ];
+ checkInputs = [pytest pytest-cov httpx];
- pythonImportsCheck = [ "ludic" ];
+ pythonImportsCheck = ["ludic"];
meta = with lib; {
homepage = "https://github.com/getludic/ludic";
description = "Web Development in Pure Python with Type-Guided Components.";
changelog = "https://github.com/getludic/ludic/releases/tag/${version}";
license = licenses.mit;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
};
}
diff --git a/Omni/Bild/Deps/nostr-rs-relay.nix b/Omni/Bild/Deps/nostr-rs-relay.nix
index 0eef13f..df76cdd 100644
--- a/Omni/Bild/Deps/nostr-rs-relay.nix
+++ b/Omni/Bild/Deps/nostr-rs-relay.nix
@@ -1,5 +1,9 @@
-{ fetchFromSourcehut, rustPlatform, pkg-config, openssl }:
-
+{
+ fetchFromSourcehut,
+ rustPlatform,
+ pkg-config,
+ openssl,
+}:
rustPlatform.buildRustPackage rec {
pname = "nostr-rs-relay";
version = "0.7.15";
@@ -13,7 +17,7 @@ rustPlatform.buildRustPackage rec {
cargoSha256 = "sha256-3593pjc4A4NsEnE/ZYsR1vSMCvw2ZJue4EIY6cFa2WA=";
- nativeBuildInputs = [ pkg-config openssl.dev ];
+ nativeBuildInputs = [pkg-config openssl.dev];
- buildInputs = [ openssl.dev ];
+ buildInputs = [openssl.dev];
}
diff --git a/Omni/Bild/Deps/outlines.nix b/Omni/Bild/Deps/outlines.nix
index 29ef41b..6426c15 100644
--- a/Omni/Bild/Deps/outlines.nix
+++ b/Omni/Bild/Deps/outlines.nix
@@ -1,6 +1,19 @@
-{ lib, sources, buildPythonPackage, interegular, jinja2, lark, numpy, perscache
-, pillow, pydantic, regex, scipy, tenacity, torch }:
-
+{
+ lib,
+ sources,
+ buildPythonPackage,
+ interegular,
+ jinja2,
+ lark,
+ numpy,
+ perscache,
+ pillow,
+ pydantic,
+ regex,
+ scipy,
+ tenacity,
+ torch,
+}:
buildPythonPackage rec {
pname = "outlines";
version = sources.outlines.rev;
@@ -23,12 +36,12 @@ buildPythonPackage rec {
];
doCheck = false; # no tests currently
- pythonImportsCheck = [ "outlines" ];
+ pythonImportsCheck = ["outlines"];
meta = with lib; {
description = "Probabilistic Generative Model Programming";
homepage = "https://github.com/normal-computing/outlines";
license = licenses.asl20;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
};
}
diff --git a/Omni/Bild/Deps/perscache.nix b/Omni/Bild/Deps/perscache.nix
index 508a261..889f91c 100644
--- a/Omni/Bild/Deps/perscache.nix
+++ b/Omni/Bild/Deps/perscache.nix
@@ -1,16 +1,23 @@
-{ lib, sources, buildPythonPackage, beartype, cloudpickle, icontract, pbr }:
-
+{
+ lib,
+ sources,
+ buildPythonPackage,
+ beartype,
+ cloudpickle,
+ icontract,
+ pbr,
+}:
buildPythonPackage rec {
pname = "perscache";
version = sources.perscache.rev;
src = sources.perscache;
- propagatedBuildInputs = [ beartype cloudpickle icontract pbr ];
+ propagatedBuildInputs = [beartype cloudpickle icontract pbr];
PBR_VERSION = version;
doCheck = false; # no tests currently
- pythonImportsCheck = [ "perscache" ];
+ pythonImportsCheck = ["perscache"];
meta = with lib; {
description = ''
@@ -20,6 +27,6 @@ buildPythonPackage rec {
'';
homepage = "https://github.com/leshchenko1979/perscache";
license = licenses.mit;
- maintainers = with maintainers; [ bsima ];
+ maintainers = with maintainers; [bsima];
};
}
diff --git a/Omni/Bild/Functions.nix b/Omni/Bild/Functions.nix
index 8b87f86..2a40da2 100644
--- a/Omni/Bild/Functions.nix
+++ b/Omni/Bild/Functions.nix
@@ -10,24 +10,25 @@ _: super: {
# rules. This will fail if build steps have changed, or if no build
# rules are available upstream.
overrideSource = depName:
- if super ? "${depName}" && super.${depName} ? overrideAttrs then
+ if super ? "${depName}" && super.${depName} ? overrideAttrs
+ then
super.${depName}.overrideAttrs (attrs:
- attrs // rec {
+ attrs
+ // rec {
version =
super.sources.${depName}.version or super.sources.${depName}.rev;
src = super.sources.${depName};
})
- else
- null;
+ else null;
# Simply override the 'src' attr on a drv. This is meant to be a simpler
# alternative to 'overrideSource' above. In an overlay, use it like:
# mypkg = super.overrideSrc super.mypkg super.sources.mypkg;
overrideSrc = dep: src:
dep.overrideAttrs (attrs:
- attrs // {
+ attrs
+ // {
version = src.version or src.rev;
src = src;
});
}
-
diff --git a/Omni/Bild/Haskell.nix b/Omni/Bild/Haskell.nix
index 764ef5d..7e969da 100644
--- a/Omni/Bild/Haskell.nix
+++ b/Omni/Bild/Haskell.nix
@@ -1,37 +1,38 @@
-_self: super:
-
-let
+_self: super: let
inherit (import ./Constants.nix) ghcCompiler;
- buildCabal = sel: name: sel.callCabal2nix name super.sources.${name} { };
-
+ buildCabal = sel: name: sel.callCabal2nix name super.sources.${name} {};
in rec {
-
- haskell = super.haskell // {
- packages = super.haskell.packages // {
- "${ghcCompiler}" = super.haskell.packages."${ghcCompiler}".override
- (_old: {
- overrides = with super.pkgs.haskell.lib;
- sel: sup:
- super.overridePinnedDeps (buildCabal sel) // {
- ap-normalize = dontCheck sup.ap-normalize;
- clay = doJailbreak sup.clay;
- cmark = doJailbreak sup.cmark;
- docopt = buildCabal sel "docopt";
- filelock = dontCheck sup.filelock;
- linear-generics = doJailbreak sup.linear-generics;
- req = doJailbreak sup.req;
- servant-auth = doJailbreak sup.servant-auth;
- servant-auth-server = dontCheck sup.servant-auth-server;
- shellcheck = doJailbreak sup.shellcheck;
- string-qq = doJailbreak sup.string-qq;
- syb-with-class = doJailbreak sup.syb-with-class;
- th-abstraction = doJailbreak sup.th-abstraction;
- };
- });
+ haskell =
+ super.haskell
+ // {
+ packages =
+ super.haskell.packages
+ // {
+ "${ghcCompiler}" =
+ super.haskell.packages."${ghcCompiler}".override
+ (_old: {
+ overrides = with super.pkgs.haskell.lib;
+ sel: sup:
+ super.overridePinnedDeps (buildCabal sel)
+ // {
+ ap-normalize = dontCheck sup.ap-normalize;
+ clay = doJailbreak sup.clay;
+ cmark = doJailbreak sup.cmark;
+ docopt = buildCabal sel "docopt";
+ filelock = dontCheck sup.filelock;
+ linear-generics = doJailbreak sup.linear-generics;
+ req = doJailbreak sup.req;
+ servant-auth = doJailbreak sup.servant-auth;
+ servant-auth-server = dontCheck sup.servant-auth-server;
+ shellcheck = doJailbreak sup.shellcheck;
+ string-qq = doJailbreak sup.string-qq;
+ syb-with-class = doJailbreak sup.syb-with-class;
+ th-abstraction = doJailbreak sup.th-abstraction;
+ };
+ });
+ };
};
- };
ormolu = super.haskellPackages.ormolu;
-
}
diff --git a/Omni/Bild/Nixpkgs.nix b/Omni/Bild/Nixpkgs.nix
index 828021c..c4934ce 100644
--- a/Omni/Bild/Nixpkgs.nix
+++ b/Omni/Bild/Nixpkgs.nix
@@ -1,5 +1,5 @@
let
- sources = import ./Sources.nix { sourcesFile = ./Sources.json; };
+ sources = import ./Sources.nix {sourcesFile = ./Sources.json;};
config = {
allowAliases = true;
@@ -16,7 +16,7 @@ let
depsOverlay = _: pkgs: pkgs.overridePinnedDeps pkgs.overrideSource;
overlays = [
- (_: _: { inherit sources; })
+ (_: _: {inherit sources;})
(import ./CcacheWrapper.nix)
(import ./Functions.nix)
depsOverlay
@@ -24,16 +24,15 @@ let
(import ./Python.nix)
(import ./Haskell.nix)
# backport newer packages from unstable
- (_: _: { unstable = nixos-unstable-small.pkgs; })
+ (_: _: {unstable = nixos-unstable-small.pkgs;})
];
nixos-unstable-small =
- import sources.nixos-unstable-small { inherit system config overlays; };
-
+ import sources.nixos-unstable-small {inherit system config overlays;};
in {
- nixos-24_05 = import sources.nixos-24_05 { inherit system config overlays; };
+ nixos-24_05 = import sources.nixos-24_05 {inherit system config overlays;};
- nixos-24_11 = import sources.nixos-24_11 { inherit system config overlays; };
+ nixos-24_11 = import sources.nixos-24_11 {inherit system config overlays;};
inherit nixos-unstable-small;
}
diff --git a/Omni/Bild/Python.nix b/Omni/Bild/Python.nix
index 88abe94..035b11c 100644
--- a/Omni/Bild/Python.nix
+++ b/Omni/Bild/Python.nix
@@ -1,15 +1,15 @@
_self: super: {
python312 = super.python312.override {
packageOverrides = _pyself: pysuper:
- with pysuper.pkgs.python312Packages;
- let dontCheck = p: p.overridePythonAttrs (_: { doCheck = false; });
+ with pysuper.pkgs.python312Packages; let
+ dontCheck = p: p.overridePythonAttrs (_: {doCheck = false;});
in {
- interegular = callPackage ./Deps/interegular.nix { };
+ interegular = callPackage ./Deps/interegular.nix {};
ipython = dontCheck pysuper.ipython;
- ludic = callPackage ./Deps/ludic.nix { };
+ ludic = callPackage ./Deps/ludic.nix {};
mypy = dontCheck pysuper.mypy;
- outlines = callPackage ./Deps/outlines.nix { };
- perscache = callPackage ./Deps/perscache.nix { };
+ outlines = callPackage ./Deps/outlines.nix {};
+ perscache = callPackage ./Deps/perscache.nix {};
tokenizers = dontCheck pysuper.tokenizers;
};
};
@@ -17,9 +17,9 @@ _self: super: {
python311 = super.python311.override {
packageOverrides = _pyself: pysuper:
with pysuper.pkgs.python311Packages; {
- llm-ollama = callPackage ./Deps/llm-ollama.nix { };
+ llm-ollama = callPackage ./Deps/llm-ollama.nix {};
llm-sentence-transformers =
- callPackage ./Deps/llm-sentence-transformers.nix { };
+ callPackage ./Deps/llm-sentence-transformers.nix {};
};
};
}
diff --git a/Omni/Bild/Sources.nix b/Omni/Bild/Sources.nix
index f7af81e..dbcd147 100644
--- a/Omni/Bild/Sources.nix
+++ b/Omni/Bild/Sources.nix
@@ -1,14 +1,13 @@
# This file has been generated by Niv.
-
let
-
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
-
- fetch_file = pkgs: name: spec:
- let name' = sanitizeName name + "-src";
- in if spec.builtin or true then
+ fetch_file = pkgs: name: spec: let
+ name' = sanitizeName name + "-src";
+ in
+ if spec.builtin or true
+ then
builtins_fetchurl {
inherit (spec) url sha256;
name = name';
@@ -19,9 +18,11 @@ let
name = name';
};
- fetch_tarball = pkgs: name: spec:
- let name' = sanitizeName name + "-src";
- in if spec.builtin or true then
+ fetch_tarball = pkgs: name: spec: let
+ name' = sanitizeName name + "-src";
+ in
+ if spec.builtin or true
+ then
builtins_fetchTarball {
name = name';
inherit (spec) url sha256;
@@ -32,18 +33,19 @@ let
inherit (spec) url sha256;
};
- fetch_git = name: spec:
- let
- ref = if spec ? ref then
- spec.ref
- else if spec ? branch then
- "refs/heads/${spec.branch}"
- else if spec ? tag then
- "refs/tags/${spec.tag}"
+ fetch_git = name: spec: let
+ ref =
+ if spec ? ref
+ then spec.ref
+ else if spec ? branch
+ then "refs/heads/${spec.branch}"
+ else if spec ? tag
+ then "refs/tags/${spec.tag}"
else
abort
"In git source '${name}': Please specify `ref`, `tag` or `branch`!";
- in builtins.fetchGit {
+ in
+ builtins.fetchGit {
url = spec.repo;
inherit (spec) rev;
inherit ref;
@@ -66,24 +68,27 @@ let
#
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
- sanitizeName = name:
- (concatMapStrings (s: if builtins.isList s then "-" else s)
- (builtins.split "[^[:alnum:]+._?=-]+"
- ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)));
+ sanitizeName = name: (concatMapStrings (s:
+ if builtins.isList s
+ then "-"
+ else s)
+ (builtins.split "[^[:alnum:]+._?=-]+"
+ ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)));
# The set of packages used when specs are fetched using non-builtins.
- mkPkgs = sources: system:
- let
- sourcesNixpkgs = import
- (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {
- inherit system;
- };
- hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
- hasThisAsNixpkgsPath = <nixpkgs> == ./.;
- in if builtins.hasAttr "nixpkgs" sources then
- sourcesNixpkgs
- else if hasNixpkgsPath && !hasThisAsNixpkgsPath then
- import <nixpkgs> { }
+ mkPkgs = sources: system: let
+ sourcesNixpkgs =
+ import
+ (builtins_fetchTarball {inherit (sources.nixpkgs) url sha256;}) {
+ inherit system;
+ };
+ hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
+ hasThisAsNixpkgsPath = <nixpkgs> == ./.;
+ in
+ if builtins.hasAttr "nixpkgs" sources
+ then sourcesNixpkgs
+ else if hasNixpkgsPath && !hasThisAsNixpkgsPath
+ then import <nixpkgs> {}
else
abort ''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
@@ -92,58 +97,62 @@ let
# The actual fetching function.
fetch = pkgs: name: spec:
-
- if !builtins.hasAttr "type" spec then
- abort "ERROR: niv spec ${name} does not have a 'type' attribute"
- else if spec.type == "file" then
- fetch_file pkgs name spec
- else if spec.type == "tarball" then
- fetch_tarball pkgs name spec
- else if spec.type == "git" then
- fetch_git name spec
- else if spec.type == "local" then
- fetch_local spec
- else if spec.type == "builtin-tarball" then
- fetch_builtin-tarball name
- else if spec.type == "builtin-url" then
- fetch_builtin-url name
+ if !builtins.hasAttr "type" spec
+ then abort "ERROR: niv spec ${name} does not have a 'type' attribute"
+ else if spec.type == "file"
+ then fetch_file pkgs name spec
+ else if spec.type == "tarball"
+ then fetch_tarball pkgs name spec
+ else if spec.type == "git"
+ then fetch_git name spec
+ else if spec.type == "local"
+ then fetch_local spec
+ else if spec.type == "builtin-tarball"
+ then fetch_builtin-tarball name
+ else if spec.type == "builtin-url"
+ then fetch_builtin-url name
else
abort
"ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# If the environment variable NIV_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
- replace = name: drv:
- let
- saneName = stringAsChars
- (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
- ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
- in if ersatz == "" then
- drv
- else
- # this turns the string into an actual Nix path (for both absolute and
- # relative paths)
- if builtins.substring 0 1 ersatz == "/" then
- /. + ersatz
+ replace = name: drv: let
+ saneName =
+ stringAsChars
+ (c:
+ if isNull (builtins.match "[a-zA-Z0-9]" c)
+ then "_"
+ else c)
+ name;
+ ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
+ in
+ if ersatz == ""
+ then drv
else
- /. + builtins.getEnv "PWD" + "/${ersatz}";
+ # this turns the string into an actual Nix path (for both absolute and
+ # relative paths)
+ if builtins.substring 0 1 ersatz == "/"
+ then /. + ersatz
+ else /. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
- mapAttrs = builtins.mapAttrs or (f: set:
- with builtins;
- listToAttrs (map (attr: {
- name = attr;
- value = f attr set.${attr};
- }) (attrNames set)));
+ mapAttrs =
+ builtins.mapAttrs
+ or (f: set:
+ with builtins;
+ listToAttrs (map (attr: {
+ name = attr;
+ value = f attr set.${attr};
+ }) (attrNames set)));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last:
- if first > last then
- [ ]
- else
- builtins.genList (n: first + n) (last - first + 1);
+ if first > last
+ then []
+ else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s:
@@ -155,53 +164,72 @@ let
concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
- optionalAttrs = cond: as: if cond then as else { };
+ optionalAttrs = cond: as:
+ if cond
+ then as
+ else {};
# fetchTarball version that is compatible between all the versions of Nix
- # deadnix: skip
- builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
- let inherit (builtins) lessThan nixVersion fetchTarball;
- in if lessThan nixVersion "1.12" then
+ builtins_fetchTarball = {
+ url,
+ name ? null,
+ # deadnix: skip
+ sha256,
+ } @ attrs: let
+ inherit (builtins) lessThan nixVersion fetchTarball;
+ in
+ if lessThan nixVersion "1.12"
+ then
fetchTarball
- ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
- else
- fetchTarball attrs;
+ ({inherit url;} // (optionalAttrs (!isNull name) {inherit name;}))
+ else fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
- # deadnix: skip
- builtins_fetchurl = { url, name ? null, sha256 }@attrs:
- let inherit (builtins) lessThan nixVersion fetchurl;
- in if lessThan nixVersion "1.12" then
+ builtins_fetchurl = {
+ url,
+ name ? null,
+ # deadnix: skip
+ sha256,
+ } @ attrs: let
+ inherit (builtins) lessThan nixVersion fetchurl;
+ in
+ if lessThan nixVersion "1.12"
+ then
fetchurl
- ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
- else
- fetchurl attrs;
+ ({inherit url;} // (optionalAttrs (!isNull name) {inherit name;}))
+ else fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (name: spec:
- if builtins.hasAttr "outPath" spec then
+ if builtins.hasAttr "outPath" spec
+ then
abort
"The values in sources.json should not have an 'outPath' attribute"
- else
- spec // { outPath = replace name (fetch config.pkgs name spec); })
+ else spec // {outPath = replace name (fetch config.pkgs name spec);})
config.sources;
# The "config" used by the fetchers
- mkConfig = { sourcesFile ?
- if builtins.pathExists ./sources.json then ./sources.json else null
- , sources ? if isNull sourcesFile then
- { }
- else
- builtins.fromJSON (builtins.readFile sourcesFile)
- , system ? builtins.currentSystem, pkgs ? mkPkgs sources system }: rec {
- # The sources, i.e. the attribute set of spec name to spec
- inherit sources;
-
- # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
- inherit pkgs;
- };
-
-in mkSources (mkConfig { }) // {
- __functor = _: settings: mkSources (mkConfig settings);
-}
+ mkConfig = {
+ sourcesFile ?
+ if builtins.pathExists ./sources.json
+ then ./sources.json
+ else null,
+ sources ?
+ if isNull sourcesFile
+ then {}
+ else builtins.fromJSON (builtins.readFile sourcesFile),
+ system ? builtins.currentSystem,
+ pkgs ? mkPkgs sources system,
+ }: rec {
+ # The sources, i.e. the attribute set of spec name to spec
+ inherit sources;
+
+ # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
+ inherit pkgs;
+ };
+in
+ mkSources (mkConfig {})
+ // {
+ __functor = _: settings: mkSources (mkConfig settings);
+ }