|
49 | 49 |
|
50 | 50 | # Minimal init script to launch the agent |
51 | 51 | initScript = pkgs.writeScript "init" '' |
52 | | - #!/bin/sh |
| 52 | + #!${pkgs.busybox}/bin/sh |
53 | 53 | set -e |
54 | 54 |
|
| 55 | + # Create busybox symlinks |
| 56 | + /bin/busybox --install -s /bin |
| 57 | +
|
55 | 58 | # Mount essential filesystems |
56 | 59 | mount -t proc proc /proc |
57 | 60 | mount -t sysfs sys /sys |
|
68 | 71 | exec /sbin/sandpolis |
69 | 72 | ''; |
70 | 73 |
|
71 | | - # Create initramfs with dracut |
| 74 | + # Create initramfs with makeInitrd |
72 | 75 | buildInitramfs = kernel: |
73 | | - pkgs.stdenv.mkDerivation { |
| 76 | + pkgs.makeInitrd { |
74 | 77 | name = "sandpolis-initramfs"; |
75 | 78 |
|
76 | | - nativeBuildInputs = [ pkgs.dracut pkgs.cpio pkgs.findutils ]; |
77 | | - |
78 | | - buildCommand = '' |
79 | | - mkdir -p $out |
80 | | -
|
81 | | - # Create a minimal root filesystem structure |
82 | | - mkdir -p rootfs/{bin,sbin,dev,proc,sys,tmp,run,var,lib,lib64,etc} |
83 | | -
|
84 | | - # Copy the agent binary |
85 | | - cp ${sandpolis-agent}/bin/sandpolis rootfs/sbin/sandpolis |
86 | | - chmod +x rootfs/sbin/sandpolis |
87 | | -
|
88 | | - # Copy the init script |
89 | | - cp ${initScript} rootfs/init |
90 | | - chmod +x rootfs/init |
91 | | -
|
92 | | - # Copy required shared libraries |
93 | | - mkdir -p rootfs/lib/x86_64-linux-gnu 2>/dev/null || true |
94 | | - mkdir -p rootfs/lib/aarch64-linux-gnu 2>/dev/null || true |
95 | | -
|
96 | | - # Find and copy all required shared libraries |
97 | | - for lib in $(ldd ${sandpolis-agent}/bin/sandpolis | grep -o '/nix/store/[^ ]*'); do |
98 | | - if [ -f "$lib" ]; then |
99 | | - cp -L "$lib" rootfs/lib/ 2>/dev/null || \ |
100 | | - cp -L "$lib" rootfs/lib64/ 2>/dev/null || true |
101 | | - fi |
102 | | - done |
103 | | -
|
104 | | - # Copy essential busybox for shell commands in init |
105 | | - cp ${pkgs.busybox}/bin/busybox rootfs/bin/sh |
106 | | - ln -s sh rootfs/bin/mount |
107 | | - ln -s sh rootfs/bin/ip |
108 | | - ln -s sh rootfs/bin/mkdir |
109 | | - ln -s sh rootfs/bin/echo |
110 | | - ln -s sh rootfs/bin/exec |
111 | | -
|
112 | | - # Create the initramfs with dracut |
113 | | - ${pkgs.dracut}/bin/dracut \ |
114 | | - --force \ |
115 | | - --no-hostonly \ |
116 | | - --no-hostonly-cmdline \ |
117 | | - --kmoddir ${kernel}/lib/modules \ |
118 | | - --kver "${kernel.version}" \ |
119 | | - --include rootfs / \ |
120 | | - --no-compress \ |
121 | | - $out/initramfs.img |
122 | | -
|
123 | | - echo "Initramfs created at $out/initramfs.img" |
124 | | - ''; |
| 79 | + # Use gzip compression (standard for initramfs) |
| 80 | + compressor = "gzip"; |
| 81 | + |
| 82 | + contents = [ |
| 83 | + # Include the init script at /init |
| 84 | + { |
| 85 | + object = initScript; |
| 86 | + symlink = "/init"; |
| 87 | + } |
| 88 | + |
| 89 | + # Include the Sandpolis agent |
| 90 | + { |
| 91 | + object = sandpolis-agent; |
| 92 | + symlink = "/sbin/sandpolis"; |
| 93 | + } |
| 94 | + |
| 95 | + # Include busybox for shell utilities |
| 96 | + { |
| 97 | + object = pkgs.busybox; |
| 98 | + symlink = "/bin/busybox"; |
| 99 | + } |
| 100 | + ]; |
125 | 101 | }; |
126 | 102 |
|
127 | 103 | kernel = pkgs.linuxPackages_latest.kernel; |
|
133 | 109 | name = "sandpolis-uki"; |
134 | 110 |
|
135 | 111 | nativeBuildInputs = [ |
136 | | - pkgs.systemd # provides ukify |
| 112 | + pkgs.systemdUkify # provides ukify |
137 | 113 | pkgs.binutils |
138 | 114 | ]; |
139 | 115 |
|
140 | 116 | buildCommand = '' |
141 | 117 | mkdir -p $out |
142 | 118 |
|
143 | | - # Use systemd's ukify to create the UKI |
144 | | - ${pkgs.systemd}/lib/systemd/ukify build \ |
| 119 | + # Use ukify to create the UKI |
| 120 | + ${pkgs.systemdUkify}/bin/ukify build \ |
145 | 121 | --linux=${kernel}/bzImage \ |
146 | | - --initrd=${initramfs}/initramfs.img \ |
| 122 | + --initrd=${initramfs}/initrd \ |
| 123 | + --os-release='NAME="Sandpolis" |
| 124 | + ID=sandpolis |
| 125 | + VERSION="0.1.0"' \ |
147 | 126 | --cmdline="console=ttyS0 console=tty0 quiet" \ |
148 | 127 | --output=$out/sandpolis.efi |
149 | 128 |
|
|
219 | 198 | pkgs.cmake |
220 | 199 | pkgs.openssl |
221 | 200 | pkgs.systemd |
222 | | - pkgs.dracut |
223 | 201 |
|
224 | 202 | # Testing/debugging tools |
225 | 203 | pkgs.qemu |
|
0 commit comments