mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
tests/lib: init env-specific subset
This commit is contained in:
parent
d5b4cfe3ba
commit
5d7859abb1
@ -1,4 +1,5 @@
|
|||||||
{ pkgs }:
|
# For the environment-specific subset, we'll be simulating the configurations
|
||||||
|
# as a simple attribute set since that's what they are anyways.
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
@ -16,5 +17,9 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
trivial = callLib ./trivial.nix;
|
trivial = callLib ./trivial.nix;
|
||||||
#home-manager = callLib ./home-manager.nix;
|
|
||||||
|
# Environment-specific subset.
|
||||||
|
home-manager = callLib ./home-manager.nix;
|
||||||
|
nixos = callLib ./nixos.nix;
|
||||||
|
nixvim = callLib ./nixvim.nix;
|
||||||
}
|
}
|
||||||
|
57
tests/lib/home-manager.nix
Normal file
57
tests/lib/home-manager.nix
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{ pkgs, lib, self }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# We're just using stub configurations instead.
|
||||||
|
nixosConfig = {
|
||||||
|
programs = {
|
||||||
|
firefox = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
|
pipewire = {
|
||||||
|
enable = true;
|
||||||
|
wireplumber.enable = true;
|
||||||
|
alsa.enable = true;
|
||||||
|
alsa.support32Bit = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
jack.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
hmConfig = {
|
||||||
|
services = {
|
||||||
|
activitywatch.enable = true;
|
||||||
|
bleachbit = {
|
||||||
|
enable = true;
|
||||||
|
cleaners = [
|
||||||
|
"firefox.cookies"
|
||||||
|
"discord.cache"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
hmConfig' = {
|
||||||
|
inherit nixosConfig;
|
||||||
|
osConfig = nixosConfig;
|
||||||
|
} // hmConfig;
|
||||||
|
in
|
||||||
|
lib.runTests {
|
||||||
|
testHomeManagerStandaloneEmpty = {
|
||||||
|
expr = self.home-manager.hasNixOSConfigAttr { } [ "programs" "firefox" "enable" ] false;
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHomeManagerStandalone = {
|
||||||
|
expr = self.home-manager.hasNixOSConfigAttr hmConfig [ "programs" "firefox" "enable" ] false;
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHomeManagerWithinNixOS = {
|
||||||
|
expr = self.home-manager.hasNixOSConfigAttr hmConfig' [ "programs" "firefox" "enable" ] false;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
}
|
28
tests/lib/nixos.nix
Normal file
28
tests/lib/nixos.nix
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{ pkgs, lib, self }:
|
||||||
|
|
||||||
|
let
|
||||||
|
testConfig = {
|
||||||
|
formatAttr = "isoImage";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.runTests {
|
||||||
|
testNixSystemHasFormat = {
|
||||||
|
expr = self.nixos.hasNixosFormat testConfig;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testNixSystemNoFormat = {
|
||||||
|
expr = self.nixos.hasNixosFormat { };
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
testNixSystemFormatCompare = {
|
||||||
|
expr = self.nixos.isFormat testConfig "isoImage";
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testNixSystemFormatCompare2 = {
|
||||||
|
expr = self.nixos.isFormat { } "isoImage";
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
}
|
28
tests/lib/nixvim.nix
Normal file
28
tests/lib/nixvim.nix
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{ pkgs, lib, self }:
|
||||||
|
|
||||||
|
let
|
||||||
|
nixvimConfig = {
|
||||||
|
plugins.lightline.enable = true;
|
||||||
|
|
||||||
|
plugins.neorg.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixosConfig = {
|
||||||
|
programs.firefox.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nixvimConfig' = {
|
||||||
|
inherit nixosConfig;
|
||||||
|
} // nixvimConfig;
|
||||||
|
in
|
||||||
|
lib.runTests {
|
||||||
|
testNixvimIsStandalone = {
|
||||||
|
expr = self.nixvim.isStandalone nixvimConfig;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testNixvimIsStandalone2 = {
|
||||||
|
expr = self.nixvim.isStandalone nixvimConfig';
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user