diff --git a/flake.nix b/flake.nix index 09d1238..065d573 100644 --- a/flake.nix +++ b/flake.nix @@ -18,44 +18,39 @@ nixpkgs, emacs-overlay, nix-org-babel, - }: { - packages.x86_64-linux.default = import ./package.nix { - pkgs = import nixpkgs { - system = "x86_64-linux"; + }: let + systems = ["aarch64-linux" "x86_64-linux"]; + eachSystem = nixpkgs.lib.genAttrs systems; + pkgsFor = eachSystem (system: + import nixpkgs { + localSystem = system; overlays = [ emacs-overlay.overlays.default nix-org-babel.overlays.default ]; + }); + in { + formatter = eachSystem ( + system: let + pkgs = pkgsFor.${system}; + in + pkgs.alejandra + ); + packages = eachSystem (system: let + pkgs = pkgsFor.${system}; + in { + default = import ./package.nix { + inherit pkgs; }; - }; - packages.aarch64-linux.default = import ./package.nix { - pkgs = import nixpkgs { - system = "aarch64-linux"; - overlays = [ - emacs-overlay.overlays.default - nix-org-babel.overlays.default - ]; + with-lsps = self.packages.${system}.default.override { + withLsps = true; }; - }; - packages.x86_64-linux.with-lsps = import ./package.nix { - pkgs = import nixpkgs { - system = "x86_64-linux"; - overlays = [ - emacs-overlay.overlays.default - nix-org-babel.overlays.default - ]; + native = self.packages.${system}.default.override { + native = true; }; - withLsps = true; - }; - packages.aarch64-linux.with-lsps = import ./package.nix { - pkgs = import nixpkgs { - system = "aarch64-linux"; - overlays = [ - emacs-overlay.overlays.default - nix-org-babel.overlays.default - ]; + with-lsps-native = self.packages.${system}.with-lsps.override { + native = true; }; - withLsps = true; - }; + }); }; } diff --git a/package.nix b/package.nix index 78cccfb..97f6a6a 100644 --- a/package.nix +++ b/package.nix @@ -5,10 +5,10 @@ ... }: let preTangledFile = pkgs.writeText "config.org" '' - ${builtins.readFile ./config.org} - #+begin_src emacs-lisp - (setq dashboard-startup-banner "${./nixmacs.xpm}") - #+end_src + ${builtins.readFile ./config.org} + #+begin_src emacs-lisp + (setq dashboard-startup-banner "${./nixmacs.xpm}") + #+end_src ''; configFile = pkgs.tangleOrgBabelFile "default.el" preTangledFile { languages = ["emacs-lisp"]; @@ -33,11 +33,15 @@ # }; defaultInitFile = true; # Package is optional, defaults to pkgs.emacs - package = if native then pkgs.emacs30-pgtk.overrideAttrs ( - oldAttrs: { - NIX_CFLAGS_COMPILE = builtins.toString oldAttrs.NIX_CFLAGS_COMPILE or "" + "-march=native -O3"; - } - ) else pkgs.emacs30-pgtk; + package = + if native + then + pkgs.emacs30-pgtk.overrideAttrs ( + oldAttrs: { + NIX_CFLAGS_COMPILE = builtins.toString oldAttrs.NIX_CFLAGS_COMPILE or "" + "-march=native -O3"; + } + ) + else pkgs.emacs30-pgtk; # By default emacsWithPackagesFromUsePackage will only pull in # packages with `:ensure`, `:ensure t` or `:ensure `. @@ -60,8 +64,8 @@ # Optionally provide extra packages not in the configuration file. # This can also include extra executables to be run by Emacs (linters, # language servers, formatters, etc) - extraEmacsPackages = epkgs: - (with pkgs; [ + extraEmacsPackages = epkgs: (with pkgs; + [ #nerd-fonts.jetbrains-mono #jetbrains-mono unzip @@ -69,25 +73,27 @@ imagemagick fontconfig freetype - ripgrep - vips - ffmpegthumbnailer - mediainfo - p7zip - epub-thumbnailer - poppler-utils - gzip - gnutar - ] ++ (with epkgs;[ + ripgrep + vips + ffmpegthumbnailer + mediainfo + p7zip + epub-thumbnailer + poppler-utils + gzip + gnutar + ] + ++ (with epkgs; [ tree-sitter tree-sitter-langs treesit-grammars.with-all-grammars - el-easydraw - ]) ++ lib.optionals (withLsps) [ - csharp-ls - clang-tools - cmake-language-server - nil + el-easydraw + ]) + ++ lib.optionals withLsps [ + csharp-ls + clang-tools + cmake-language-server + nil ]); # Optionally override derivations.