diff --git a/README.md b/README.md index 4b4918e..937bf17 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,40 @@ # nixos x13s > [!CAUTION] -> This project is partially maintained. -> It receives kernel updates, until mainline will provide a fully functional experience. +> This project is unmaintained. 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. +## Binary cache + +A binary cache is provided through Cachix so you can avoid re-building the kernel. + +https://app.cachix.org/cache/nixos-x13s + +Ensure you are not overriding the nixpkgs input when consuming this flake, or you may not be able to take advantages of this cache. + +NixOS configuration example: + +```nix + nix.settings = { + substituters = [ + "https://nixos-x13s.cachix.org" + ]; + trusted-public-keys = [ + "nixos-x13s.cachix.org-1:SzroHbidolBD3Sf6UusXp12YZ+a5ynWv0RtYF0btFos=" + ]; + }; +``` + ## Add with a flake ```nix { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - nixos-x13s.url = "git+https://codeberg.org/steveej/nixos-x13s"; + nixos-x13s.url = "git+https://codeberg.org/adamcstephens/nixos-x13s"; }; outputs = @@ -26,7 +46,13 @@ The support for this machine is constantly improving in mainline kernel and upst inputs.nixos-x13s.nixosModules.default { nixos-x13s.enable = true; - nixos-x13s.kernel = "jhovold"; # jhovold is default + nixos-x13s.kernel = "jhovold"; # jhovold is default, but mainline supported + + # install multiple kernels! note this increases eval time for each specialization + specialisation = { + # note that activation of each specialization is required to copy the dtb to the EFI, and thus boot + mainline.configuration.nixos-x13s.kernel = "mainline"; + }; # allow unfree firmware nixpkgs.config.allowUnfree = true; @@ -40,6 +66,25 @@ The support for this machine is constantly improving in mainline kernel and upst } ``` +## Add using not a flake + +Clone the repository: + +``` +git clone https://codeberg.org/adamcstephens/nixos-x13s /etc/nixos/nixos-x13s +``` + +Then reference the module in your `configuration.nix` and use the module as documented in the flake example above: + +```nix + imports = + [ + ./nixos-x13s/module.nix + ]; + nixos-x13s.enable = true; + ... +``` + ## UEFI Update ISO This repository provides a package which can output the USB UEFI Update ISO. This will be updated as Lenovo releases new versions. diff --git a/flake.lock b/flake.lock index 422ac12..3dc68ab 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", "type": "github" }, "original": { @@ -18,30 +18,13 @@ "type": "github" } }, - "linux-jhovold": { - "flake": false, - "locked": { - "lastModified": 1728631036, - "narHash": "sha256-1LnClVjY6WS+IR9eqPFA7gzXm0cio3mY23NXj9cKHHs=", - "owner": "jhovold", - "repo": "linux", - "rev": "6a97bc22fa36010400b91e6d5979741c391112c3", - "type": "github" - }, - "original": { - "owner": "jhovold", - "ref": "wip/sc8280xp-6.12-rc2", - "repo": "linux", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1725432240, - "narHash": "sha256-+yj+xgsfZaErbfYM3T+QvEE2hU7UuE+Jf0fJCJ8uPS0=", + "lastModified": 1722062969, + "narHash": "sha256-QOS0ykELUmPbrrUGmegAUlpmUFznDQeR4q7rFhl8eQg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ad416d066ca1222956472ab7d0555a6946746a80", + "rev": "b73c2221a46c13557b1b3be9c2070cc42cf01eb3", "type": "github" }, "original": { @@ -53,20 +36,19 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1725233747, - "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", + "lastModified": 1719876945, + "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" } }, "root": { "inputs": { "flake-parts": "flake-parts", - "linux-jhovold": "linux-jhovold", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index a0a9d0c..f0ea0ca 100644 --- a/flake.nix +++ b/flake.nix @@ -2,9 +2,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; - - linux-jhovold.url = "github:jhovold/linux/wip/sc8280xp-6.12-rc2"; - linux-jhovold.flake = false; }; outputs = @@ -24,7 +21,7 @@ { pkgs, ... }: { devShells = rec { - default = pkgs.mkShellNoCC { packages = ci.nativeBuildInputs; }; + default = pkgs.mkShellNoCC { packages = [ pkgs.npins ] ++ ci.nativeBuildInputs; }; ci = pkgs.mkShellNoCC { packages = [ @@ -39,16 +36,9 @@ ]; }; }; - - formatter = pkgs.nixfmt-rfc-style; }; - flake.nixosModules.default = import ./module.nix { - inherit dtbName; - - # FIXME: don't hardcode this with the arch - x13sPackages = self.packages.aarch64-linux; - }; + flake.nixosModules.default = import ./module.nix { inherit dtbName; }; flake.nixosConfigurations = { example = inputs.nixpkgs.lib.nixosSystem { @@ -59,7 +49,7 @@ { config, pkgs, ... }: { nixos-x13s.enable = true; - nixos-x13s.kernel = "jhovold"; # jhovold is default + nixos-x13s.kernel = "jhovold"; # jhovold is default, but mainline supported # allow unfree firmware nixpkgs.config.allowUnfree = true; diff --git a/module.nix b/module.nix index 0038fbe..61c066a 100644 --- a/module.nix +++ b/module.nix @@ -1,4 +1,4 @@ -{ dtbName, x13sPackages }: +{ dtbName }: { config, lib, @@ -9,7 +9,12 @@ let cfg = config.nixos-x13s; + x13sPackages = import ./packages/default.nix { inherit lib pkgs; }; + linuxPackages_x13s = + if cfg.kernel == "mainline" then + pkgs.linuxPackages_latest + else pkgs.linuxPackagesFor ( if cfg.kernel == "jhovold" then x13sPackages.linux_jhovold else throw "Unsupported kernel" ); @@ -43,13 +48,21 @@ in kernel = lib.mkOption { type = lib.types.enum [ "jhovold" + "mainline" ]; - description = "Which patched kernel to use. jhovold is the latest RC or release with some x13s specific patches."; + description = "Which patched kernel to use. jhovold is the latest RC or release with some x13s specific patches, and mainline is nixos latest"; default = "jhovold"; }; }; config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = false; + message = "adamcstephens/nixos-x13s is no longer maintained"; + } + ]; + environment.systemPackages = [ pkgs.efibootmgr ]; hardware.enableAllFirmware = true; @@ -78,30 +91,30 @@ in "clk_ignore_unused" "pd_ignore_unused" "arm64.nopauth" - "regulator_ignore_unused" # allows for > 30 sec to load msm, at the potential cost of power + # "regulator_ignore_unused" # allows for > 30 sec to load msm, at the potential cost of power ]; initrd = { kernelModules = [ "nvme" - "phy_qcom_qmp_pcie" - "pcie_qcom" + "phy-qcom-qmp-pcie" + "pcie-qcom" - "i2c_core" - "i2c_hid" - "i2c_hid-of" - "i2c_qcom-geni" + "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" + "phy-qcom-qmp-combo" "gpucc_sc8280xp" "dispcc_sc8280xp" "phy_qcom_edp" - "panel_edp" + "panel-edp" "msm" ]; }; diff --git a/npins/default.nix b/npins/default.nix new file mode 100644 index 0000000..4a7c372 --- /dev/null +++ b/npins/default.nix @@ -0,0 +1,47 @@ +# Generated by npins. Do not modify; will be overwritten regularly +let + data = builtins.fromJSON (builtins.readFile ./sources.json); + version = data.version; + + mkSource = spec: + assert spec ? type; let + path = + if spec.type == "Git" then mkGitSource spec + else if spec.type == "GitRelease" then mkGitSource spec + else if spec.type == "PyPi" then mkPyPiSource spec + else if spec.type == "Channel" then mkChannelSource spec + else builtins.throw "Unknown source type ${spec.type}"; + in + spec // { outPath = path; }; + + mkGitSource = { repository, revision, url ? null, hash, ... }: + assert repository ? type; + # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository + # In the latter case, there we will always be an url to the tarball + if url != null then + (builtins.fetchTarball { + inherit url; + sha256 = hash; # FIXME: check nix version & use SRI hashes + }) + else assert repository.type == "Git"; builtins.fetchGit { + url = repository.url; + rev = revision; + # hash = hash; + }; + + mkPyPiSource = { url, hash, ... }: + builtins.fetchurl { + inherit url; + sha256 = hash; + }; + + mkChannelSource = { url, hash, ... }: + builtins.fetchTarball { + inherit url; + sha256 = hash; + }; +in +if version == 3 then + builtins.mapAttrs (_: mkSource) data.pins +else + throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" diff --git a/npins/sources.json b/npins/sources.json new file mode 100644 index 0000000..6224ea5 --- /dev/null +++ b/npins/sources.json @@ -0,0 +1,17 @@ +{ + "pins": { + "linux-jhovold": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "jhovold", + "repo": "linux" + }, + "branch": "wip/sc8280xp-6.11-rc1", + "revision": "9c6b81022b9c277d65c68e25f4cfd52f33ef8f28", + "url": "https://github.com/jhovold/linux/archive/9c6b81022b9c277d65c68e25f4cfd52f33ef8f28.tar.gz", + "hash": "13c6r67iy8y750f8zpals4l941lshxx3w3ar1ss9dizsqjsghdsr" + } + }, + "version": 3 +} \ No newline at end of file diff --git a/packages/default.nix b/packages/default.nix index 5674e77..f4a84f7 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -1,10 +1,6 @@ -{ - inputs, - lib, - pkgs, - ... -}: +{ lib, pkgs, ... }: let + sources = import ../npins; linux_x13s_pkg = { version, buildLinux, ... }@args: @@ -13,20 +9,15 @@ let // { modDirVersion = version; - structuredExtraConfig = with lib.kernel; { - MODULE_COMPRESS = yes; - MODULE_COMPRESS_ALL = yes; - MODULE_COMPRESS_XZ = yes; - }; - + kernelPatches = (args.kernelPatches or [ ]) ++ [ ]; extraMeta.branch = lib.versions.majorMinor version; } ); in { linux_jhovold = pkgs.callPackage linux_x13s_pkg { - src = inputs.linux-jhovold; - version = "6.12.0-rc2"; + src = sources.linux-jhovold; + version = "6.11.0-rc1"; defconfig = "johan_defconfig"; }; diff --git a/packages/part.nix b/packages/part.nix index 6983c9a..a665de7 100644 --- a/packages/part.nix +++ b/packages/part.nix @@ -1,9 +1,4 @@ -{ - inputs, - lib, - withSystem, - ... -}: +{ lib, withSystem, ... }: { perSystem = { pkgs, ... }: @@ -15,6 +10,6 @@ }; flake.packages.aarch64-linux = withSystem "aarch64-linux" ( - { pkgs, ... }: import ./default.nix { inherit inputs lib pkgs; } + { pkgs, ... }: import ./default.nix { inherit lib pkgs; } ); } diff --git a/update.py b/update.py new file mode 100755 index 0000000..efcb733 --- /dev/null +++ b/update.py @@ -0,0 +1,55 @@ +#!/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}"])