1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-07 01:07:00 +00:00
home-manager/tests/default.nix

406 lines
13 KiB
Nix
Raw Normal View History

{ pkgs ? import <nixpkgs> { }, enableBig ? true }:
2018-12-11 00:51:48 +01:00
let
lib = import ../modules/lib/stdlib-extended.nix pkgs.lib;
nmtSrc = fetchTarball {
url = "https://git.sr.ht/~rycee/nmt/archive/v0.5.1.tar.gz";
sha256 = "0qhn7nnwdwzh910ss78ga2d00v42b0lspfd7ybl61mpfgz3lmdcj";
};
# Recursively replace each derivation in the given attribute set with the same
# derivation but with the `outPath` attribute set to the string
# `"@package-name@"`. This allows the tests to refer to derivations through
# their values without establishing an actual dependency on the derivation
# output.
scrubDerivations = attrs:
let
scrubDerivation = name: value:
let
scrubbedValue = scrubDerivations value;
newDrvAttrs = {
buildScript = abort "no build allowed";
outPath = builtins.traceVerbose ("${name} - got out path")
"@${lib.getName value}@";
# Prevent getOutput from descending into outputs
outputSpecified = true;
# Allow the original package to be used in derivation inputs
__spliced = {
buildHost = value;
hostTarget = value;
};
};
in if lib.isAttrs value then
if lib.isDerivation value then
scrubbedValue // newDrvAttrs
else
scrubbedValue
else
value;
in lib.mapAttrs scrubDerivation attrs;
# Globally unscrub a few selected packages that are used by a wide selection of tests.
whitelist = let
inner = self: super: {
inherit (pkgs)
coreutils jq desktop-file-utils diffutils findutils glibcLocales gettext
gnugrep gnused shared-mime-info emptyDirectory
# Needed by pretty much all tests that have anything to do with fish.
babelfish fish;
xorg =
super.xorg.overrideScope (self: super: { inherit (pkgs.xorg) lndir; });
};
outer = self: super:
inner self super // {
buildPackages = super.buildPackages.extend inner;
};
in outer;
scrubbedPkgs =
let rawScrubbedPkgs = lib.makeExtensible (final: scrubDerivations pkgs);
in builtins.traceVerbose "eval scrubbed nixpkgs"
(rawScrubbedPkgs.extend whitelist);
modules = import ../modules/modules.nix {
inherit lib pkgs;
check = false;
} ++ [
({ config, ... }: {
_module.args = {
# Prevent the nixpkgs module from working. We want to minimize the number
# of evaluations of Nixpkgs.
pkgsPath = abort "pkgs path is unavailable in tests";
realPkgs = pkgs;
pkgs = let
overlays = config.test.stubOverlays ++ lib.optionals
(config.nixpkgs.overlays != null && config.nixpkgs.overlays != [ ])
config.nixpkgs.overlays;
stubbedPkgs = if overlays == [ ] then
scrubbedPkgs
else
builtins.traceVerbose "eval overlayed nixpkgs"
(lib.foldr (o: p: p.extend o) scrubbedPkgs overlays);
in lib.mkImageMediaOverride stubbedPkgs;
};
# Fix impurities. Without these some of the user's environment
# will leak into the tests through `builtins.getEnv`.
xdg.enable = true;
home = {
username = "hm-user";
homeDirectory = "/home/hm-user";
stateVersion = lib.mkDefault "18.09";
};
# Avoid including documentation since this will cause
# unnecessary rebuilds of the tests.
manual.manpages.enable = lib.mkDefault false;
imports = [ ./asserts.nix ./big-test.nix ./stubs.nix ];
test.enableBig = enableBig;
})
];
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
isLinux = pkgs.stdenv.hostPlatform.isLinux;
in import nmtSrc {
inherit lib pkgs modules;
2018-12-11 00:51:48 +01:00
testedAttrPath = [ "home" "activationPackage" ];
tests = builtins.foldl' (a: b: a // (import b)) { } ([
./lib/generators
./lib/types
./modules/files
./modules/home-environment
./modules/misc/fontconfig
./modules/misc/manual
nix: add structural settings (#2718) Nix permits user level configurations through ~/.config/nix/nix.conf that allow customization of system-wide settings and behavior. This is beneficial in chroot environments and for per-user configurations. System level Nix configurations in the form of /etc/nix/nix.conf can be specified declaratively via the NixOS nix module but as of currently no counter part exists in home-manager. This PR is a port of the RFC42 implementation for the NixOS nix module[1] to home-manager. Non-applicable options have been excluded and the config generation backends have been tweaked to the backends offered by home-manager. A notable change from the NixOS module is a mandatory option to specify the Nix binary corresponding to the version "nix.conf" should be generated against. This is necessary because the validation phase is dependent on the `nix show-config` subcommand on the host platform. While it is possible to avoid validation entirely, the lack of type checking was deemed too significant. In NixOs, the version information can be retrieved from the `package` option itself which declares the Nix binary system-wide. However in home-manager, there is no pure way to detect the system Nix version and what state version the "nix.conf" should be generated against. Thus an option is used to overcome this limitation by forcing the user to specify the Nix package. Note this interaction can still be automated by forwarding the system-wide Nix package to the home-manager module if needed. Three unit tests were added to test the module behavior for the empty settings, the example settings and the example registry configurations respectively. [1] - NixOS/nixpkgs#139075
2022-03-17 22:47:32 -04:00
./modules/misc/nix
./modules/misc/specialisation
./modules/programs/aerc
./modules/programs/alacritty
./modules/programs/alot
./modules/programs/antidote
2020-04-28 14:38:41 -04:00
./modules/programs/aria2
./modules/programs/atuin
./modules/programs/autojump
./modules/programs/bacon
./modules/programs/bash
./modules/programs/bat
./modules/programs/borgmatic
./modules/programs/bottom
./modules/programs/broot
./modules/programs/browserpass
2022-08-17 18:16:01 +02:00
./modules/programs/btop
2023-09-03 12:09:45 +02:00
./modules/programs/carapace
2023-06-16 21:38:29 +02:00
./modules/programs/cava
2024-10-10 00:08:02 +02:00
./modules/programs/cmus
2023-04-14 23:41:51 +02:00
./modules/programs/comodoro
2023-03-27 12:25:17 -06:00
./modules/programs/darcs
2020-05-06 12:23:40 -04:00
./modules/programs/dircolors
./modules/programs/direnv
./modules/programs/earthly
./modules/programs/emacs
2024-05-02 02:23:11 +02:00
./modules/programs/fastfetch
./modules/programs/feh
./modules/programs/fish
./modules/programs/gallery-dl
2020-10-15 22:25:47 +02:00
./modules/programs/gh
2023-07-05 19:56:25 +02:00
./modules/programs/gh-dash
2024-12-26 20:01:54 -03:00
./modules/programs/ghostty
./modules/programs/git
2023-09-19 08:03:34 +02:00
./modules/programs/git-cliff
./modules/programs/git-credential-oauth
2024-12-14 16:13:07 -03:00
./modules/programs/git-worktree-switcher
2024-10-26 00:00:00 +07:00
./modules/programs/go
./modules/programs/gpg
./modules/programs/gradle
./modules/programs/granted
2022-01-04 00:09:24 +01:00
./modules/programs/helix
./modules/programs/himalaya
./modules/programs/htop
2022-08-01 11:03:41 -04:00
./modules/programs/hyfetch
2020-04-30 23:49:20 -04:00
./modules/programs/i3status
./modules/programs/irssi
2023-01-27 22:15:17 +01:00
./modules/programs/jujutsu
2024-02-18 22:57:35 +01:00
./modules/programs/joplin-desktop
2025-02-22 16:23:01 +00:00
./modules/programs/jqp
2022-10-23 21:22:14 +02:00
./modules/programs/k9s
./modules/programs/kakoune
./modules/programs/khal
2023-07-03 22:06:38 +02:00
./modules/programs/khard
2023-09-19 08:03:34 +02:00
./modules/programs/kitty
2024-10-03 15:57:31 +02:00
./modules/programs/kubecolor
./modules/programs/lapce
./modules/programs/ledger
./modules/programs/less
2024-12-27 18:39:49 +01:00
./modules/programs/lesspipe
./modules/programs/lf
./modules/programs/lsd
./modules/programs/lieer
./modules/programs/man
./modules/programs/mbsync
./modules/programs/micro
./modules/programs/mise
./modules/programs/mpv
./modules/programs/mu
./modules/programs/mujmap
2020-08-26 21:20:54 +02:00
./modules/programs/ncmpcpp
./modules/programs/ne
./modules/programs/neomutt
./modules/programs/neovide
./modules/programs/neovim
./modules/programs/newsboat
2022-08-17 13:58:46 +02:00
./modules/programs/nheko
./modules/programs/nix-index
2024-07-18 14:15:10 +02:00
./modules/programs/nix-your-shell
./modules/programs/nnn
2020-07-24 17:15:55 +02:00
./modules/programs/nushell
2022-09-29 13:08:53 +02:00
./modules/programs/oh-my-posh
./modules/programs/openstackclient
./modules/programs/pandoc
2023-01-27 04:20:00 +00:00
./modules/programs/papis
./modules/programs/pay-respects
./modules/programs/pet
2022-03-28 11:19:38 -04:00
./modules/programs/pistol
2022-09-30 18:53:39 +02:00
./modules/programs/pls
2024-02-24 17:39:35 +01:00
./modules/programs/poetry
./modules/programs/powerline-go
./modules/programs/pubs
./modules/programs/pyenv
2023-08-12 22:07:04 +02:00
./modules/programs/qcal
2020-04-07 03:10:07 -04:00
./modules/programs/qutebrowser
2023-08-26 15:36:08 +02:00
./modules/programs/ranger
./modules/programs/readline
./modules/programs/rio
./modules/programs/ripgrep
./modules/programs/ruff
2021-12-30 06:47:44 -05:00
./modules/programs/sagemath
./modules/programs/sapling
2021-01-30 03:29:23 +01:00
./modules/programs/sbt
./modules/programs/scmpuff
2023-11-11 10:19:45 +01:00
./modules/programs/senpai
2023-11-06 20:05:51 +01:00
./modules/programs/sftpman
./modules/programs/sioyek
2021-07-11 19:28:56 +02:00
./modules/programs/sm64ex
2024-04-19 12:39:30 +02:00
./modules/programs/spotify-player
./modules/programs/ssh
./modules/programs/starship
./modules/programs/taskwarrior
./modules/programs/tealdeer
./modules/programs/texlive
2023-10-01 21:41:55 +07:00
./modules/programs/thefuck
./modules/programs/thunderbird
2022-09-21 22:59:50 +02:00
./modules/programs/tmate
./modules/programs/tmux
2021-04-29 05:26:58 +05:30
./modules/programs/topgrade
2023-05-11 04:21:18 -05:00
./modules/programs/translate-shell
2022-09-09 07:42:53 +07:00
./modules/programs/vifm
./modules/programs/vim-vint
2025-02-21 10:48:51 -03:00
./modules/programs/vinegar
./modules/programs/vscode
./modules/programs/watson
2022-04-08 12:18:27 +05:30
./modules/programs/wezterm
./modules/programs/yazi
./modules/programs/zed-editor
./modules/programs/zellij
2023-09-11 15:50:12 -03:00
./modules/programs/zk
./modules/programs/zplug
./modules/programs/zsh
./modules/services/gpg-agent
2023-09-19 08:03:34 +02:00
./modules/services/syncthing/common
./modules/xresources
] ++ lib.optionals isDarwin [
./modules/launchd
./modules/programs/aerospace
2024-11-22 23:35:22 +08:00
./modules/services/emacs-darwin
2024-04-15 01:40:27 -06:00
./modules/services/espanso-darwin
./modules/services/git-sync-darwin
./modules/services/imapnotify-darwin
./modules/services/nix-gc-darwin
2025-01-25 01:54:49 +02:00
./modules/services/ollama/darwin
./modules/services/yubikey-agent-darwin
./modules/targets-darwin
] ++ lib.optionals isLinux [
./modules/config/home-cursor
./modules/config/i18n
2021-06-16 01:59:25 +03:00
./modules/i18n/input-method
./modules/misc/debug
./modules/misc/editorconfig
./modules/misc/gtk
./modules/misc/numlock
./modules/misc/pam
./modules/misc/qt
./modules/misc/xdg
./modules/misc/xsession
./modules/programs/abook
./modules/programs/autorandr
2023-09-29 13:04:57 +02:00
./modules/programs/awscli
./modules/programs/beets # One test relies on services.mpd
2023-11-29 01:23:23 -06:00
./modules/programs/bemenu
./modules/programs/boxxy
2024-12-18 16:42:28 +01:00
./modules/programs/cavalier
2025-02-12 13:52:35 +01:00
./modules/programs/eww
./modules/programs/firefox
./modules/programs/firefox/firefox.nix
./modules/programs/firefox/floorp.nix
./modules/programs/firefox/librewolf.nix
./modules/programs/foot
2024-04-21 13:12:43 +02:00
./modules/programs/freetube
2023-03-01 15:57:55 +01:00
./modules/programs/fuzzel
./modules/programs/getmail
2021-05-16 14:54:43 -07:00
./modules/programs/gnome-shell
./modules/programs/gnome-terminal
./modules/programs/hexchat
2024-04-22 22:34:22 -05:00
./modules/programs/hyprlock
2023-11-13 16:10:38 -08:00
./modules/programs/i3blocks
./modules/programs/i3status-rust
./modules/programs/imv
./modules/programs/kodi
2022-10-09 20:11:59 +02:00
./modules/programs/looking-glass-client
2021-06-12 09:55:58 +02:00
./modules/programs/mangohud
2020-08-26 21:20:54 +02:00
./modules/programs/ncmpcpp-linux
./modules/programs/pqiv
./modules/programs/rbw
./modules/programs/rofi
./modules/programs/rofi-pass
2025-02-21 19:15:02 +01:00
./modules/programs/swayimg
2022-06-07 15:01:14 -04:00
./modules/programs/swaylock
./modules/programs/swayr
./modules/programs/terminator
2024-04-16 22:44:55 +02:00
./modules/programs/tofi
2020-07-29 16:29:51 -04:00
./modules/programs/waybar
2023-01-31 17:06:18 +01:00
./modules/programs/wlogout
./modules/programs/wofi
./modules/programs/xmobar
2022-10-25 21:31:46 +09:00
./modules/programs/yambar
2022-09-09 09:56:07 +02:00
./modules/programs/yt-dlp
2023-08-04 19:56:37 +08:00
./modules/services/activitywatch
./modules/services/avizo
./modules/services/barrier
2024-05-08 06:16:09 +02:00
./modules/services/blanket
2022-09-25 19:27:04 +02:00
./modules/services/borgmatic
2022-10-27 19:08:14 +02:00
./modules/services/cachix-agent
2023-10-15 14:03:18 +02:00
./modules/services/cliphist
2022-08-27 20:52:41 +02:00
./modules/services/clipman
./modules/services/clipse
2023-04-14 23:41:51 +02:00
./modules/services/comodoro
2024-12-28 11:16:56 +01:00
./modules/services/copyq
2023-12-27 20:00:49 +08:00
./modules/services/conky
./modules/services/darkman
./modules/services/devilspie2
./modules/services/dropbox
./modules/services/emacs
./modules/services/espanso
2021-10-11 21:41:49 +02:00
./modules/services/flameshot
./modules/services/fluidsynth
./modules/services/fnott
./modules/services/fusuma
2021-07-14 19:20:28 -06:00
./modules/services/git-sync
2024-06-28 08:24:13 -07:00
./modules/services/glance
2019-02-24 12:33:56 -07:00
./modules/services/gromit-mpx
./modules/services/home-manager-auto-upgrade
2024-05-05 04:13:18 -05:00
./modules/services/hypridle
2024-04-27 09:54:16 -05:00
./modules/services/hyprpaper
./modules/services/imapnotify
2020-04-12 15:42:43 +02:00
./modules/services/kanshi
./modules/services/lieer
./modules/services/linux-wallpaperengine
./modules/services/mopidy
2022-03-04 00:43:40 +01:00
./modules/services/mpd
2022-12-27 18:15:51 +01:00
./modules/services/mpd-mpris
2023-09-19 08:03:34 +02:00
./modules/services/mpdris2
./modules/services/nix-gc
2025-01-25 01:54:49 +02:00
./modules/services/ollama/linux
./modules/services/osmscout-server
2021-06-07 23:38:42 +02:00
./modules/services/pantalaimon
2022-12-28 22:16:14 +01:00
./modules/services/parcellite
./modules/services/pass-secret-service
./modules/services/pasystray
2020-12-03 03:55:37 +01:00
./modules/services/pbgopy
./modules/services/picom
2021-01-30 18:20:36 +01:00
./modules/services/playerctld
./modules/services/podman-linux
2020-03-02 22:31:15 +01:00
./modules/services/polybar
2022-02-07 18:54:09 +08:00
./modules/services/recoll
./modules/services/redshift-gammastep
./modules/services/remmina
./modules/services/screen-locker
2023-11-11 22:49:58 +01:00
./modules/services/signaturepdf
./modules/services/snixembed
./modules/services/swayidle
./modules/services/swaync
2023-07-07 10:15:43 +02:00
./modules/services/swayosd
./modules/services/sxhkd
2023-02-09 01:59:38 +09:00
./modules/services/syncthing/linux
./modules/services/tldr-update
2021-07-21 22:43:18 +02:00
./modules/services/trayer
./modules/services/trayscale
./modules/services/twmn
2022-08-22 11:01:54 -04:00
./modules/services/udiskie
./modules/services/volnoti
./modules/services/window-managers/bspwm
2021-11-09 23:17:36 +01:00
./modules/services/window-managers/herbstluftwm
./modules/services/window-managers/hyprland
./modules/services/window-managers/i3
2023-08-11 11:09:54 +02:00
./modules/services/window-managers/river
2022-07-08 19:31:25 +02:00
./modules/services/window-managers/spectrwm
./modules/services/window-managers/sway
./modules/services/window-managers/wayfire
./modules/services/wlsunset
./modules/services/wob
./modules/services/wpaperd
./modules/services/xsettingsd
./modules/services/yubikey-agent
./modules/systemd
./modules/targets-linux
]);
2018-12-11 00:51:48 +01:00
}