-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from Jovian-Experiments/fix/no-op-oversight
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Module No-Op | ||
on: | ||
pull_request: | ||
push: | ||
jobs: | ||
eval: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@v4 | ||
|
||
- name: Verify module is a No-Op | ||
run: nix-instantiate ./support/nix-tests/check-no-ops.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env nix-instantiate | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# Author: Samuel Dionne-Riel | ||
# | ||
# What's this? A shebang and +x in my Nix expression?? | ||
# ¯\_(ツ)_/¯ | ||
# | ||
# Test that eval for unconfigured modules are no-ops. | ||
# | ||
# Origin: https://gitlab.com/samueldr/nixos-configuration/-/blob/cb5c6a1671ebeb1250e4f00e89787f15f45a37f1/modules/tests/check-no-ops.nix | ||
# | ||
|
||
let nixpkgs = ../../nixpkgs.nix; in | ||
{ pkgs ? import nixpkgs {} }: | ||
|
||
let | ||
baseCfg = { | ||
# Prevent stray warnings | ||
system.stateVersion = "00.00"; | ||
# Ignore bootloader asserts | ||
boot.isContainer = true; | ||
# Manual builds will differ since new options are added. This is okay. | ||
documentation.nixos.enable = false; | ||
}; | ||
compareEvals = a: b: a.config.system.build.toplevel == b.config.system.build.toplevel; | ||
evalConfig = cfg: (import (pkgs.path + "/nixos")) { configuration = { imports = [ cfg baseCfg ]; }; }; | ||
evalModule = module: evalConfig { imports = [ module ]; }; | ||
virginEval = evalConfig {}; | ||
modules = [ | ||
../../modules | ||
]; | ||
in | ||
map (modulePath: | ||
let | ||
moduleEval = evalConfig modulePath; | ||
toplevel = moduleEval.config.system.build.toplevel; | ||
vToplevel = virginEval.config.system.build.toplevel; | ||
in | ||
if !(compareEvals moduleEval virginEval) | ||
then | ||
builtins.throw '' | ||
Module '${toString modulePath}' is not a no-op. | ||
${toString modulePath} != virginEval | ||
${toplevel} != ${vToplevel} | ||
'' | ||
toplevel | ||
else toplevel | ||
) modules |