Skip to content

Commit 43ffe9a

Browse files
authored
Merge pull request #1580 from NixOS/private-flake
Refactor tests to load flake inputs with flake-compat
2 parents e07b161 + 3beac24 commit 43ffe9a

File tree

28 files changed

+654
-317
lines changed

28 files changed

+654
-317
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v5
1313
- uses: cachix/install-nix-action@v31
14-
- run: cd tests && nix fmt .. -- --fail-on-change
14+
- run: nix build .#checks.x86_64-linux.formatting
1515
tests:
1616
needs: nixfmt
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v5
2020
- uses: cachix/install-nix-action@v31
21-
- run: nix run ./tests#run .
21+
- run: nix run .#run-tests

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Link the profile in the table in README.md and in flake.nix.
4242

4343
## 3. Testing
4444

45-
Run `nix run ./tests#run .` to evaluate all hardware profiles.
45+
Run `nix run .#run-tests` to evaluate all hardware profiles.
4646
Because profiles can only be tested with the appropriate hardware, quality
4747
assurance is up to *you*.
4848

apple/imac/14-2/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"bcma"
3030
];
3131
kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.0") pkgs.linuxPackages_latest;
32-
extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
3332
};
3433

3534
hardware = {

apple/macbook-air/6/default.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
{
44
imports = [ ../. ];
55

6-
boot.kernelModules = [ "wl" ];
7-
boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
86
boot.blacklistedKernelModules = [ "bcma" ];
97

108
boot = {

apple/macbook-pro/11-1/default.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@
66
../../../common/cpu/intel/haswell
77
];
88

9-
# broadcom-wl
109
hardware.enableRedistributableFirmware = lib.mkDefault true;
11-
# nixos-generate-config doesn't detect this automatically.
12-
boot.extraModulePackages = with config.boot.kernelPackages; [ broadcom_sta ];
13-
boot.kernelModules = [ "wl" ];
1410
}

dell/inspiron/3442/default.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,4 @@
1212
fwupd.enable = lib.mkDefault true;
1313
thermald.enable = lib.mkDefault true;
1414
};
15-
16-
boot = {
17-
# needs to be explicitly loaded or else bluetooth/wifi won't work.
18-
kernelModules = [ "wl" ];
19-
extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
20-
};
2115
}

dell/xps/13-9343/default.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313
};
1414

1515
boot = {
16-
# needs to be explicitly loaded or else bluetooth/wifi won't work
1716
kernelModules = [
1817
"kvm-intel"
19-
"wl"
2018
];
21-
extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
2219
};
2320
}

flake.nix

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,39 @@
22
description = "nixos-hardware";
33

44
outputs =
5-
{ ... }:
5+
{ self, ... }:
6+
let
7+
# Import private inputs (for development)
8+
privateInputs =
9+
(import ./tests/flake-compat.nix {
10+
src = ./tests;
11+
}).defaultNix;
12+
13+
systems = [
14+
"aarch64-linux"
15+
"riscv64-linux"
16+
"x86_64-linux"
17+
];
18+
19+
formatSystems = [
20+
"aarch64-linux"
21+
"x86_64-linux"
22+
"aarch64-darwin"
23+
];
24+
25+
# Helper to iterate over systems
26+
eachSystem =
27+
f:
28+
privateInputs.nixos-unstable-small.lib.genAttrs systems (
29+
system: f privateInputs.nixos-unstable-small.legacyPackages.${system} system
30+
);
31+
32+
eachSystemFormat =
33+
f:
34+
privateInputs.nixos-unstable-small.lib.genAttrs formatSystems (
35+
system: f privateInputs.nixos-unstable-small.legacyPackages.${system} system
36+
);
37+
in
638
{
739

840
nixosModules =
@@ -420,5 +452,40 @@
420452
common-pc-laptop-ssd = import ./common/pc/ssd;
421453
common-pc-ssd = import ./common/pc/ssd;
422454
};
455+
456+
# Add formatter for `nix fmt`
457+
formatter = eachSystemFormat (
458+
pkgs: _system:
459+
(privateInputs.treefmt-nix.lib.evalModule pkgs ./tests/treefmt.nix).config.build.wrapper
460+
);
461+
462+
# Add packages
463+
packages = eachSystem (
464+
pkgs: _system: {
465+
run-tests = pkgs.callPackage ./tests/run-tests.nix {
466+
inherit self;
467+
};
468+
}
469+
);
470+
471+
# Add checks for `nix run .#run-tests`
472+
checks = eachSystem (
473+
pkgs: system:
474+
let
475+
treefmtEval = privateInputs.treefmt-nix.lib.evalModule pkgs ./tests/treefmt.nix;
476+
nixosTests = import ./tests/nixos-tests.nix {
477+
inherit
478+
self
479+
privateInputs
480+
system
481+
pkgs
482+
;
483+
};
484+
in
485+
pkgs.lib.optionalAttrs (self.formatter ? ${system}) {
486+
formatting = treefmtEval.config.build.check self;
487+
}
488+
// nixosTests
489+
);
423490
};
424491
}

framework/13-inch/common/amd.nix

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
../../../common/gpu/amd
77
];
88

9-
boot.kernelParams =
10-
[
11-
# There seems to be an issue with panel self-refresh (PSR) that
12-
# causes hangs for users.
13-
#
14-
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
15-
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
16-
"amdgpu.dcdebugmask=0x10"
17-
]
18-
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/[email protected]/
19-
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
20-
"rtc_cmos.use_acpi_alarm=1"
21-
];
9+
boot.kernelParams = [
10+
# There seems to be an issue with panel self-refresh (PSR) that
11+
# causes hangs for users.
12+
#
13+
# https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459
14+
# https://gitlab.freedesktop.org/drm/amd/-/issues/3647
15+
"amdgpu.dcdebugmask=0x10"
16+
]
17+
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/[email protected]/
18+
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
19+
"rtc_cmos.use_acpi_alarm=1"
20+
];
2221

2322
# AMD has better battery life with PPD over TLP:
2423
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13

framework/13-inch/common/intel.nix

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
../../../common/cpu/intel
1010
];
1111

12-
boot.kernelParams =
13-
[
14-
# For Power consumption
15-
# https://community.frame.work/t/linux-battery-life-tuning/6665/156
16-
"nvme.noacpi=1"
17-
]
18-
# Fixes a regression in s2idle, making it more power efficient than deep sleep
19-
# Update 04/2024: It appears that s2idle-regression got fixed in newer kernel-versions (SebTM)
20-
# (see: https://github.com/NixOS/nixos-hardware/pull/903#discussion_r1556096657)
21-
++ lib.lists.optional (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") "acpi_osi=\"!Windows 2020\"";
12+
boot.kernelParams = [
13+
# For Power consumption
14+
# https://community.frame.work/t/linux-battery-life-tuning/6665/156
15+
"nvme.noacpi=1"
16+
]
17+
# Fixes a regression in s2idle, making it more power efficient than deep sleep
18+
# Update 04/2024: It appears that s2idle-regression got fixed in newer kernel-versions (SebTM)
19+
# (see: https://github.com/NixOS/nixos-hardware/pull/903#discussion_r1556096657)
20+
++ lib.lists.optional (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") "acpi_osi=\"!Windows 2020\"";
2221

2322
# Requires at least 5.16 for working wi-fi and bluetooth.
2423
# https://community.frame.work/t/using-the-ax210-with-linux-on-the-framework-laptop/1844/89

0 commit comments

Comments
 (0)