This commit is contained in:
Tristan Ross 2025-10-30 00:28:17 -04:00 committed by GitHub
commit f149f88667
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 184 additions and 80 deletions

View file

@ -1,3 +1,7 @@
# This file is necessary so nix-env -qa does not break,
# when nixos-hardware is used as a channel
{ }
{ pkgs }:
import ./toplevel.nix {
fn = p: pkgs.callPackages "${builtins.toString p}/all.nix";
inherit (pkgs) lib;
}

21
flake.lock generated
View file

@ -1,6 +1,25 @@
{
"nodes": {
"root": {}
"nixpkgs": {
"locked": {
"lastModified": 1757163567,
"narHash": "sha256-uKMQbZmAr6R2tQ/4YpON6ZR00Z0alKeJdAyMHR8n47U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "413fda74348e993e19c01f9bb23f933abcb071bf",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7

View file

@ -1,10 +1,27 @@
{
description = "nixos-hardware";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs =
{ ... }:
{ nixpkgs, ... }:
let
inherit (nixpkgs.lib)
genAttrs
;
eachSystem = genAttrs [
"aarch64-linux"
"x86_64-linux"
"riscv64-linux"
];
in
{
hydraJobs = import ./jobs.nix nixpkgs;
packages = eachSystem (system: import ./. { pkgs = nixpkgs.legacyPackages.${system}; });
nixosModules =
let
deprecated =

6
jobs.nix Normal file
View file

@ -0,0 +1,6 @@
nixpkgs:
import ./toplevel.nix {
fn = p: import "${builtins.toString p}/jobs.nix";
args = nixpkgs;
inherit (nixpkgs) lib;
}

View file

@ -10,85 +10,10 @@ let
mkDefault
mkOption
types
versions
;
# Set the version and hash for the kernel sources
srcVersion =
with config.hardware.microsoft-surface;
if kernelVersion == "longterm" then
"6.12.19"
else if kernelVersion == "stable" then
"6.15.9"
else
abort "Invalid kernel version: ${kernelVersion}";
srcHash =
with config.hardware.microsoft-surface;
if kernelVersion == "longterm" then
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
else if kernelVersion == "stable" then
"sha256-6U86+FSSMC96gZRBRY+AvKCtmRLlpMg8aZ/zxjxSlX0="
else
abort "Invalid kernel version: ${kernelVersion}";
# Set the version and hash for the linux-surface releases
pkgVersion =
with config.hardware.microsoft-surface;
if kernelVersion == "longterm" then
"6.12.7"
else if kernelVersion == "stable" then
"6.15.3"
else
abort "Invalid kernel version: ${kernelVersion}";
pkgHash =
with config.hardware.microsoft-surface;
if kernelVersion == "longterm" then
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
else if kernelVersion == "stable" then
"sha256-ozvYrZDiVtMkdCcVnNEdlF2Kdw4jivW0aMJrDynN3Hk="
else
abort "Invalid kernel version: ${kernelVersion}";
# Fetch the linux-surface package
repos =
pkgs.callPackage
(
{
fetchFromGitHub,
rev,
hash,
}:
{
linux-surface = fetchFromGitHub {
owner = "linux-surface";
repo = "linux-surface";
rev = rev;
hash = hash;
};
}
)
{
hash = pkgHash;
rev = "arch-${pkgVersion}-1";
};
# Fetch and build the kernel package
inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; })
linuxPackage
surfacePatches
;
kernelPatches = surfacePatches {
version = pkgVersion;
patchFn = ./kernel/${versions.majorMinor pkgVersion}/patches.nix;
patchSrc = (repos.linux-surface + "/patches/${versions.majorMinor pkgVersion}");
};
kernelPackages = linuxPackage {
inherit kernelPatches;
version = srcVersion;
sha256 = srcHash;
ignoreConfigErrors = true;
kernelPackages = pkgs.callPackage ../pkgs/kernel {
inherit (config.hardware.microsoft-surface) kernelVersion;
};
in

View file

@ -0,0 +1,12 @@
{
lib,
stdenv,
callPackages,
}:
let
pkgs = callPackages ./. { };
in
lib.optionalAttrs (stdenv.hostPlatform.isx86_64) {
kernel-stable = pkgs.kernel-stable.kernel;
kernel-longterm = pkgs.kernel-longterm.kernel;
}

View file

@ -0,0 +1,10 @@
{ callPackage }:
{
kernel-stable = callPackage ./kernel {
kernelVersion = "stable";
};
kernel-longterm = callPackage ./kernel {
kernelVersion = "longterm";
};
}

View file

@ -0,0 +1,8 @@
nixpkgs:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux.callPackages ./. { };
in
{
kernel-stable.x86_64-linux = nixpkgs.lib.hydraJob pkgs.kernel-stable.kernel;
kernel-longterm.x86_64-linux = nixpkgs.lib.hydraJob pkgs.kernel-longterm.kernel;
}

View file

@ -0,0 +1,83 @@
{
lib,
kernelVersion,
callPackage,
}:
let
inherit (lib) versions;
# Set the version and hash for the kernel sources
srcVersion =
if kernelVersion == "longterm" then
"6.12.19"
else if kernelVersion == "stable" then
"6.15.9"
else
abort "Invalid kernel version: ${kernelVersion}";
srcHash =
if kernelVersion == "longterm" then
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
else if kernelVersion == "stable" then
"sha256-6U86+FSSMC96gZRBRY+AvKCtmRLlpMg8aZ/zxjxSlX0="
else
abort "Invalid kernel version: ${kernelVersion}";
# Set the version and hash for the linux-surface releases
pkgVersion =
if kernelVersion == "longterm" then
"6.12.7"
else if kernelVersion == "stable" then
"6.15.3"
else
abort "Invalid kernel version: ${kernelVersion}";
pkgHash =
if kernelVersion == "longterm" then
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
else if kernelVersion == "stable" then
"sha256-ozvYrZDiVtMkdCcVnNEdlF2Kdw4jivW0aMJrDynN3Hk="
else
abort "Invalid kernel version: ${kernelVersion}";
# Fetch the linux-surface package
repos =
callPackage
(
{
fetchFromGitHub,
rev,
hash,
}:
{
linux-surface = fetchFromGitHub {
owner = "linux-surface";
repo = "linux-surface";
rev = rev;
hash = hash;
};
}
)
{
hash = pkgHash;
rev = "arch-${pkgVersion}-1";
};
# Fetch and build the kernel package
inherit (callPackage ../../common/kernel/linux-package.nix { inherit repos; })
linuxPackage
surfacePatches
;
kernelPatches = surfacePatches {
version = pkgVersion;
patchFn = ../../common/kernel/${versions.majorMinor pkgVersion}/patches.nix;
patchSrc = (repos.linux-surface + "/patches/${versions.majorMinor pkgVersion}");
};
in
linuxPackage {
inherit kernelPatches;
version = srcVersion;
sha256 = srcHash;
ignoreConfigErrors = true;
}

20
toplevel.nix Normal file
View file

@ -0,0 +1,20 @@
{
lib,
fn ? p: import p,
args ? { },
}:
let
pkgs = builtins.mapAttrs (_name: p: fn p args) {
microsoft-surface = ./microsoft/surface/pkgs;
};
in
lib.foldAttrs (item: acc: item // acc) { } (
lib.flatten (
lib.attrValues (
lib.mapAttrs (
toplevelName: jobs:
lib.listToAttrs (lib.mapAttrsToList (name: lib.nameValuePair "${toplevelName}/${name}") jobs)
) pkgs
)
)
)