summaryrefslogtreecommitdiff
path: root/checks/side-effects.nix
blob: a3e023607929c7c4e340398fbf978dd32e9a3af6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Test that including the WSL module in a config does not change anything without enabling it

{ system
, inputs
, emptyFile
, ...
}:
let
  configModule = { config, options, ... }: {
    fileSystems."/" = {
      device = "/dev/sda1";
      fsType = "ext4";
    };
    boot.loader.grub.device = "nodev";
    system.stateVersion = options.system.stateVersion.default;
  };

  cleanConfig = inputs.nixpkgs.lib.nixosSystem {
    inherit system;
    modules = [
      configModule
    ];
  };
  wslModuleConfig = inputs.nixpkgs.lib.nixosSystem {
    inherit system;
    modules = [
      configModule
      inputs.self.nixosModules.wsl
    ];
  };
in
# Check that both configs evaluate to the same derivation
if cleanConfig.config.system.build.toplevel.outPath == wslModuleConfig.config.system.build.toplevel.outPath
then emptyFile
else throw "The WSL module introduces a side-effect even when not enabled!"