Add custom kernel config to shrink the image size
Some checks failed
ci/woodpecker/push/ci Pipeline failed

This commit is contained in:
Daniel Lundin 2024-10-11 15:06:27 +02:00
parent 5413d6ab6b
commit d65e479bef
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
9 changed files with 2564 additions and 50 deletions

View file

@ -1,15 +0,0 @@
{ ... }:
{
imports = [
./modules/filesystems.nix
./modules/generic.nix
./modules/kernel.nix
./modules/minimize.nix
./modules/network.nix
./modules/patagia-agent.nix
./modules/partitions.nix
./modules/system_overrides.nix
./modules/sysupdate.nix
./modules/utils.nix
];
}

View file

@ -107,8 +107,16 @@
inherit patagia-agent;
};
}
./base.nix
./modules/kernel
./modules/filesystems.nix
./modules/generic.nix
./modules/minimize.nix
./modules/network.nix
# ./modules/patagia-agent.nix
./modules/partitions.nix
./modules/system_overrides.nix
./modules/sysupdate.nix
./modules/utils.nix
];
};
};

View file

@ -11,7 +11,6 @@
initrd.systemd.enable = true;
kernelParams = [
"console=ttyS0"
# "quiet"
];
loader.efi.canTouchEfiVariables = true;
loader.grub.enable = false;
@ -19,18 +18,7 @@
uki.name = "patos";
};
# Temporary files
boot.tmp.useTmpfs = true;
systemd.services.nix-daemon = {
environment.TMPDIR = "/var/tmp";
};
system.switch = {
enable = false;
enableNg = true;
};
services.fstrim.enable = true;
system.image.version = "0.0.1"; # FIXME: Use epoch version.
system.nixos = {
codeName = "Finn";
@ -39,7 +27,7 @@
release = "2024-09";
};
system.image.version = "0.0.1"; # FIXME: Use epoch version.
system.switch.enable = false;
# Make the current system version visible in the prompt.
programs.bash.promptInit = ''
@ -51,15 +39,21 @@
services.getty.autologinUser = "root";
# Don't accumulate crap.
# Temporary files
boot.tmp.cleanOnBoot = true;
boot.tmp.useTmpfs = true;
systemd.services.nix-daemon = {
environment.TMPDIR = "/var/tmp";
};
services.journald.extraConfig = ''
SystemMaxUse=10M
'';
services.fstrim.enable = true;
# Debugging
environment.systemPackages = with pkgs; [
parted
(runCommand "systemd-sysupdate" { } ''
mkdir -p $out/bin
ln -s ${config.systemd.package}/lib/systemd/systemd-sysupdate $out/bin

View file

@ -1,13 +0,0 @@
{ pkgs, ... }:
{
boot.kernelPackages = pkgs.linuxPackages_6_11;
boot.kernelPatches = [
{
# name = "crashdump-config";
patch = null;
extraConfig = ''
EROFS_FS_ZIP_ZSTD y
'';
}
];
}

View file

@ -0,0 +1,19 @@
{ lib, pkgs, ... }:
{
boot.kernelPackages =
let
version = "6.11.2";
in
pkgs.linuxPackagesFor (
pkgs.linuxManualConfig {
version = "${version}-patos1";
modDirVersion = version;
src = pkgs.fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${version}.tar.xz";
hash = "sha256:ec9ef7a0b9cebb55940e1ef87a1f9e1004b10456a119dc386bb3e565b0d39c42";
};
configfile = ./generic.config;
allowImportFromDerivation = true;
}
);
}

File diff suppressed because it is too large Load diff

View file

@ -5,12 +5,13 @@
];
nix.enable = false;
system.disableInstallerTools = true;
system.etc.overlay.enable = true;
systemd.sysusers.enable = true;
system.disableInstallerTools = true;
programs.less.lessopen = null;
programs.command-not-found.enable = false;
environment.defaultPackages = [ ];
}

View file

@ -21,7 +21,7 @@
mkfsOptions = {
erofs = [
"-zzstd,5" # Zstd compression
"-zzstd,6" # Zstd compression
"-T0" # Fixed timestamp for all files
"-Efragments,dedupe,ztailpacking" # Extended options
];
@ -31,7 +31,6 @@
"esp" = {
contents = {
"/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source = "${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
"/EFI/Linux/${config.system.boot.loader.ukiFile}".source = "${config.system.build.uki}/${config.system.boot.loader.ukiFile}";
# systemd-boot configuration
@ -59,7 +58,6 @@
Format = "erofs";
Minimize = "best";
ReadOnly = "yes";
SizeMinBytes = "1G";
SizeMaxBytes = "1G";
SplitName = "store";

View file

@ -1,4 +1,5 @@
final: prev: {
# Build mkfs.erofs with zstd support
erofs-utils = prev.erofs-utils.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [ prev.zstd ];
configureFlags = old.configureFlags ++ [