Compare commits

..

No commits in common. "main" and "week20" have entirely different histories.
main ... week20

12 changed files with 166 additions and 196 deletions

View file

@ -11,7 +11,7 @@ steps:
- name: build - name: build
image: bash image: bash
commands: commands:
- tini -s nix -- develop .#ci -c just -- build - nix develop .#ci -c just -- build
- name: upload - name: upload
image: bash image: bash

View file

@ -1,8 +1,5 @@
# nixos x13s # nixos x13s
> [!CAUTION]
> This project is unmaintained.
This repository aims to provide easy, shared, support for Lenovo X13s on Linux. This repository aims to provide easy, shared, support for Lenovo X13s on Linux.
The support for this machine is constantly improving in mainline kernel and upstream packages. Eventually the goal is that this repository is no longer necessary. The support for this machine is constantly improving in mainline kernel and upstream packages. Eventually the goal is that this repository is no longer necessary.

View file

@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1719994518, "lastModified": 1714641030,
"narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1722062969, "lastModified": 1714906307,
"narHash": "sha256-QOS0ykELUmPbrrUGmegAUlpmUFznDQeR4q7rFhl8eQg=", "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b73c2221a46c13557b1b3be9c2070cc42cf01eb3", "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -36,14 +36,14 @@
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1719876945, "lastModified": 1714640452,
"narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=",
"type": "tarball", "type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
} }
}, },
"root": { "root": {

View file

@ -28,14 +28,13 @@
pkgs.cachix pkgs.cachix
pkgs.jq pkgs.jq
pkgs.just pkgs.just
(pkgs.python3.withPackages (py: [
py.PyGithub
py.packaging
]))
pkgs.pyright
]; ];
}; };
}; };
packages = {
iso = self.nixosConfigurations.iso.config.system.build.isoImage;
};
}; };
flake.nixosModules.default = import ./module.nix { inherit dtbName; }; flake.nixosModules.default = import ./module.nix { inherit dtbName; };
@ -45,19 +44,21 @@
system = "aarch64-linux"; system = "aarch64-linux";
modules = [ modules = [
self.nixosModules.default self.nixosModules.default
( {
{ config, pkgs, ... }: nixos-x13s.enable = true;
{ nixos-x13s.kernel = "jhovold"; # jhovold is default, but mainline supported
nixos-x13s.enable = true;
nixos-x13s.kernel = "jhovold"; # jhovold is default, but mainline supported
# allow unfree firmware # install multiple kernels! note this increases eval time for each specialization
nixpkgs.config.allowUnfree = true; # specialisation = {
# mainline.configuration.nixos-x13s.kernel = "mainline";
# };
# define your fileSystems # allow unfree firmware
fileSystems."/".device = "/dev/notreal"; nixpkgs.config.allowUnfree = true;
}
) # define your fileSystems
fileSystems."/".device = "/dev/notreal";
}
]; ];
}; };
@ -67,45 +68,12 @@
self.nixosModules.default self.nixosModules.default
( (
{ { modulesPath, config, ... }:
modulesPath,
config,
lib,
pkgs,
...
}:
let let
image = import "${inputs.nixpkgs}/nixos/lib/make-disk-image.nix" { dtb = "${config.boot.kernelPackages.kernel}/dtbs/qcom/${dtbName}";
inherit config lib pkgs;
name = "nixos-x13s-bootstrap";
diskSize = "auto";
format = "raw";
partitionTableType = "efi";
copyChannel = false;
};
in in
{ {
hardware.deviceTree = { imports = [ "${toString modulesPath}/installer/cd-dvd/iso-image.nix" ];
enable = true;
name = "qcom/${dtbName}";
};
system.build.bootstrap-image = image;
boot = {
initrd = {
systemd.enable = true;
systemd.emergencyAccess = true;
};
loader = {
grub.enable = false;
systemd-boot.enable = true;
systemd-boot.graceful = true;
};
};
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@ -114,16 +82,16 @@
bluetoothMac = "02:68:b3:29:da:98"; bluetoothMac = "02:68:b3:29:da:98";
}; };
fileSystems = { isoImage = {
"/boot" = { makeEfiBootable = true;
fsType = "vfat"; makeUsbBootable = true;
device = "/dev/disk/by-label/ESP";
}; contents = [
"/" = { {
device = "/dev/disk/by-label/nixos"; source = dtb;
fsType = "ext4"; target = "/x13s.dtb";
autoResize = true; }
}; ];
}; };
} }
) )

View file

@ -2,7 +2,6 @@
{ {
config, config,
lib, lib,
options,
pkgs, pkgs,
... ...
}: }:
@ -19,22 +18,7 @@ let
if cfg.kernel == "jhovold" then x13sPackages.linux_jhovold else throw "Unsupported kernel" if cfg.kernel == "jhovold" then x13sPackages.linux_jhovold else throw "Unsupported kernel"
); );
dtb = "${linuxPackages_x13s.kernel}/dtbs/qcom/${dtbName}"; dtb = "${linuxPackages_x13s.kernel}/dtbs/qcom/${dtbName}";
dtbEfiPath = "dtbs/x13s.dtb"; dtbEfiPath = "dtbs/${cfg.kernel}/${config.boot.kernelPackages.kernel.version}/${dtbName}";
modulesClosure = pkgs.makeModulesClosure {
rootModules = config.boot.initrd.availableKernelModules ++ config.boot.initrd.kernelModules;
kernel = config.system.modulesTree;
firmware = config.hardware.firmware;
allowMissing = false;
};
modulesWithExtra = pkgs.symlinkJoin {
name = "modules-closure";
paths = [
modulesClosure
x13sPackages.graphics-firmware
];
};
in in
{ {
options.nixos-x13s = { options.nixos-x13s = {
@ -56,24 +40,21 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [
{
assertion = false;
message = "adamcstephens/nixos-x13s is no longer maintained";
}
];
environment.systemPackages = [ pkgs.efibootmgr ]; environment.systemPackages = [ pkgs.efibootmgr ];
hardware.enableAllFirmware = true; hardware.enableAllFirmware = true;
hardware.firmware = lib.mkBefore [ x13sPackages.graphics-firmware ]; hardware.firmware = [ x13sPackages."x13s/extra-firmware" ];
systemd.services.pd-mapper = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${lib.getExe x13sPackages.pd-mapper}";
Restart = "always";
};
};
boot = { boot = {
initrd.systemd.enable = true;
initrd.systemd.contents = {
"/lib".source = lib.mkForce "${modulesWithExtra}/lib";
};
loader.efi.canTouchEfiVariables = true; loader.efi.canTouchEfiVariables = true;
loader.systemd-boot.enable = lib.mkDefault true; loader.systemd-boot.enable = lib.mkDefault true;
loader.systemd-boot.extraFiles = { loader.systemd-boot.extraFiles = {
@ -90,8 +71,11 @@ in
"efi=noruntime" "efi=noruntime"
"clk_ignore_unused" "clk_ignore_unused"
"pd_ignore_unused" "pd_ignore_unused"
"regulator_ignore_unused"
"arm64.nopauth" "arm64.nopauth"
# "regulator_ignore_unused" # allows for > 30 sec to load msm, at the potential cost of power
# blacklist graphics in initrd so the firmware can load from disk
"rd.driver.blacklist=msm"
]; ];
initrd = { initrd = {
@ -115,19 +99,11 @@ in
"dispcc_sc8280xp" "dispcc_sc8280xp"
"phy_qcom_edp" "phy_qcom_edp"
"panel-edp" "panel-edp"
"msm" # "msm"
]; ];
}; };
}; };
# https://github.com/jhovold/linux/wiki/X13s#modem
networking.networkmanager.fccUnlockScripts = [
{
id = "105b:e0c3";
path = "${pkgs.modemmanager}/share/ModemManager/fcc-unlock.available.d/105b";
}
];
nixpkgs.overlays = [ nixpkgs.overlays = [
(_: super: { (_: super: {
# don't try and use zfs # don't try and use zfs
@ -143,12 +119,6 @@ in
# default is performance # default is performance
powerManagement.cpuFreqGovernor = "ondemand"; powerManagement.cpuFreqGovernor = "ondemand";
# https://github.com/jhovold/linux/wiki/X13s#camera
services.udev.extraRules = ''
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="linux,cma", GROUP="video", MODE="0660"
ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system", GROUP="video", MODE="0660"
'';
systemd.services.bluetooth-x13s-mac = { systemd.services.bluetooth-x13s-mac = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
before = [ "bluetooth.service" ]; before = [ "bluetooth.service" ];

View file

@ -7,10 +7,10 @@
"owner": "jhovold", "owner": "jhovold",
"repo": "linux" "repo": "linux"
}, },
"branch": "wip/sc8280xp-6.11-rc1", "branch": "wip/sc8280xp-6.9",
"revision": "9c6b81022b9c277d65c68e25f4cfd52f33ef8f28", "revision": "357c0f0c7ad2d7d95a3200b6cfd7bef43299de04",
"url": "https://github.com/jhovold/linux/archive/9c6b81022b9c277d65c68e25f4cfd52f33ef8f28.tar.gz", "url": "https://github.com/jhovold/linux/archive/357c0f0c7ad2d7d95a3200b6cfd7bef43299de04.tar.gz",
"hash": "13c6r67iy8y750f8zpals4l941lshxx3w3ar1ss9dizsqjsghdsr" "hash": "1n6cv149rafgk7wkb8cjixy6car4zq0dhhz39b7gjnzr599mqwxn"
} }
}, },
"version": 3 "version": 3

View file

@ -14,23 +14,17 @@ let
} }
); );
in in
{ rec {
linux_jhovold = pkgs.callPackage linux_x13s_pkg { linux_jhovold = linux_jhovold_6_9;
linux_jhovold_6_9 = pkgs.callPackage linux_x13s_pkg {
src = sources.linux-jhovold; src = sources.linux-jhovold;
version = "6.11.0-rc1"; version = "6.9.0";
defconfig = "johan_defconfig"; defconfig = "johan_defconfig";
}; };
graphics-firmware = pd-mapper = pkgs.callPackage ./pd-mapper { inherit qrtr; };
let qrtr = pkgs.callPackage ./qrtr { };
gpu-src = pkgs.fetchurl {
url = "https://download.lenovo.com/pccbbs/mobiles/n3hdr20w.exe"; "x13s/extra-firmware" = pkgs.callPackage ./extra-firmware.nix { };
hash = "sha256-Jwyl9uKOnjpwfHd+VaGHjYs9x8cUuRdFCERuXqaJwEY=";
};
in
pkgs.runCommand "graphics-firmware" { } ''
mkdir -vp "$out/lib/firmware/qcom/sc8280xp/LENOVO/21BX"
${lib.getExe pkgs.innoextract} ${gpu-src}
cp -v code\$GetExtractPath\$/*/*.mbn "$out/lib/firmware/qcom/sc8280xp/LENOVO/21BX/"
'';
} }

View file

@ -0,0 +1,21 @@
{ stdenvNoCC, fetchFromGitHub }:
stdenvNoCC.mkDerivation {
pname = "x13s-extra-firmware";
version = "1.0.0";
src = fetchFromGitHub {
owner = "ironrobin";
repo = "x13s-alarm";
rev = "efa51c3b519f75b3983aef67855b1561d9828771";
sha256 = "sha256-weETbWXz9aL2pDQDKk7fkb1ecQH0qrhUYDs2E5EiJcI=";
};
dontFixup = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/lib/firmware/qcom/sc8280xp/LENOVO/21BX
cp x13s-firmware/qcvss8280.mbn $out/lib/firmware/qcom/sc8280xp/LENOVO/21BX/
'';
}

View file

@ -0,0 +1,36 @@
{
stdenv,
lib,
fetchFromGitHub,
qrtr,
xz,
}:
stdenv.mkDerivation {
pname = "pd-mapper";
version = "unstable-2023-09-01";
buildInputs = [
qrtr
xz
];
src = fetchFromGitHub {
owner = "andersson";
repo = "pd-mapper";
rev = "10997ba7c43a3787a40b6b1b161408033e716374";
hash = "sha256-qGrYNoPCxtdpTdbkSmB39+6/pSXml96Aul8b9opF9Lc=";
};
patches = [ ./pd-mapper-firmware-path.diff ];
installFlags = [ "prefix=$(out)" ];
meta = with lib; {
description = "Qualcomm PD mapper";
homepage = "https://github.com/andersson/pd-mapper";
license = licenses.bsd3;
mainProgram = "pd-mapper";
platforms = platforms.aarch64;
};
}

View file

@ -0,0 +1,13 @@
diff --git a/pd-mapper.c b/pd-mapper.c
index 65c4b80..669d9a0 100644
--- a/pd-mapper.c
+++ b/pd-mapper.c
@@ -194,7 +194,7 @@ static int pd_load_map(const char *file)
}
#ifndef ANDROID
-#define FIRMWARE_BASE "/lib/firmware/"
+#define FIRMWARE_BASE "/run/current-system/firmware/"
#else
#define FIRMWARE_BASE "/vendor/firmware/"
#endif

26
packages/qrtr/default.nix Normal file
View file

@ -0,0 +1,26 @@
{
stdenv,
lib,
fetchFromGitHub,
}:
stdenv.mkDerivation {
pname = "qrtr";
version = "unstable-2023-01-17";
src = fetchFromGitHub {
owner = "andersson";
repo = "qrtr";
rev = "d0d471c96e7d112fac6f48bd11f9e8ce209c04d2";
hash = "sha256-KF0gCBRw3BDJdK1s+dYhHkokVTHwRFO58ho0IwHPehc=";
};
installFlags = [ "prefix=$(out)" ];
meta = with lib; {
description = "QMI IDL compiler";
homepage = "https://github.com/andersson/qrtr";
license = licenses.bsd3;
platforms = platforms.aarch64;
};
}

View file

@ -1,55 +0,0 @@
#!/usr/bin/env python3
from github import Github
import sys
import re
from packaging.version import Version
from subprocess import run
latest_version: str = "0"
latest_branch: str = ""
previous_version: str = ""
with Github() as gh:
for branch in gh.get_user("jhovold").get_repo("linux").get_branches():
v = re.match("wip/sc8280xp-((v?6.[0-9]+)(-rc[0-9]+)?)", branch.name)
if v != None and Version(v.group(1)) > Version(latest_version):
# add .0 to version
latest_version = f"{v.group(2)}.0{v.group(3) or ''}"
latest_branch = v.group(0)
print("branch: " + latest_branch)
print("latest: " + latest_version)
with open("packages/default.nix", "r") as f:
lines = f.readlines()
for line in lines:
v = re.match(r'^\s*version = "(6[.0-9-rc]+)";.*$', line)
if v != None:
previous_version = v.group(1)
print("previous: " + previous_version)
if previous_version == latest_version:
print("No update found, exiting.")
sys.exit(1)
with open("packages/default.nix", "w") as f:
for line in lines:
f.write(
re.sub(
r'^(\s*version = ")6[.0-9-rc]+(";.*$)',
rf"\g<1>{latest_version}\2",
line,
)
)
run(
f"npins add --name linux-jhovold github --branch {latest_branch} jhovold linux".split(
" "
)
)
run("git add npins/ packages/default.nix".split(" "))
run(["git", "commit", "-m", f"jhovold: {previous_version} -> {latest_version}"])