diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 914ae85..307bab4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,34 @@ jobs: git push fi + test: + name: Test Modules + + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest] + + runs-on: ${{ matrix.os }} + + 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 tests + run: | + nix run \ + --inputs-from ./dev \ + github:Mic92/nix-fast-build -- \ + --no-nom \ + --flake "./dev#checks.$(nix eval --raw --impure --expr builtins.currentSystem)" + validate-sources: name: Validate sources @@ -70,31 +98,3 @@ jobs: run: | set -e nix eval --file ./.github/checkSources.nix - - vm: - name: Test Modules - - 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 }} - run: | - nix build \ - --print-build-logs \ - --show-trace \ - "./dev#checks.x86_64-linux.module-test-$TEST" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9397714..ea6bcd8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/dev/flake.nix b/dev/flake.nix index 8c72f3e..a23748c 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -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; } ); diff --git a/modules/home-manager/gtk.nix b/modules/home-manager/gtk.nix index 39ce902..2f02c9b 100644 --- a/modules/home-manager/gtk.nix +++ b/modules/home-manager/gtk.nix @@ -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"; + }; - icon = ctp.mkCatppuccinOpt { name = "GTK modified Papirus icon theme"; } // { - accent = ctp.mkAccentOpt "GTK modified Papirus icon theme"; + gnomeShellTheme = mkEnableOption "Catppuccin gtk theme for GNOME Shell"; + + 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 diff --git a/test.nix b/test.nix deleted file mode 100644 index 86eccfa..0000000 --- a/test.nix +++ /dev/null @@ -1,149 +0,0 @@ -{ - testers, - fetchFromGitHub, - home-manager, -}: -let - common = { - catppuccin = { - enable = true; - sources = { - # this is used to ensure that we are able to apply - # source overrides without breaking the other sources - palette = fetchFromGitHub { - owner = "catppuccin"; - repo = "palette"; - rev = "16726028c518b0b94841de57cf51f14c095d43d8"; # refs/tags/1.1.1~1 - hash = "sha256-qZjMlZFTzJotOYjURRQMsiOdR2XGGba8XzXwx4+v9tk="; - }; - }; - }; - }; - - # shorthand for enabling a module - enable = { - enable = true; - }; -in -testers.runNixOSTest { - name = "module-test"; - - nodes.machine = - { lib, pkgs, ... }: - { - imports = [ - home-manager.nixosModules.default - ./modules/nixos - common - ]; - - boot = { - loader.grub = enable; - plymouth = enable; - }; - - services = { - displayManager.sddm = enable // { - package = pkgs.kdePackages.sddm; # our module/the upstream port requires the qt6 version - }; - xserver.enable = true; # required for sddm - }; - - console = enable; - - users.users.test = { - isNormalUser = true; - home = "/home/test"; - }; - - virtualisation = { - memorySize = 4096; - writableStore = true; - }; - - home-manager.users.test = { - imports = [ - ./modules/home-manager - common - ]; - - xdg.enable = true; - - home = { - username = "test"; - stateVersion = lib.mkDefault "23.11"; - }; - - manual.manpages.enable = lib.mkDefault false; - - i18n.inputMethod.enabled = "fcitx5"; - - programs = { - alacritty = enable; - bat = enable; - bottom = enable; - btop = enable; - cava = enable; - fish = enable; - foot = enable; - fzf = enable; - gh-dash = enable; - git = enable // { - delta = enable; - }; - gitui = enable; - # this is enabled by default already, but still - # listing explicitly so we know it's tested - glamour.catppuccin.enable = true; - helix = enable; - imv = enable; - k9s = enable; - kitty = enable; - lazygit = enable; - micro = enable; - mpv = enable; - neovim = enable; - newsboat = enable; - rio = enable; - rofi = enable; - skim = enable; - starship = enable; - swaylock = enable; - tmux = enable; - tofi = enable; - waybar = enable; - yazi = enable; - zathura = enable; - zellij = enable; - zsh = enable // { - syntaxHighlighting = enable; - }; - }; - - qt = enable // { - platformTheme.name = "kvantum"; - style.name = "kvantum"; - }; - - services = { - dunst = enable; - mako = enable; - polybar = enable // { - script = '' - polybar top & - ''; - }; - }; - - wayland.windowManager.sway = enable; - wayland.windowManager.hyprland = enable; - }; - }; - - testScript = _: '' - machine.start() - machine.wait_for_unit("home-manager-test.service") - machine.wait_until_succeeds("systemctl status home-manager-test.service") - machine.succeed("echo \"system started!\"") - ''; -} diff --git a/tests/common.nix b/tests/common.nix new file mode 100644 index 0000000..08f10d7 --- /dev/null +++ b/tests/common.nix @@ -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="; + }; + }; + }; +} diff --git a/tests/darwin.nix b/tests/darwin.nix new file mode 100644 index 0000000..07a885b --- /dev/null +++ b/tests/darwin.nix @@ -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 diff --git a/tests/default.nix b/tests/default.nix new file mode 100644 index 0000000..cc370e7 --- /dev/null +++ b/tests/default.nix @@ -0,0 +1,17 @@ +{ + lib, + nixpkgs, + nixpkgs-stable, + home-manager, + home-manager-stable, +}: +lib.optionalAttrs nixpkgs.stdenv.isLinux { + nixos-test-unstable = nixpkgs.callPackage ./nixos.nix { inherit home-manager; }; + nixos-test-stable = nixpkgs-stable.callPackage ./nixos.nix { home-manager = home-manager-stable; }; +} +// lib.optionalAttrs nixpkgs.stdenv.isDarwin { + darwin-test-unstable = nixpkgs.callPackage ./darwin.nix { inherit home-manager; }; + darwin-test-stable = nixpkgs-stable.callPackage ./darwin.nix { + home-manager = home-manager-stable; + }; +} diff --git a/tests/home.nix b/tests/home.nix new file mode 100644 index 0000000..72f2d87 --- /dev/null +++ b/tests/home.nix @@ -0,0 +1,82 @@ +{ lib, ... }: +{ + imports = [ + ../modules/home-manager + ./common.nix + ]; + + xdg.enable = true; + + home = { + username = "test"; + stateVersion = lib.mkDefault "23.11"; + }; + + manual.manpages.enable = lib.mkDefault false; + + i18n.inputMethod.enabled = "fcitx5"; + + programs = { + alacritty.enable = true; + bat.enable = true; + bottom.enable = true; + btop.enable = true; + cava.enable = true; + fish.enable = true; + foot.enable = true; + fzf.enable = true; + gh-dash.enable = true; + git = { + enable = true; + delta.enable = true; + }; + gitui.enable = true; + # this is enabled by default already, but still + # listing explicitly so we know it's tested + glamour.catppuccin.enable = true; + helix.enable = true; + imv.enable = true; + k9s.enable = true; + kitty.enable = true; + lazygit.enable = true; + micro.enable = true; + mpv.enable = true; + neovim.enable = true; + newsboat.enable = true; + rio.enable = true; + rofi.enable = true; + skim.enable = true; + starship.enable = true; + swaylock.enable = true; + tmux.enable = true; + tofi.enable = true; + waybar.enable = true; + yazi.enable = true; + zathura.enable = true; + zellij.enable = true; + zsh = { + enable = true; + syntaxHighlighting.enable = true; + }; + }; + + qt = { + enable = true; + platformTheme.name = "kvantum"; + style.name = "kvantum"; + }; + + services = { + dunst.enable = true; + mako.enable = true; + polybar = { + enable = true; + script = '' + polybar top & + ''; + }; + }; + + wayland.windowManager.sway.enable = true; + wayland.windowManager.hyprland.enable = true; +} diff --git a/tests/nixos.nix b/tests/nixos.nix new file mode 100644 index 0000000..9f39471 --- /dev/null +++ b/tests/nixos.nix @@ -0,0 +1,50 @@ +{ testers, home-manager }: +testers.runNixOSTest { + name = "module-test"; + + nodes.machine = + { lib, pkgs, ... }: + { + imports = [ + home-manager.nixosModules.default + ../modules/nixos + ./common.nix + ]; + + boot = { + loader.grub.enable = true; + plymouth.enable = true; + }; + + services = { + displayManager.sddm = { + enable = true; + package = pkgs.kdePackages.sddm; # our module/the upstream port requires the qt6 version + }; + xserver.enable = true; # required for sddm + }; + + console.enable = true; + + users.users.test = { + isNormalUser = true; + home = "/home/test"; + }; + + virtualisation = { + memorySize = 4096; + writableStore = true; + }; + + home-manager.users.test = { + imports = [ ./home.nix ]; + }; + }; + + testScript = _: '' + machine.start() + machine.wait_for_unit("home-manager-test.service") + machine.wait_until_succeeds("systemctl status home-manager-test.service") + machine.succeed("echo \"system started!\"") + ''; +}