1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

tests: remove with lib (#6511)

This commit is contained in:
Austin Horstman 2025-02-21 21:20:07 -08:00 committed by GitHub
parent e495cd8c80
commit 439a125afe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
100 changed files with 77 additions and 398 deletions

View file

@ -1,8 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, lib, ... }:
let inherit (lib) concatStringsSep mkOption types;
in {
options.test.asserts = {
warnings = {
enable = mkOption {
@ -37,8 +35,8 @@ with lib;
};
};
config = mkMerge [
(mkIf config.test.asserts.warnings.enable {
config = lib.mkMerge [
(lib.mkIf config.test.asserts.warnings.enable {
home.file = {
"asserts/warnings.actual".text = concatStringsSep ''
@ -57,12 +55,13 @@ with lib;
'';
})
(mkIf config.test.asserts.assertions.enable {
(lib.mkIf config.test.asserts.assertions.enable {
home.file = {
"asserts/assertions.actual".text = concatStringsSep ''
--
'' (map (x: x.message) (filter (x: !x.assertion) config.assertions));
''
(map (x: x.message) (lib.filter (x: !x.assertion) config.assertions));
"asserts/assertions.expected".text = concatStringsSep ''
--

View file

@ -1,4 +1,4 @@
{ ... }: {
{
home.username = "alice";
home.homeDirectory = "/home/alice";
home.stateVersion = "24.11";

View file

@ -1,4 +1,4 @@
{ ... }: {
{
home.username = "alice";
home.homeDirectory = "/home/alice";

View file

@ -1,5 +1,3 @@
{ ... }:
{
accounts.email = {
maildirBasePath = "Mail";

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file."disabled" = {
enable = false;

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file."executable" = {
text = "";

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file.".hidden".source = ./.hidden;

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file."source with spaces!".source = ./. + "/source with spaces!";

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file = {
conflict1 = {

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file."$HOME/$FOO/bar baz".text = "blah";

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.file."using-text".text = ''
This is the

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
launchd.agents."test-service" = {

View file

@ -1,5 +1,3 @@
{ ... }:
{
editorconfig = {
enable = true;

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ pkgs, ... }: {
config = {
home.packages = [ pkgs.comic-relief pkgs.unifont ];

View file

@ -1,5 +1,3 @@
{ ... }:
{
nix = {
registry = {

View file

@ -1,8 +1,4 @@
{ config, lib, ... }:
with lib;
{
{ config, ... }: {
config = {
pam.sessionVariables = {
V1 = "v1";

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
home.file.testfile.text = "not special";
specialisation.test.configuration = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, lib, ... }: {
config = {
# Test fallback behavior for stateVersion >= 20.09, which is pure.
xdg.enable = lib.mkForce false;

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ pkgs, ... }: {
config = {
xdg.desktopEntries = {
full = { # full definition

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
xdg.configHome = /. + "${config.home.homeDirectory}/.dummy-config";
xdg.dataHome = /. + "${config.home.homeDirectory}/.dummy-data";

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
xdg.mimeApps = {

View file

@ -1,4 +1,4 @@
{ ... }: {
{
config = {
xdg.mime.enable = false;
nmt.script = ''

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
xsession = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.stateVersion = "19.09";

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.abook.enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.abook = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
test.asserts.assertions.expected = [''

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
nmt.script = let dir = "home-files/.config/aerc";

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, pkgs, ... }: {
config = {
nmt.script = let
dir = if (pkgs.stdenv.isDarwin && !config.xdg.enable) then

View file

@ -1,5 +1,3 @@
{ ... }:
{
programs.atuin = {
enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.bash = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
programs.bottom = {
enable = true;

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
programs.bottom = {
enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.boxxy.enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.boxxy.enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.dircolors = {

View file

@ -1,4 +1,4 @@
{ ... }: {
{
config = {
programs.eww = {
enable = true;

View file

@ -1,4 +1,4 @@
{ ... }: {
{
config = {
programs.eww = { enable = true; };

View file

@ -1,18 +1,13 @@
modulePath:
{ config, lib, ... }:
with lib;
let
moduleName = concatStringsSep "." modulePath;
moduleName = lib.concatStringsSep "." modulePath;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig (setAttrByPath modulePath {
config = lib.mkIf config.test.enableBig (lib.setAttrByPath modulePath {
enable = true;
enableGnomeExtensions = true;
} // {

View file

@ -1,20 +1,15 @@
modulePath:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = getAttrFromPath modulePath config;
cfg = lib.getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig ({
config = lib.mkIf config.test.enableBig ({
home.stateVersion = "23.05";
} // setAttrByPath modulePath {
} // lib.setAttrByPath modulePath {
enable = true;
policies = { BlockAboutConfig = true; };
package = pkgs.${cfg.wrappedPackageName}.override {

View file

@ -1,20 +1,15 @@
modulePath:
{ config, lib, pkgs, ... }:
with lib;
{ config, lib, ... }:
let
cfg = getAttrFromPath modulePath config;
cfg = lib.getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig ({
home.stateVersion = "19.09";
} // setAttrByPath modulePath { enable = true; } // {
} // lib.setAttrByPath modulePath { enable = true; } // {
nmt.script = ''
assertFileRegex \
home-path/bin/${cfg.wrappedPackageName} \

View file

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ lib, pkgs, ... }:
let
func = pkgs.writeText "func.fish" ''

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ lib, ... }: {
config = {
programs.fish = {
enable = true;

View file

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ lib, pkgs, ... }:
let
fooPluginSrc = pkgs.writeText "fooPluginSrc" "";

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
imports = [ ../../accounts/email-test-accounts.nix ];

View file

@ -1,5 +1,3 @@
{ ... }:
{
programs = {
fish.enable = true;

View file

@ -1,5 +1,3 @@
{ ... }:
{
programs = {
zsh.enable = true;

View file

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
dummy-gnome-shell-extensions = pkgs.runCommand "dummy-package" { } ''
mkdir -p $out/share/gnome-shell/extensions/dummy-package
@ -31,7 +28,7 @@ let
"test-extension-uuid"
];
actualEnabledExtensions = catAttrs "value"
actualEnabledExtensions = lib.catAttrs "value"
config.dconf.settings."org/gnome/shell".enabled-extensions.value;
in {
@ -62,8 +59,8 @@ in {
message = "Expected disable-user-extensions to be false.";
}
{
assertion =
all (e: elem e actualEnabledExtensions) expectedEnabledExtensions;
assertion = lib.all (e: lib.elem e actualEnabledExtensions)
expectedEnabledExtensions;
message = ''
Expected enabled-extensions to contain all of:
${toString expectedEnabledExtensions}

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
programs.gpg = {
enable = true;

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ lib, pkgs, ... }: {
config = {
programs.kitty = {
enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.kitty = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
imports = [ ../../accounts/email-test-accounts.nix ];
config = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
programs.looking-glass-client = {
enable = true;

View file

@ -1,8 +1,4 @@
{ config, lib, ... }:
with lib;
{
{ config, ... }: {
config = {
programs.looking-glass-client = {
enable = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.man = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.man = { enable = true; };

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
imports = [ ../../accounts/email-test-accounts.nix ];
config = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
imports = [ ../../accounts/email-test-accounts.nix ];
config = {

View file

@ -1,5 +1,3 @@
{ ... }:
{
home.preferXdgDirectories = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.readline = {

View file

@ -1,13 +1,9 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, lib, ... }: {
config = {
programs.ssh = { enable = true; };
home.file.assertions.text = builtins.toJSON
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
(map (a: a.message) (lib.filter (a: !a.assertion) config.assertions));
nmt.script = ''
assertFileExists home-files/.ssh/config

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.ssh = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, lib, ... }: {
config = {
programs.ssh = {
enable = true;
@ -25,7 +21,7 @@ with lib;
};
home.file.result.text = builtins.toJSON
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
(map (a: a.message) (lib.filter (a: !a.assertion) config.assertions));
nmt.script = ''
assertFileExists home-files/.ssh/config

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.ssh = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.ssh = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.ssh = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.ssh = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, lib, ... }: {
config = {
programs.ssh = {
enable = true;
@ -12,7 +8,7 @@ with lib;
proxyJump = "jump-host";
};
ordered = hm.dag.entryAfter [ "xyz" ] { port = 1; };
ordered = lib.hm.dag.entryAfter [ "xyz" ] { port = 1; };
xyz = {
identityFile = "file";
@ -49,7 +45,7 @@ with lib;
};
home.file.assertions.text = builtins.toJSON
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
(map (a: a.message) (lib.filter (a: !a.assertion) config.assertions));
nmt.script = ''
assertFileExists home-files/.ssh/config

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, lib, ... }: {
config = {
programs.ssh = {
enable = true;
@ -19,7 +15,7 @@ with lib;
};
home.file.assertions.text = builtins.toJSON
(map (a: a.message) (filter (a: !a.assertion) config.assertions));
(map (a: a.message) (lib.filter (a: !a.assertion) config.assertions));
nmt.script = ''
assertFileExists home-files/.ssh/config

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ lib, pkgs, ... }: {
config = {
programs.texlive.enable = true;
@ -14,7 +10,7 @@ with lib;
combine = tpkgs:
pkgs.symlinkJoin {
name = "dummy-texlive-combine";
paths = attrValues tpkgs;
paths = lib.attrValues tpkgs;
};
};
})

View file

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ pkgs, ... }:
let
substituteExpected = path:

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.tmux = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ pkgs, ... }: {
config = {
programs.tmux = {
aggressiveResize = true;

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.tmux = {

View file

@ -1,7 +1,3 @@
{ config, lib, ... }:
with lib;
{
config = {
programs.tmux = { enable = false; };

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.tmux = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.tmux = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.tmux = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.tmux = {

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, pkgs, ... }: {
programs.watson = {
enable = true;
package = config.lib.test.mkStubPackage { };

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, pkgs, ... }: {
programs.watson = {
enable = true;
package = config.lib.test.mkStubPackage { };

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
home.stateVersion = "22.11";

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
home.stateVersion = "22.11";

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
home.stateVersion = "22.11";

View file

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{
{ config, ... }: {
config = {
programs.xmobar = {
enable = true;

View file

@ -1,5 +1,3 @@
{ ... }:
{
services.activitywatch.enable = true;

View file

@ -1,5 +1,3 @@
{ ... }:
{
services.fluidsynth.enable = true;
services.fluidsynth.soundService = "pipewire-pulse";

View file

@ -1,5 +1,3 @@
{ ... }:
{
imports = [ ./i3-stubs.nix ];

View file

@ -1,5 +1,3 @@
{ ... }:
{
xsession.windowManager.i3 = {
enable = true;

View file

@ -1,5 +1,3 @@
{ ... }:
{
imports = [ ./i3-stubs.nix ];

View file

@ -1,5 +1,3 @@
{ ... }:
{
imports = [ ./i3-stubs.nix ];

View file

@ -1,5 +1,3 @@
{ ... }:
{
imports = [ ./i3-stubs.nix ];

View file

@ -1,5 +1,3 @@
{ ... }:
{
imports = [ ./i3-stubs.nix ];

View file

@ -1,5 +1,3 @@
{ ... }:
let
i3 = {
ws1 = "1";

View file

@ -1,5 +1,3 @@
{ ... }:
{
systemd.user.timers.test-timer = {
Unit = { Description = "A basic test timer"; };

View file

@ -1,14 +1,9 @@
{ config, lib, pkgs, ... }:
with lib;
{ pkgs, ... }:
let
darwinTestApp = pkgs.runCommandLocal "target-darwin-example-app" { } ''
mkdir -p $out/Applications
touch $out/Applications/example-app
'';
in {
config = {
home.packages = [ darwinTestApp ];

View file

@ -1,9 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
{ lib, pkgs, ... }:
let
expectedXdgDataDirs = concatStringsSep ":" [
expectedXdgDataDirs = lib.concatStringsSep ":" [
"\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share"
"/home/hm-user/.nix-profile/share"
"/usr/share/ubuntu"
@ -12,7 +9,6 @@ let
"/var/lib/snapd/desktop"
"/foo"
];
in {
config = {
targets.genericLinux.enable = true;

View file

@ -1,5 +1,3 @@
{ ... }:
{
xresources.properties = { };

View file

@ -1,5 +1,3 @@
{ ... }:
{
xresources = {
properties = {

View file

@ -1,8 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
let
inherit (lib) mkOption types;
stubType = types.submodule ({ name, ... }: {
options = {
@ -15,13 +13,13 @@ let
outPath = mkOption {
type = types.nullOr types.str;
default = "@${name}@";
defaultText = literalExpression ''"@''${name}@"'';
defaultText = lib.literalExpression ''"@''${name}@"'';
};
version = mkOption {
type = types.nullOr types.str;
default = null;
defaultText = literalExpression "pkgs.\${name}.version or null";
defaultText = lib.literalExpression "pkgs.\${name}.version or null";
};
buildScript = mkOption {
@ -52,7 +50,7 @@ let
meta.mainProgram = name;
} buildScript;
stubbedPkg = pkg // optionalAttrs (outPath != null) {
stubbedPkg = pkg // lib.optionalAttrs (outPath != null) {
inherit outPath;
# Prevent getOutput from descending into outputs
@ -63,7 +61,8 @@ let
buildHost = pkg;
hostTarget = pkg;
};
} // optionalAttrs (version != null) { inherit version; } // extraAttrs;
} // lib.optionalAttrs (version != null) { inherit version; }
// extraAttrs;
in stubbedPkg;
in {
@ -90,11 +89,12 @@ in {
config = {
lib.test.mkStubPackage = mkStubPackage;
test.stubOverlays = [ ] ++ optional (config.test.stubs != { }) (self: super:
mapAttrs (n: v:
builtins.traceVerbose "${n} - stubbed" (mkStubPackage (v
// optionalAttrs (v.version == null) {
version = super.${n}.version or null;
}))) config.test.stubs) ++ config.test.unstubs;
test.stubOverlays = [ ] ++ lib.optional (config.test.stubs != { })
(self: super:
lib.mapAttrs (n: v:
builtins.traceVerbose "${n} - stubbed" (mkStubPackage (v
// lib.optionalAttrs (v.version == null) {
version = super.${n}.version or null;
}))) config.test.stubs) ++ config.test.unstubs;
};
}