From 881fad4fe0dbd634567c265aad537f3bba957260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 24 Sep 2024 21:53:37 +0200 Subject: [PATCH] save more space by using python3 minimal --- nix/kexec-installer/module.nix | 11 +++++++++-- nix/noninteractive.nix | 1 + nix/python-minimal.nix | 15 +++++++++++++++ nix/zfs-minimal.nix | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 nix/python-minimal.nix diff --git a/nix/kexec-installer/module.nix b/nix/kexec-installer/module.nix index 4bd1511..2e865bd 100644 --- a/nix/kexec-installer/module.nix +++ b/nix/kexec-installer/module.nix @@ -1,7 +1,14 @@ { config, lib, modulesPath, pkgs, ... }: let - restore-network = pkgs.writers.writePython3Bin "restore-network" { flakeIgnore = [ "E501" ]; } - ./restore_routes.py; + writePython3 = pkgs.writers.makePythonWriter + pkgs.python3Minimal pkgs.python3Packages pkgs.buildPackages.python3Packages; + + # writePython3Bin takes the same arguments as writePython3 but outputs a directory (like writeScriptBin) + writePython3Bin = name: writePython3 "/bin/${name}"; + + restore-network = writePython3Bin "restore-network" { + flakeIgnore = [ "E501" ]; + } ./restore_routes.py; # does not link with iptables enabled iprouteStatic = pkgs.pkgsStatic.iproute2.override { iptables = null; }; diff --git a/nix/noninteractive.nix b/nix/noninteractive.nix index 0af2458..41ae548 100644 --- a/nix/noninteractive.nix +++ b/nix/noninteractive.nix @@ -12,6 +12,7 @@ imports = [ ./zfs-minimal.nix ./no-bootloaders.nix + ./python-minimal.nix ./noveau-workaround.nix # reduce closure size by removing perl "${modulesPath}/profiles/perlless.nix" diff --git a/nix/python-minimal.nix b/nix/python-minimal.nix new file mode 100644 index 0000000..6ef3cc0 --- /dev/null +++ b/nix/python-minimal.nix @@ -0,0 +1,15 @@ +{ + nixpkgs.overlays = [ + (final: prev: { + bcachefs-tools = prev.bcachefs-tools.overrideAttrs (old: { + python3 = prev.python3Minimal; + }); + cifs-utils = prev.cifs-utils.overrideAttrs (old: { + python3 = prev.python3Minimal; + }); + nfs-utils = prev.nfs-utils.overrideAttrs (old: { + python3 = prev.python3Minimal; + }); + }) + ]; +} diff --git a/nix/zfs-minimal.nix b/nix/zfs-minimal.nix index 62a587f..855722f 100644 --- a/nix/zfs-minimal.nix +++ b/nix/zfs-minimal.nix @@ -4,6 +4,8 @@ let zfs = pkgs.zfsUnstable.override { # this overrides saves 10MB samba = pkgs.coreutils; + + python3 = pkgs.python3Minimal; }; in {