Skip to content

Commit 7006b36

Browse files
committed
test that nixos-shell exits nonzero on bad config
namely a config that lacks both the `override` and `extendModules` attributes.
1 parent 4f3df0d commit 7006b36

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ test-mounts:
2121
test-efi:
2222
$(NIXOS_SHELL) examples/vm-efi.nix
2323

24+
test-broken:
25+
! $(NIXOS_SHELL) --flake '.#BROKEN-DO-NOT-USE-UNLESS-YOU-KNOW-WHAT-YOU-ARE-DOING'
26+
2427
install:
2528
$(INSTALL) -D bin/nixos-shell $(DESTDIR)$(PREFIX)/bin/nixos-shell
2629
$(INSTALL) -D share/modules/nixos-shell.nix $(DESTDIR)$(PREFIX)/share/modules/nixos-shell.nix

flake.nix

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@
1818

1919
mkSystem = pkgs: config: makeOverridable nixosSystem {
2020
system = "x86_64-linux";
21-
modules = [ config inp.self.nixosModules.nixos-shell ];
21+
modules = [ config inp.self.nixosModules.nixos-shell ];
2222
};
2323

2424
supportedSystems = [ "x86_64-linux" ];
2525
in
2626
{
27-
nixosConfigurations = mapAttrs (_name: config: mkSystem inp.nixpkgs config) vms;
27+
nixosConfigurations =
28+
let
29+
configs = mapAttrs (_name: config: mkSystem inp.nixpkgs config) vms;
30+
in
31+
configs
32+
//
33+
{
34+
# Used for testing that nixos-shell exits nonzero when provided a
35+
# non-extensible config
36+
BROKEN-DO-NOT-USE-UNLESS-YOU-KNOW-WHAT-YOU-ARE-DOING =
37+
removeAttrs configs.vm [ "extendModules" "override" ];
38+
};
2839

2940
nixosModules.nixos-shell = import ./share/modules/nixos-shell.nix;
3041
}

0 commit comments

Comments
 (0)