Skip to content

Commit 350fd66

Browse files
Add hydra jobs & flake packages
1 parent 11b2a10 commit 350fd66

File tree

10 files changed

+184
-80
lines changed

10 files changed

+184
-80
lines changed

default.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# This file is necessary so nix-env -qa does not break,
22
# when nixos-hardware is used as a channel
3-
{ }
3+
{ pkgs }:
4+
import ./toplevel.nix {
5+
fn = p: pkgs.callPackages "${builtins.toString p}/all.nix";
6+
inherit (pkgs) lib;
7+
}

flake.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
{
22
description = "nixos-hardware";
33

4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
5+
46
outputs =
5-
{ ... }:
7+
{ nixpkgs, ... }:
8+
let
9+
inherit (nixpkgs.lib)
10+
genAttrs
11+
;
12+
13+
eachSystem = genAttrs [
14+
"aarch64-linux"
15+
"x86_64-linux"
16+
"riscv64-linux"
17+
];
18+
in
619
{
720

21+
hydraJobs = import ./jobs.nix nixpkgs;
22+
23+
packages = eachSystem (system: import ./. { pkgs = nixpkgs.legacyPackages.${system}; });
24+
825
nixosModules =
926
let
1027
deprecated =

jobs.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
nixpkgs:
2+
import ./toplevel.nix {
3+
fn = p: import "${builtins.toString p}/jobs.nix";
4+
args = nixpkgs;
5+
inherit (nixpkgs) lib;
6+
}

microsoft/surface/common/default.nix

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,10 @@ let
1010
mkDefault
1111
mkOption
1212
types
13-
versions
1413
;
1514

16-
# Set the version and hash for the kernel sources
17-
srcVersion =
18-
with config.hardware.microsoft-surface;
19-
if kernelVersion == "longterm" then
20-
"6.12.19"
21-
else if kernelVersion == "stable" then
22-
"6.15.9"
23-
else
24-
abort "Invalid kernel version: ${kernelVersion}";
25-
26-
srcHash =
27-
with config.hardware.microsoft-surface;
28-
if kernelVersion == "longterm" then
29-
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
30-
else if kernelVersion == "stable" then
31-
"sha256-6U86+FSSMC96gZRBRY+AvKCtmRLlpMg8aZ/zxjxSlX0="
32-
else
33-
abort "Invalid kernel version: ${kernelVersion}";
34-
35-
# Set the version and hash for the linux-surface releases
36-
pkgVersion =
37-
with config.hardware.microsoft-surface;
38-
if kernelVersion == "longterm" then
39-
"6.12.7"
40-
else if kernelVersion == "stable" then
41-
"6.15.3"
42-
else
43-
abort "Invalid kernel version: ${kernelVersion}";
44-
45-
pkgHash =
46-
with config.hardware.microsoft-surface;
47-
if kernelVersion == "longterm" then
48-
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
49-
else if kernelVersion == "stable" then
50-
"sha256-ozvYrZDiVtMkdCcVnNEdlF2Kdw4jivW0aMJrDynN3Hk="
51-
else
52-
abort "Invalid kernel version: ${kernelVersion}";
53-
54-
# Fetch the linux-surface package
55-
repos =
56-
pkgs.callPackage
57-
(
58-
{
59-
fetchFromGitHub,
60-
rev,
61-
hash,
62-
}:
63-
{
64-
linux-surface = fetchFromGitHub {
65-
owner = "linux-surface";
66-
repo = "linux-surface";
67-
rev = rev;
68-
hash = hash;
69-
};
70-
}
71-
)
72-
{
73-
hash = pkgHash;
74-
rev = "arch-${pkgVersion}-1";
75-
};
76-
77-
# Fetch and build the kernel package
78-
inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; })
79-
linuxPackage
80-
surfacePatches
81-
;
82-
kernelPatches = surfacePatches {
83-
version = pkgVersion;
84-
patchFn = ./kernel/${versions.majorMinor pkgVersion}/patches.nix;
85-
patchSrc = (repos.linux-surface + "/patches/${versions.majorMinor pkgVersion}");
86-
};
87-
kernelPackages = linuxPackage {
88-
inherit kernelPatches;
89-
version = srcVersion;
90-
sha256 = srcHash;
91-
ignoreConfigErrors = true;
15+
kernelPackages = pkgs.callPackage ../pkgs/kernel {
16+
inherit (config.hardware.microsoft-surface) kernelVersion;
9217
};
9318

9419
in

microsoft/surface/pkgs/all.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
lib,
3+
stdenv,
4+
callPackages,
5+
}:
6+
let
7+
pkgs = callPackages ./. { };
8+
in
9+
lib.optionalAttrs (stdenv.hostPlatform.isx86_64) {
10+
kernel-stable = pkgs.kernel-stable.kernel;
11+
kernel-longterm = pkgs.kernel-longterm.kernel;
12+
}

microsoft/surface/pkgs/default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{ callPackage }:
2+
{
3+
kernel-stable = callPackage ./kernel {
4+
kernelVersion = "stable";
5+
};
6+
7+
kernel-longterm = callPackage ./kernel {
8+
kernelVersion = "longterm";
9+
};
10+
}

microsoft/surface/pkgs/jobs.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
nixpkgs:
2+
let
3+
pkgs = nixpkgs.legacyPackages.x86_64-linux.callPackages ./. { };
4+
in
5+
{
6+
kernel-stable.x86_64-linux = nixpkgs.lib.hydraJob pkgs.kernel-stable.kernel;
7+
kernel-longterm.x86_64-linux = nixpkgs.lib.hydraJob pkgs.kernel-longterm.kernel;
8+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
lib,
3+
kernelVersion,
4+
callPackage,
5+
}:
6+
let
7+
inherit (lib) versions;
8+
9+
# Set the version and hash for the kernel sources
10+
srcVersion =
11+
if kernelVersion == "longterm" then
12+
"6.12.19"
13+
else if kernelVersion == "stable" then
14+
"6.15.9"
15+
else
16+
abort "Invalid kernel version: ${kernelVersion}";
17+
18+
srcHash =
19+
if kernelVersion == "longterm" then
20+
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
21+
else if kernelVersion == "stable" then
22+
"sha256-6U86+FSSMC96gZRBRY+AvKCtmRLlpMg8aZ/zxjxSlX0="
23+
else
24+
abort "Invalid kernel version: ${kernelVersion}";
25+
26+
# Set the version and hash for the linux-surface releases
27+
pkgVersion =
28+
if kernelVersion == "longterm" then
29+
"6.12.7"
30+
else if kernelVersion == "stable" then
31+
"6.15.3"
32+
else
33+
abort "Invalid kernel version: ${kernelVersion}";
34+
35+
pkgHash =
36+
if kernelVersion == "longterm" then
37+
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
38+
else if kernelVersion == "stable" then
39+
"sha256-ozvYrZDiVtMkdCcVnNEdlF2Kdw4jivW0aMJrDynN3Hk="
40+
else
41+
abort "Invalid kernel version: ${kernelVersion}";
42+
43+
# Fetch the linux-surface package
44+
repos =
45+
callPackage
46+
(
47+
{
48+
fetchFromGitHub,
49+
rev,
50+
hash,
51+
}:
52+
{
53+
linux-surface = fetchFromGitHub {
54+
owner = "linux-surface";
55+
repo = "linux-surface";
56+
rev = rev;
57+
hash = hash;
58+
};
59+
}
60+
)
61+
{
62+
hash = pkgHash;
63+
rev = "arch-${pkgVersion}-1";
64+
};
65+
66+
# Fetch and build the kernel package
67+
inherit (callPackage ../../common/kernel/linux-package.nix { inherit repos; })
68+
linuxPackage
69+
surfacePatches
70+
;
71+
72+
kernelPatches = surfacePatches {
73+
version = pkgVersion;
74+
patchFn = ../../common/kernel/${versions.majorMinor pkgVersion}/patches.nix;
75+
patchSrc = (repos.linux-surface + "/patches/${versions.majorMinor pkgVersion}");
76+
};
77+
in
78+
linuxPackage {
79+
inherit kernelPatches;
80+
version = srcVersion;
81+
sha256 = srcHash;
82+
ignoreConfigErrors = true;
83+
}

toplevel.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
lib,
3+
fn ? p: import p,
4+
args ? { },
5+
}:
6+
let
7+
pkgs = builtins.mapAttrs (_name: p: fn p args) {
8+
microsoft-surface = ./microsoft/surface/pkgs;
9+
};
10+
in
11+
lib.foldAttrs (item: acc: item // acc) { } (
12+
lib.flatten (
13+
lib.attrValues (
14+
lib.mapAttrs (
15+
toplevelName: jobs:
16+
lib.listToAttrs (lib.mapAttrsToList (name: lib.nameValuePair "${toplevelName}/${name}") jobs)
17+
) pkgs
18+
)
19+
)
20+
)

0 commit comments

Comments
 (0)