-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
89 lines (74 loc) · 2.5 KB
/
flake.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
description = "Testing Bluetooth on a Raspberry Pi 4B";
inputs = {
nixpkgs = {
url = github:NixOS/nixpkgs/nixos-22.05;
};
flake-utils-plus = {
url = github:gytis-ivaskevicius/flake-utils-plus/v1.3.1;
};
};
outputs = { self, nixpkgs, flake-utils-plus }@attrs: rec {
nixosConfigurations.btpi = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
({ config, lib, ... }: flake-utils-plus.nixosModules.autoGenFromInputs { inputs = attrs; inherit config; inherit lib; })
{
nix.generateNixPathFromInputs = true;
}
({ pkgs, lib, ... }: {
# Host
networking.hostName = "btpi";
system.stateVersion = "22.05";
# Flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nix.settings.trusted-users = [ "root" "@wheel" ];
# SD card longevity
fileSystems."/".options = [ "noatime" ];
# Kernel
boot.kernelPackages = pkgs.linuxPackages_rpi4;
boot.kernelParams = lib.mkForce [ "8250.nr_uarts=1" "console=ttyS0,115200n8" "console=tty0" ];
# User
users.users.test = {
isNormalUser = true;
initialPassword = "test";
extraGroups = [ "wheel" ];
};
# SSH
services.openssh = {
enable = true;
permitRootLogin = "no";
};
networking.firewall.allowedTCPPorts = [ 22 ];
# Bluetooth
hardware.bluetooth.enable = true;
# SD image
sdImage.compressImage = false;
imports = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image.nix"
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
];
disabledModules = [
"profiles/all-hardware.nix"
"profiles/base.nix"
];
# Edit config.txt
#
# These changes will only be reflected in the SD image and are
# not applied upon system activation.
sdImage.populateFirmwareCommands = lib.mkAfter ''
chmod u+w firmware/config.txt
cat <<EOF >> firmware/config.txt
# Configure bluetooth controller
dtparam=krnbt=on
EOF
chmod u-w firmware/config.txt
'';
})
];
};
packages.x86_64-linux = {
btpi-sd = nixosConfigurations.btpi.config.system.build.sdImage;
};
};
}