2024-05-12 22:28:24 +02:00
|
|
|
{ dtbName }:
|
2024-01-22 18:47:25 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.nixos-x13s;
|
|
|
|
|
|
|
|
x13sPackages = import ./packages/default.nix { inherit lib pkgs; };
|
|
|
|
|
2024-02-20 14:55:19 +01:00
|
|
|
linuxPackages_x13s =
|
|
|
|
if cfg.kernel == "mainline" then
|
2024-02-20 14:43:19 +01:00
|
|
|
pkgs.linuxPackages_latest
|
2024-02-20 14:55:19 +01:00
|
|
|
else
|
|
|
|
pkgs.linuxPackagesFor (
|
2024-05-12 22:28:24 +02:00
|
|
|
if cfg.kernel == "jhovold" then x13sPackages.linux_jhovold else throw "Unsupported kernel"
|
2024-02-20 14:55:19 +01:00
|
|
|
);
|
2024-01-22 18:47:25 +01:00
|
|
|
dtb = "${linuxPackages_x13s.kernel}/dtbs/qcom/${dtbName}";
|
2024-05-17 04:25:10 +02:00
|
|
|
dtbEfiPath = "dtbs/x13s.dtb";
|
2024-01-22 18:47:25 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.nixos-x13s = {
|
|
|
|
enable = lib.mkEnableOption "x13s hardware support";
|
|
|
|
|
|
|
|
bluetoothMac = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-05-14 21:33:45 +02:00
|
|
|
description = "Bluetooth MAC address to set on boot";
|
2024-01-22 18:47:25 +01:00
|
|
|
};
|
2024-02-20 14:43:19 +01:00
|
|
|
|
|
|
|
kernel = lib.mkOption {
|
|
|
|
type = lib.types.enum [
|
|
|
|
"jhovold"
|
|
|
|
"mainline"
|
|
|
|
];
|
2024-05-14 21:33:45 +02:00
|
|
|
description = "Which patched kernel to use. jhovold is the latest RC or release with some x13s specific patches, and mainline is nixos latest";
|
2024-02-20 14:43:19 +01:00
|
|
|
default = "jhovold";
|
|
|
|
};
|
2024-01-22 18:47:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.efibootmgr ];
|
|
|
|
|
|
|
|
hardware.enableAllFirmware = true;
|
|
|
|
hardware.firmware = [ x13sPackages."x13s/extra-firmware" ];
|
|
|
|
|
|
|
|
systemd.services.pd-mapper = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${lib.getExe x13sPackages.pd-mapper}";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
loader.efi.canTouchEfiVariables = true;
|
|
|
|
loader.systemd-boot.enable = lib.mkDefault true;
|
|
|
|
loader.systemd-boot.extraFiles = {
|
2024-03-07 17:19:25 +01:00
|
|
|
"${dtbEfiPath}" = dtb;
|
2024-01-22 18:47:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
kernelPackages = linuxPackages_x13s;
|
|
|
|
|
|
|
|
kernelParams = [
|
2024-01-23 22:05:10 +01:00
|
|
|
# needed to boot
|
2024-03-07 17:19:25 +01:00
|
|
|
"dtb=${dtbEfiPath}"
|
2024-01-23 22:05:10 +01:00
|
|
|
|
2024-01-22 18:47:25 +01:00
|
|
|
# jhovold recommended
|
|
|
|
"efi=noruntime"
|
|
|
|
"clk_ignore_unused"
|
|
|
|
"pd_ignore_unused"
|
2024-02-14 15:49:08 +01:00
|
|
|
"regulator_ignore_unused"
|
2024-01-22 18:47:25 +01:00
|
|
|
"arm64.nopauth"
|
|
|
|
|
|
|
|
# blacklist graphics in initrd so the firmware can load from disk
|
|
|
|
"rd.driver.blacklist=msm"
|
|
|
|
];
|
|
|
|
|
|
|
|
initrd = {
|
|
|
|
kernelModules = [
|
|
|
|
"nvme"
|
|
|
|
"phy-qcom-qmp-pcie"
|
|
|
|
"pcie-qcom"
|
|
|
|
|
|
|
|
"i2c-core"
|
|
|
|
"i2c-hid"
|
|
|
|
"i2c-hid-of"
|
|
|
|
"i2c-qcom-geni"
|
|
|
|
|
|
|
|
"leds_qcom_lpg"
|
|
|
|
"pwm_bl"
|
|
|
|
"qrtr"
|
|
|
|
"pmic_glink_altmode"
|
|
|
|
"gpio_sbu_mux"
|
|
|
|
"phy-qcom-qmp-combo"
|
|
|
|
"gpucc_sc8280xp"
|
|
|
|
"dispcc_sc8280xp"
|
|
|
|
"phy_qcom_edp"
|
|
|
|
"panel-edp"
|
|
|
|
# "msm"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-25 03:17:14 +01:00
|
|
|
nixpkgs.overlays = [
|
2024-02-05 15:09:25 +01:00
|
|
|
(_: super: {
|
2024-01-25 03:17:14 +01:00
|
|
|
# don't try and use zfs
|
2024-03-07 17:19:25 +01:00
|
|
|
zfs = super.zfs.overrideAttrs (_: {
|
|
|
|
meta.platforms = [ ];
|
|
|
|
});
|
2024-01-25 03:17:14 +01:00
|
|
|
|
|
|
|
# allow missing modules
|
|
|
|
makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2024-01-22 18:47:25 +01:00
|
|
|
# default is performance
|
|
|
|
powerManagement.cpuFreqGovernor = "ondemand";
|
|
|
|
|
2024-05-14 21:33:45 +02:00
|
|
|
systemd.services.bluetooth-x13s-mac = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
before = [ "bluetooth.service" ];
|
|
|
|
requiredBy = [ "bluetooth.service" ];
|
|
|
|
|
2024-01-22 18:47:25 +01:00
|
|
|
serviceConfig = {
|
2024-05-14 21:33:45 +02:00
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
2024-05-15 06:03:41 +02:00
|
|
|
ExecStart = "${pkgs.util-linux}/bin/script -q -c '${pkgs.bluez}/bin/btmgmt --index 0 public-addr ${cfg.bluetoothMac}'";
|
2024-01-22 18:47:25 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|