Skip to content

Commit

Permalink
tests: Add a test for the home-manager module
Browse files Browse the repository at this point in the history
  • Loading branch information
traxys committed Jan 6, 2024
1 parent eecd2ab commit f447ee1
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
- run: nix flake check --all-systems --builders ""
- run: nix flake check --all-systems --builders "" ./templates/_wrapper/simple --no-write-lock-file
- run: nix build .#docs --show-trace --builders ""
- run: ./tests/modules/check.sh
2 changes: 2 additions & 0 deletions statix.toml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ignore = ["plugins/lsp/language-servers/rust-analyzer-config.nix"]
# Frequent in nix module configurations
disabled = ["repeated_keys"]
30 changes: 30 additions & 0 deletions tests/modules/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env -S nix run 'github:clhodapp/nix-runner/7b56158f7ab9fd7806068c6571833210e063df19' --
#!package nixpkgs#bash
#!package nixpkgs#home-manager
#!command bash

self=$(realpath "$(dirname "$0")")

systems=(
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
)

failures=()

ok=true

echo "=== HOME MANAGER ==="
for system in "${systems[@]}"; do
if ! home-manager --no-write-lock-file build --flake ${self}/home-manager#nixvim-${system}; then
failures+=("home-manager-${system}")
ok=false
fi
done

if [[ $ok = false ]]; then
echo -e "\nFAILURES: ${failures[@]}"
exit 1
fi
1 change: 1 addition & 0 deletions tests/modules/home-manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/flake.lock
41 changes: 41 additions & 0 deletions tests/modules/home-manager/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
description = "Nixvim Home Manager module";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixvim.url = "path:../../../";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
nixpkgs,
home-manager,
nixvim,
...
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
in {
homeConfigurations = builtins.listToAttrs (
builtins.map (system: {
name = "nixvim-${system}";
value = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};

modules = [
./home.nix
nixvim.homeManagerModules.nixvim
];
};
})
systems
);
};
}
13 changes: 13 additions & 0 deletions tests/modules/home-manager/home.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
home.username = "nixvim";
home.homeDirectory = "/invalid/dir";

home.stateVersion = "23.05"; # Please read the comment before changing.

programs.nixvim = {
enable = true;
};

# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

0 comments on commit f447ee1

Please sign in to comment.