-
Notifications
You must be signed in to change notification settings - Fork 0
/
strap.nix
75 lines (75 loc) · 1.93 KB
/
strap.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
File 5 of 5
Prev
Up
Next
Base
browse →
Patchset 5
browse
Diff view:
{ lib, pkgs, ... }:
let
inherit (pkgs)
cacert
curl
makeInitrd
makeModulesClosure
nix
writeText
;
modulesClosure = pkgs.makeModulesClosure {
kernel = pkgs.linux;
firmware = pkgs.linux;
rootModules = [
"af_packet" "ext4" "sd_mod" "virtio_blk" "virtio_net"
"virtio_pci" "virtio_rng" "virtio_scsi"
"vfat" "nls_cp437" "nls_iso8859_1" "efivarfs"
];
allowMissing = false;
};
# systemd is an optional dependency of iputils, override it ourselves
dhcp = pkgs.dhcp.override {
iputils = pkgs.iputils.override { systemd = null; };
openldap = null;
};
# Nix complains when there is no /etc/passwd
passwd = writeText "passwd" ''
root:x:0:0:System administrator:/:/
'';
nixosenter = pkgs.substituteAll {
src = ../third_party/nixpkgs/nixos/modules/installer/tools/nixos-enter.sh;
inherit (pkgs) runtimeShell;
isExecutable = true;
};
# Build a path containing all packages that are used in nixstrap.
path = lib.concatStringsSep ":" [
"${pkgs.execline}/bin"
# Used for insmod.
"${pkgs.kmod}/bin"
# Used to format the disk.
"${pkgs.e2fsprogs}/bin"
# echo, touch, mkdir, dd, mount, umount, etc.
"${pkgs.busybox}/bin"
# GPT fdisk.
"${pkgs.gptfdisk}/bin"
# DHCP client, too lazy to write a udhcpc script.
"${dhcp}/bin"
# Using non-musl curl because Nix depends on it either way.
"${curl}/bin"
# Nix, obviously. Cannot be compiled with musl for Reasons.
"${nix}/bin"
];
init = pkgs.substituteAll {
src = ./init.execline;
isExecutable = true;
execline = pkgs.execline;
inherit cacert nixosenter path modulesClosure;
};
# Builds an initrd containing the nixstrap script.
initrd = pkgs.makeInitrd {
contents = [
{ object = init; symlink = "/init"; }
{ object = passwd; symlink = "/etc/passwd"; }
];
};
in initrd