diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 20ff4d5..9bb32f6 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -24,7 +24,7 @@ jobs: id: cache-nix-store with: path: nix-store.dump - key: nix-store-${{ hashFiles('flake.*') }} + key: nix-store-${{ hashFiles('flake.lock') }} restore-keys: | nix-store- - name: Import /nix/store contents @@ -41,6 +41,40 @@ jobs: if: ${{ !steps.cache-nix-store.outputs.cache-hit }} run: | nix-store --export $(nix-store -qR /nix/store/*-doom-emacs) > nix-store.dump + check-home-manager: + name: Home-Manager module (x86_64 only) + needs: check-emacs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # Nix Flakes doesn't work on shallow clones + fetch-depth: 0 + - uses: cachix/install-nix-action@v17 + with: + name: nix-community + - name: Retrieve /nix/store archive + uses: actions/cache@v3 + id: cache-nix-store + with: + path: nix-store.dump + key: nix-store-${{ hashFiles('flake.lock') }} + restore-keys: | + nix-store- + - name: Import /nix/store contents + if: ${{ steps.cache-nix-store.outputs.cache-hit }} + run: | + if [[ -f nix-store.dump ]]; then + nix-store --import < nix-store.dump || true + rm nix-store.dump + fi + - name: Run checks in Home-Manager module + run: | + nix build .#checks.x86_64-linux.home-manager-module + - name: Export /nix/store contents + if: ${{ !steps.cache-nix-store.outputs.cache-hit }} + run: | + nix-store --export $(nix-store -qR /nix/store/*-doom-emacs) > nix-store.dump check-emacsGit: name: Flake Check emacsGit (x86_64 only) runs-on: ubuntu-latest @@ -57,7 +91,7 @@ jobs: id: cache-nix-store-emacsGit with: path: nix-store.dump - key: nix-store-emacsGit-${{ hashFiles('flake.*') }} + key: nix-store-emacsGit-${{ hashFiles('flake.lock') }} restore-keys: | nix-store-emacsGit- - name: Import /nix/store contents diff --git a/checks.nix b/checks.nix new file mode 100644 index 0000000..4811f12 --- /dev/null +++ b/checks.nix @@ -0,0 +1,46 @@ +{ system }: +{ self, nixpkgs, emacs-overlay, ... }@inputs: + +let + pkgs = import nixpkgs { + inherit system; + # we are not using emacs-overlay's flake.nix here, + # to avoid unnecessary inputs to be added to flake.lock; + # this means we need to import the overlay in a hack-ish way + overlays = [ (import emacs-overlay) ]; + }; + # we are cloning HM here for the same reason as above, to avoid + # an extra additional input to be added to flake + home-manager = pkgs.fetchFromGitHub { + owner = "nix-community"; + repo = "home-manager"; + rev = "8160b3b45b8457d58d2b3af2aeb2eb6f47042e0f"; + sha256 = "sha256-/aN3p2LaRNVXf7w92GWgXq9H5f23YRQPOvsm3BrBqzU="; + }; +in +{ + home-manager-module = (import "${home-manager}/modules" { + inherit pkgs; + configuration = { + imports = [ self.outputs.hmModule ]; + home = { + username = "nix-doom-emacs"; + homeDirectory = "/tmp"; + stateVersion = "22.11"; + }; + programs.doom-emacs = { + enable = true; + doomPrivateDir = ./test/doom.d; + }; + }; + }).activationPackage; + init-example-el = self.outputs.package.${system} { + doomPrivateDir = ./test/doom.d; + dependencyOverrides = inputs; + }; + init-example-el-emacsGit = self.outputs.package.${system} { + doomPrivateDir = ./test/doom.d; + dependencyOverrides = inputs; + emacsPackages = with pkgs; emacsPackagesFor emacsGit; + }; +} diff --git a/default.nix b/default.nix index 62e3275..52d539a 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,13 @@ { # The files would be going to ~/.config/doom (~/.doom.d) doomPrivateDir -/* Extra packages to install + /* Extra packages to install - Useful for non-emacs packages containing emacs bindings (e.g. - mu4e). + Useful for non-emacs packages containing emacs bindings (e.g. + mu4e). - Example: - extraPackages = epkgs: [ pkgs.mu ]; -*/ + Example: + extraPackages = epkgs: [ pkgs.mu ]; + */ , extraPackages ? epkgs: [ ] /* Extra configuration to source during initialization @@ -24,17 +24,17 @@ Only used to get emacs package, if `bundledPackages` is set. */ , emacsPackages -/* Overlay to customize emacs (elisp) dependencies + /* Overlay to customize emacs (elisp) dependencies - See overrides.nix for addition examples. + See overrides.nix for addition examples. - Example: - emacsPackagesOverlay = self: super: { - magit-delta = super.magit-delta.overrideAttrs (esuper: { - buildInputs = esuper.buildInputs ++ [ pkgs.git ]; - }); - }; -*/ + Example: + emacsPackagesOverlay = self: super: { + magit-delta = super.magit-delta.overrideAttrs (esuper: { + buildInputs = esuper.buildInputs ++ [ pkgs.git ]; + }); + }; + */ , emacsPackagesOverlay ? self: super: { } /* Use bundled revision of github.com/nix-community/emacs-overlay as `emacsPackages`. diff --git a/flake.nix b/flake.nix index 5308ea3..b8bc8e4 100644 --- a/flake.nix +++ b/flake.nix @@ -99,28 +99,7 @@ package = { dependencyOverrides ? { }, ... }@args: pkgs.callPackage self (args // { dependencyOverrides = (inputs // dependencyOverrides); }); - }) // eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system: { - checks = - let - pkgs = import nixpkgs { - inherit system; - # we are not using emacs-overlay's flake.nix here, - # to avoid unnecessary inputs to be added to flake.lock; - # this means we need to import the overlay in a hack-ish way - overlays = [ (import emacs-overlay) ]; - }; - in - { - init-example-el = self.outputs.package.${system} { - doomPrivateDir = ./test/doom.d; - dependencyOverrides = inputs; - }; - init-example-el-emacsGit = self.outputs.package.${system} { - doomPrivateDir = ./test/doom.d; - dependencyOverrides = inputs; - emacsPackages = with pkgs; emacsPackagesFor emacsGit; - }; - }; + checks = import ./checks.nix { inherit system; } inputs; }) // { hmModule = import ./modules/home-manager.nix inputs; };