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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
{ buildSystem, config, inputs, lib, modulesPath, pkgs, ... }: {
imports = [
# Minimize the build to produce a smaller closure
(modulesPath + "/profiles/minimal.nix")
(import (inputs.mobile-nixos + "/lib/configuration.nix") { device = "oneplus-enchilada"; })
./firmware.nix
];
krebs.build.host = config.krebs.hosts.qi;
krebs.shadow.overridesFile =
"${config.krebs.secret.directory}/shadow-overrides";
# Cross-compiled where the builder's system differs, with ccache where the
# builder has /var/cache/ccache in its sandbox.
mobile.boot.stage-1.kernel.package = lib.mkForce (let
buildPkgs = import pkgs.path {
localSystem = buildSystem;
crossSystem = pkgs.stdenv.hostPlatform.system;
inherit (pkgs) config overlays;
};
stdenv = buildPkgs.ccacheStdenv.override {
extraConfig = /* sh */ ''
if [ -w /var/cache/ccache ]; then
export CCACHE_COMPRESS=1
export CCACHE_DIR=/var/cache/ccache
export CCACHE_SLOPPINESS=random_seed
export CCACHE_UMASK=007
else
export CCACHE_DIR=''${TMPDIR:-/tmp}/ccache
export CCACHE_DISABLE=1
fi
'';
};
in
buildPkgs.callPackage
(inputs.mobile-nixos + "/devices/families/sdm845-mainline/kernel")
{
mobile-nixos = buildPkgs.mobile-nixos // {
kernel-builder =
buildPkgs.mobile-nixos.kernel-builder.override { inherit stdenv; };
};
});
# The kernel has no modules.
boot.kernelModules = lib.mkForce [ ];
system.activationScripts.modprobe = lib.mkForce "";
networking.networkmanager.enable = false;
networking.wireless = {
extraConfig = "country=DE";
userControlled = true;
enable = true;
# The keys are in the secrets file, as lines of NAME=KEY. wpa_supplicant
# runs as a user of its own, which can't read the secrets (root's, mode
# 0600), so it gets a copy as a credential, which systemd reads as root.
secretsFile = "/run/credentials/wpa_supplicant.service/wireless.secrets";
networks = {
krebs.pskRaw = "ext:krebs";
Telefon.pskRaw = "ext:Telefon";
Vodafone-A72G.auth = ''
key_mgmt=SAE
ieee80211w=2
psk=ext:Vodafone-A72G
'';
pi.pskRaw = "ext:pi";
Pixel_1108.pskRaw = "ext:Pixel_1108";
};
};
systemd.services.wpa_supplicant.serviceConfig.LoadCredential = [
"wireless.secrets:${config.krebs.secret.directory}/wireless.secrets"
];
# The kernel looks for regulatory.db before the root is mounted.
systemd.services.regulatory-db = {
before = [ "wpa_supplicant.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.iw}/bin/iw reg reload";
};
};
zramSwap.enable = true;
environment.systemPackages = [
pkgs.git
pkgs.rsync
pkgs.btrfs-progs
];
nixpkgs.config.allowUnfree = false;
services.openssh.enable = true;
users.mutableUsers = false;
users.users = {
default = {
isNormalUser = true;
extraGroups = [
"wheel"
];
};
};
nix = {
settings = {
trusted-users = [ "@wheel" "root" ];
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
builders-use-substitutes = true;
flake-registry = builtins.toFile "empty-flake-registry.json" ''{"flakes":[],"version":2}'';
trust-tarballs-from-git-forges = true;
};
package = pkgs.nixVersions.latest;
nixPath = [ "/var/src" ];
};
# at least required for rebuild switch (not for creating the image)
# otherwise nixos-rebuild switch will fail with:
# Failed to install bootloader
# warning: error(s) occurred while switching to the new configuration
boot.loader.grub.enable = false;
system.build.installBootLoader = pkgs.writers.writeDash "install-bootloader" ''
echo DERP >&2
'';
services.journald.extraConfig = ''
Storage=volatile
'';
boot.growPartition = false;
boot.initrd.luks.devices.main = {
device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888889";
allowDiscards = true;
bypassWorkqueues = true;
};
fileSystems."/" = {
device = "/dev/mapper/main";
fsType = "btrfs";
};
}
|