Skip to content

Commit

Permalink
chore(modules): add tests for home-manager on darwin (#251)
Browse files Browse the repository at this point in the history
* chore(modules): add tests for home-manager on darwin

* ci: use nix-fast-build for tests

this also enables the new darwin tests

* chore(tests): disable unsupported modules on darwin

* docs: add `tests` scope to CONTRIBUTING.md

* fix(home-manager): exclude `gtk.catppuccin.icon` from global enable

this was accidentally enabled by default only with `catppuccin.enable`

* fix(tests): build activationPackage for darwin
  • Loading branch information
getchoo authored Jun 29, 2024
1 parent 63e0859 commit 3fdc011
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 207 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ jobs:
git push
fi
validate-sources:
name: Validate sources
test:
name: Test Modules

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
Expand All @@ -66,35 +71,30 @@ jobs:
- name: Install Nix
uses: cachix/install-nix-action@V27

- name: Check for external repositories
- name: Setup cache
uses: DeterminateSystems/magic-nix-cache-action@v7

- name: Run tests
run: |
set -e
nix eval --file ./.github/checkSources.nix
nix run \
--inputs-from ./dev \
github:Mic92/nix-fast-build -- \
--no-nom \
--flake "./dev#checks.$(nix eval --raw --impure --expr builtins.currentSystem)"
vm:
name: Test Modules
validate-sources:
name: Validate sources

runs-on: ubuntu-latest

strategy:
matrix:
test: [unstable, stable]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@V27

- name: Setup cache
uses: DeterminateSystems/magic-nix-cache-action@v7

- name: Run VM
env:
TEST: ${{ matrix.test }}
- name: Check for external repositories
run: |
nix build \
--print-build-logs \
--show-trace \
"./dev#checks.x86_64-linux.module-test-$TEST"
set -e
nix eval --file ./.github/checkSources.nix
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ describes the motivation and content of the commit.

### Commit scopes

Available commit scopes are port names, `nixos`, `home-manager`, and `modules`. If
none of these apply, omit the scope.
Available commit scopes are port names, `nixos`, `home-manager`, `modules`, and
`tests`. If none of these apply, omit the scope.

### Breaking changes

Expand Down
9 changes: 4 additions & 5 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@
system,
...
}:
lib.optionalAttrs pkgs.stdenv.isLinux {
module-test-unstable = pkgs.callPackage ../test.nix { inherit home-manager; };
module-test-stable = nixpkgsFor.${system}.stable.callPackage ../test.nix {
home-manager = home-manager-stable;
};
import ../tests {
inherit lib home-manager home-manager-stable;
nixpkgs = pkgs;
nixpkgs-stable = nixpkgsFor.${system}.stable;
}
);

Expand Down
67 changes: 38 additions & 29 deletions modules/home-manager/gtk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,48 @@ let
enable = cfg.enable && config.gtk.enable;
in
{
options.gtk.catppuccin = ctp.mkCatppuccinOpt { name = "gtk"; } // {
# NOTE: we are overriding the previous declaration of `enable` here
# as this module is deprecated and we do not want it to apply with
# the global `catppuccin.enable`
enable = mkEnableOption "Catppuccin theme";
options.gtk.catppuccin =
ctp.mkCatppuccinOpt {
name = "gtk";
enableDefault = false;
}
// {
accent = ctp.mkAccentOpt "gtk";

accent = ctp.mkAccentOpt "gtk";
size = mkOption {
type = types.enum [
"standard"
"compact"
];
default = "standard";
description = "Catppuccin size variant for gtk";
};
tweaks = mkOption {
type = types.listOf (
types.enum [
"black"
"rimless"
"normal"
]
);
default = [ "normal" ];
description = "Catppuccin tweaks for gtk";
};
size = mkOption {
type = types.enum [
"standard"
"compact"
];
default = "standard";
description = "Catppuccin size variant for gtk";
};

gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";
tweaks = mkOption {
type = types.listOf (
types.enum [
"black"
"rimless"
"normal"
]
);
default = [ "normal" ];
description = "Catppuccin tweaks for gtk";
};

gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell";

icon = ctp.mkCatppuccinOpt { name = "GTK modified Papirus icon theme"; } // {
accent = ctp.mkAccentOpt "GTK modified Papirus icon theme";
icon =
ctp.mkCatppuccinOpt {
name = "GTK modified Papirus icon theme";
# NOTE: we exclude this from the global `catppuccin.enable` as there is no
# `enable` option in the upstream module to guard it
enableDefault = false;
}
// {
accent = ctp.mkAccentOpt "GTK modified Papirus icon theme";
};
};
};

imports = [
(mkRenamedOptionModule
Expand Down
149 changes: 0 additions & 149 deletions test.nix

This file was deleted.

16 changes: 16 additions & 0 deletions tests/common.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ pkgs, ... }:
{
catppuccin = {
enable = true;
sources = {
# this is used to ensure that we are able to apply
# source overrides without breaking the other sources
palette = pkgs.fetchFromGitHub {
owner = "catppuccin";
repo = "palette";
rev = "16726028c518b0b94841de57cf51f14c095d43d8"; # refs/tags/1.1.1~1
hash = "sha256-qZjMlZFTzJotOYjURRQMsiOdR2XGGba8XzXwx4+v9tk=";
};
};
};
}
43 changes: 43 additions & 0 deletions tests/darwin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
lib,
pkgs,
home-manager,
}:
(home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
./home.nix

{
home = {
homeDirectory = "/Users/test";
};

i18n.inputMethod.enabled = lib.mkForce null;

programs = {
cava.enable = lib.mkForce false; # NOTE: this may actually work on darwin, but the package is currently not supported
foot.enable = lib.mkForce false;
imv.enable = lib.mkForce false;
mpv.enable = lib.mkForce false; # NOTE: same as cava, but `mpv` fails to build currently
rofi.enable = lib.mkForce false;
swaylock.enable = lib.mkForce false;
tofi.enable = lib.mkForce false;
waybar.enable = lib.mkForce false;
};

qt.enable = lib.mkForce false; # NOTE: same as cava

services = {
dunst.enable = lib.mkForce false;
mako.enable = lib.mkForce false;
polybar.enable = lib.mkForce false;
};

wayland.windowManager = {
hyprland.enable = lib.mkForce false;
sway.enable = lib.mkForce false;
};
}
];
}).activationPackage
Loading

0 comments on commit 3fdc011

Please sign in to comment.