From 95c1a5d5947c4c27a9c1f2acbd025f089f13b856 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Sat, 25 May 2024 17:41:10 +1000 Subject: [PATCH] Split checks off to their own file To make it easier to add more. --- checks.nix | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 47 +++------------------------------------ 2 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 checks.nix diff --git a/checks.nix b/checks.nix new file mode 100644 index 0000000..1e0f758 --- /dev/null +++ b/checks.nix @@ -0,0 +1,65 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ + emacs29, + runCommand, + testers, + tmux, + writeText, + makeDoomPackages, +}: +let + common = { + # TODO: drop after NixOS 24.05 release. + emacs = emacs29; + doomLocalDir = "~/.local/share/nix-doom-unstraightened"; + }; + mkDoom = args: (makeDoomPackages (common // args)).doomEmacs; + doomTest = assertion: args: testers.testEqualContents { + inherit assertion; + expected = writeText "doom-expected" "Doom functions"; + # Runs Doom in tmux, waiting (by polling) until its window disappears. + actual = runCommand "interactive" { + nativeBuildInputs = [ tmux (mkDoom args) ]; + } '' + tmux new-session -s doom-testing -d + tmux new-window -n doom-window doom-emacs + for ((i = 0; i < 100; i++)); do + tmux list-windows -a | grep -q doom-window || break + sleep .1 + done + tmux kill-session -t doom-testing + ''; + }; +in { + minimal = mkDoom { doomDir = ./doomdirs/minimal; }; + minimalEmacs = (makeDoomPackages (common // { + doomDir = ./doomdirs/minimal; + })).emacsWithDoom; + full = mkDoom { + full = true; + doomDir = ./doomdirs/minimal; + }; + example = mkDoom { doomDir = ./doomdirs/example; }; + example-without-loader = mkDoom { + doomDir = ./doomdirs/example; + profileName = ""; + }; + interactive = doomTest "minimal doom starts" { doomDir = ./doomdirs/test; }; + interactive-without-loader = doomTest "minimal doom (without loader) starts" { + doomDir = ./doomdirs/test; + profileName = ""; + }; +} diff --git a/flake.nix b/flake.nix index e709d59..eda9b8b 100644 --- a/flake.nix +++ b/flake.nix @@ -51,50 +51,9 @@ in pkgs.callPackages self mergedArgs; in { - checks = perSystemPackages (pkgs: - let - common = { - # TODO: drop after NixOS 24.05 release. - emacs = pkgs.emacs29; - doomLocalDir = "~/.local/share/nix-doom-unstraightened"; - }; - mkDoom = args: (doomFromPackages pkgs (common // args)).doomEmacs; - doomTest = assertion: args: pkgs.testers.testEqualContents { - inherit assertion; - expected = pkgs.writeText "doom-expected" "Doom functions"; - # Runs Doom in tmux, waiting (by polling) until its window disappears. - actual = pkgs.runCommand "interactive" { - nativeBuildInputs = [ pkgs.tmux (mkDoom args) ]; - } '' - tmux new-session -s doom-testing -d - tmux new-window -n doom-window doom-emacs - for ((i = 0; i < 100; i++)); do - tmux list-windows -a | grep -q doom-window || break - sleep .1 - done - tmux kill-session -t doom-testing - ''; - }; - in { - minimal = mkDoom { doomDir = ./doomdirs/minimal; }; - minimalEmacs = (doomFromPackages pkgs (common // { - doomDir = ./doomdirs/minimal; - })).emacsWithDoom; - full = mkDoom { - full = true; - doomDir = ./doomdirs/minimal; - }; - example = mkDoom { doomDir = ./doomdirs/example; }; - example-without-loader = mkDoom { - doomDir = ./doomdirs/example; - profileName = ""; - }; - interactive = doomTest "minimal doom starts" { doomDir = ./doomdirs/test; }; - interactive-without-loader = doomTest "minimal doom (without loader) starts" { - doomDir = ./doomdirs/test; - profileName = ""; - }; - }); + checks = perSystemPackages (pkgs: pkgs.callPackages ./checks.nix { + makeDoomPackages = doomFromPackages pkgs; + }); packages = perSystemPackages (pkgs: { doom-example = (doomFromPackages pkgs { # TODO: drop after NixOS 24.05 release.