From 0f8bbe01f7bea0e99bdc96781dba89003e19f2ee Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 8 Jul 2022 19:35:42 +0100 Subject: [PATCH 1/7] Move checks to its own file --- checks.nix | 23 +++++++++++++++++++++++ flake.nix | 23 +---------------------- 2 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 checks.nix diff --git a/checks.nix b/checks.nix new file mode 100644 index 0000000..3fd6845 --- /dev/null +++ b/checks.nix @@ -0,0 +1,23 @@ +{ 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) ]; + }; +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; + }; +} 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; }; From 1713df2a43645a982e73b820235e4701b42dfbde Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 8 Jul 2022 19:46:36 +0100 Subject: [PATCH 2/7] Add check for home-manager module --- checks.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/checks.nix b/checks.nix index 3fd6845..daa4414 100644 --- a/checks.nix +++ b/checks.nix @@ -9,8 +9,29 @@ let # this means we need to import the overlay in a hack-ish way overlays = [ (import emacs-overlay) ]; }; + 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; From bcf03a7746778f44406cc9dc5078d2940acef013 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 8 Jul 2022 19:50:45 +0100 Subject: [PATCH 3/7] Add Home-Manager checks to GH action --- .github/workflows/check-build.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 20ff4d5..2f38d6c 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -41,6 +41,36 @@ 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.*') }} + 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 check-emacsGit: name: Flake Check emacsGit (x86_64 only) runs-on: ubuntu-latest From 50363ab85b36e4d35e038f753482f16ec882854e Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 8 Jul 2022 20:02:52 +0100 Subject: [PATCH 4/7] Generate the cache hash by flake.lock --- .github/workflows/check-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 2f38d6c..593e7ff 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 @@ -58,7 +58,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 @@ -87,7 +87,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 From 057f87c90823c59a8410d17a8efc8ae2f1850794 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 8 Jul 2022 20:32:22 +0100 Subject: [PATCH 5/7] Also export cache from HM checks --- .github/workflows/check-build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/check-build.yml b/.github/workflows/check-build.yml index 593e7ff..9bb32f6 100644 --- a/.github/workflows/check-build.yml +++ b/.github/workflows/check-build.yml @@ -71,6 +71,10 @@ jobs: - 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 From 12553f419fa4a6cea9f5de4601e546d75bacf0b9 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 10 Jul 2022 19:50:21 +0100 Subject: [PATCH 6/7] Add comment about home-manager import --- checks.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/checks.nix b/checks.nix index daa4414..4811f12 100644 --- a/checks.nix +++ b/checks.nix @@ -9,6 +9,8 @@ let # 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"; From 84c37396e8a62c579221df06152d97cc8b85a107 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 10 Jul 2022 20:03:14 +0100 Subject: [PATCH 7/7] Doc align fixes --- default.nix | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/default.nix b/default.nix index 82f4bb8..5cd2cd8 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`.