···7475#### `buildPythonPackage` function {#buildpythonpackage-function}
7677-The `buildPythonPackage` function is implemented in
78-`pkgs/development/interpreters/python/mk-python-derivation.nix`
079using setup hooks.
8081The following is an example:
···7475#### `buildPythonPackage` function {#buildpythonpackage-function}
7677+The `buildPythonPackage` function has its name binding in
78+`pkgs/development/interpreters/python/python-packages-base.nix` and is
79+implemented in `pkgs/development/interpreters/python/mk-python-derivation.nix`
80using setup hooks.
8182The following is an example:
···8586- [ollama](https://ollama.ai), server for running large language models locally.
870088- [hebbot](https://github.com/haecker-felix/hebbot), a Matrix bot to generate "This Week in X" like blog posts. Available as [services.hebbot](#opt-services.hebbot.enable).
8990- [Python Matter Server](https://github.com/home-assistant-libs/python-matter-server), a
···8586- [ollama](https://ollama.ai), server for running large language models locally.
8788+- [Mihomo](https://github.com/MetaCubeX/mihomo), a rule-based proxy in Go. Available as [services.mihomo.enable](#opt-services.mihomo.enable).
89+90- [hebbot](https://github.com/haecker-felix/hebbot), a Matrix bot to generate "This Week in X" like blog posts. Available as [services.hebbot](#opt-services.hebbot.enable).
9192- [Python Matter Server](https://github.com/home-assistant-libs/python-matter-server), a
+59-26
nixos/modules/image/repart-image.nix
···2# NixOS module that can be imported.
34{ lib
05, runCommand
6-, runCommandLocal
7, python3
8, black
9, ruff
···26, xz
2728 # arguments
0029, imageFileBasename
30, compression
31, fileSystems
32-, partitions
33, split
34, seed
35, definitionsDirectory
36, sectorSize
37, mkfsEnv ? {}
038}:
3940let
···52 mypy --strict $out
53 '';
5455- amendedRepartDefinitions = runCommandLocal "amended-repart.d" {} ''
56- definitions=$(${amendRepartDefinitions} ${partitions} ${definitionsDirectory})
57- cp -r $definitions $out
58- '';
59-60 fileSystemToolMapping = {
61 "vfat" = [ dosfstools mtools ];
62 "ext4" = [ e2fsprogs.bin ];
···78 "xz" = "xz --keep --verbose --threads=0 -${toString compression.level}";
79 }."${compression.algorithm}";
80in
81-82-runCommand imageFileBasename
83-{
0084 __structuredAttrs = true;
8586 nativeBuildInputs = [
87 systemd
88 fakeroot
89 util-linux
090 compressionPkg
91 ] ++ fileSystemTools;
9293 env = mkfsEnv;
940000095 systemdRepartFlags = [
96 "--dry-run=no"
97- "--empty=create"
98 "--size=auto"
99 "--seed=${seed}"
100- "--definitions=${amendedRepartDefinitions}"
101 "--split=${lib.boolToString split}"
102 "--json=pretty"
00103 ] ++ lib.optionals (sectorSize != null) [
104 "--sector-size=${toString sectorSize}"
105 ];
106107- passthru = {
108- inherit amendRepartDefinitions amendedRepartDefinitions;
109- };
110-} ''
111- mkdir -p $out
112- cd $out
000000000113114- echo "Building image with systemd-repart..."
115- unshare --map-root-user fakeroot systemd-repart \
116- ''${systemdRepartFlags[@]} \
117- ${imageFileBasename}.raw \
118- | tee repart-output.json
11900000000120 # Compression is implemented in the same derivation as opposed to in a
121 # separate derivation to allow users to save disk space. Disk images are
122 # already very space intensive so we want to allow users to mitigate this.
123- if ${lib.boolToString compression.enable}; then
0124 for f in ${imageFileBasename}*; do
125 echo "Compressing $f with ${compression.algorithm}..."
126 # Keep the original file when compressing and only delete it afterwards
127 ${compressionCommand} $f && rm $f
128 done
129- fi
130-''
00000000
···2# NixOS module that can be imported.
34{ lib
5+, stdenvNoCC
6, runCommand
07, python3
8, black
9, ruff
···26, xz
2728 # arguments
29+, name
30+, version
31, imageFileBasename
32, compression
33, fileSystems
34+, partitionsJSON
35, split
36, seed
37, definitionsDirectory
38, sectorSize
39, mkfsEnv ? {}
40+, createEmpty ? true
41}:
4243let
···55 mypy --strict $out
56 '';
570000058 fileSystemToolMapping = {
59 "vfat" = [ dosfstools mtools ];
60 "ext4" = [ e2fsprogs.bin ];
···76 "xz" = "xz --keep --verbose --threads=0 -${toString compression.level}";
77 }."${compression.algorithm}";
78in
79+ stdenvNoCC.mkDerivation (finalAttrs:
80+ (if (version != null)
81+ then { pname = name; inherit version; }
82+ else { inherit name; }
83+ ) // {
84 __structuredAttrs = true;
8586 nativeBuildInputs = [
87 systemd
88 fakeroot
89 util-linux
90+ ] ++ lib.optionals (compression.enable) [
91 compressionPkg
92 ] ++ fileSystemTools;
9394 env = mkfsEnv;
9596+ inherit partitionsJSON definitionsDirectory;
97+98+ # relative path to the repart definitions that are read by systemd-repart
99+ finalRepartDefinitions = "repart.d";
100+101 systemdRepartFlags = [
102 "--dry-run=no"
0103 "--size=auto"
104 "--seed=${seed}"
105+ "--definitions=${finalAttrs.finalRepartDefinitions}"
106 "--split=${lib.boolToString split}"
107 "--json=pretty"
108+ ] ++ lib.optionals createEmpty [
109+ "--empty=create"
110 ] ++ lib.optionals (sectorSize != null) [
111 "--sector-size=${toString sectorSize}"
112 ];
113114+ dontUnpack = true;
115+ dontConfigure = true;
116+ doCheck = false;
117+118+ patchPhase = ''
119+ runHook prePatch
120+121+ amendedRepartDefinitionsDir=$(${amendRepartDefinitions} $partitionsJSON $definitionsDirectory)
122+ ln -vs $amendedRepartDefinitionsDir $finalRepartDefinitions
123+124+ runHook postPatch
125+ '';
126+127+ buildPhase = ''
128+ runHook preBuild
129130+ echo "Building image with systemd-repart..."
131+ unshare --map-root-user fakeroot systemd-repart \
132+ ''${systemdRepartFlags[@]} \
133+ ${imageFileBasename}.raw \
134+ | tee repart-output.json
135136+ runHook postBuild
137+ '';
138+139+ installPhase = ''
140+ runHook preInstall
141+142+ mkdir -p $out
143+ ''
144 # Compression is implemented in the same derivation as opposed to in a
145 # separate derivation to allow users to save disk space. Disk images are
146 # already very space intensive so we want to allow users to mitigate this.
147+ + lib.optionalString compression.enable
148+ ''
149 for f in ${imageFileBasename}*; do
150 echo "Compressing $f with ${compression.algorithm}..."
151 # Keep the original file when compressing and only delete it afterwards
152 ${compressionCommand} $f && rm $f
153 done
154+ '' + ''
155+ mv -v repart-output.json ${imageFileBasename}* $out
156+157+ runHook postInstall
158+ '';
159+160+ passthru = {
161+ inherit amendRepartDefinitions;
162+ };
163+})
···2, lib
3, buildPythonPackage
4, fetchPypi
05, isPyPy
6, R
7, rWrapper
···38 # R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
39 # This patch sets R_LIBS_SITE when rpy2 is imported.
40 ./rpy2-3.x-r-libs-site.patch
00000041 ];
4243 postPatch = ''
···81 ];
8283 doCheck = !stdenv.isDarwin;
84-85- # newlines in environment variables are a problem due to
86- # https://github.com/rpy2/rpy2/issues/1066
87- preCheck = "unset postPatch";
8889 nativeCheckInputs = [
90 pytestCheckHook
···2, lib
3, buildPythonPackage
4, fetchPypi
5+, fetchpatch
6, isPyPy
7, R
8, rWrapper
···39 # R_LIBS_SITE is used by the nix r package to point to the installed R libraries.
40 # This patch sets R_LIBS_SITE when rpy2 is imported.
41 ./rpy2-3.x-r-libs-site.patch
42+43+ # https://github.com/rpy2/rpy2/pull/1094
44+ (fetchpatch {
45+ url = "https://github.com/rpy2/rpy2/commit/026d069a008163a62d12567bcb938410d0f9bf7a.diff";
46+ hash = "sha256-x778upSY3zab5EiRyOcsbDpPj7vN/7XzefEs+wvkNg0=";
47+ })
48 ];
4950 postPatch = ''
···88 ];
8990 doCheck = !stdenv.isDarwin;
00009192 nativeCheckInputs = [
93 pytestCheckHook