2024-04-28 12:26:05 +10:00
|
|
|
# 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.
|
|
|
|
|
|
2024-03-04 01:29:47 +11:00
|
|
|
{
|
|
|
|
|
inputs = {
|
2024-05-12 20:40:49 +10:00
|
|
|
# Default to reusing the system's emacs package if it has nixpkgs in the system flake registry.
|
2024-03-04 01:29:47 +11:00
|
|
|
nixpkgs.url = "nixpkgs";
|
2024-05-07 22:47:37 +10:00
|
|
|
systems.url = "github:nix-systems/default";
|
2024-03-04 01:29:47 +11:00
|
|
|
doomemacs = {
|
|
|
|
|
url = "github:doomemacs/doomemacs";
|
|
|
|
|
flake = false;
|
|
|
|
|
};
|
2024-03-18 20:52:48 +11:00
|
|
|
emacs-overlay = {
|
|
|
|
|
url = "github:nix-community/emacs-overlay";
|
|
|
|
|
inputs = {
|
2024-05-07 22:36:33 +10:00
|
|
|
# These should be unused, but let's unset them to make that explicit.
|
|
|
|
|
nixpkgs-stable.follows = "";
|
|
|
|
|
nixpkgs.follows = "";
|
2024-03-18 20:52:48 +11:00
|
|
|
};
|
|
|
|
|
};
|
2024-03-04 01:29:47 +11:00
|
|
|
};
|
|
|
|
|
|
2024-05-07 23:02:59 +10:00
|
|
|
outputs = { self, systems, doomemacs, nixpkgs, emacs-overlay, ... }: let
|
2024-05-07 22:47:37 +10:00
|
|
|
perSystemPackages = let
|
|
|
|
|
eachSystem = nixpkgs.lib.genAttrs (import systems);
|
|
|
|
|
in
|
|
|
|
|
f: eachSystem (system: f nixpkgs.legacyPackages.${system});
|
2024-05-25 20:30:33 +10:00
|
|
|
|
2024-05-11 20:35:42 +10:00
|
|
|
doomFromPackages = pkgs: args: let
|
|
|
|
|
# Hack to avoid pkgs.extend having to instantiate an additional nixpkgs.
|
|
|
|
|
#
|
|
|
|
|
# We need emacsPackagesFor from the overlay, but neither the overlay itself
|
|
|
|
|
# (it only uses "super", not "self") nor us actually needs anything overlaid
|
|
|
|
|
# on nixpkgs. So we can call the overlay and pass emacsPackagesFor through
|
|
|
|
|
# directly instead of having pkgs.callPackage do it.
|
|
|
|
|
inherit (emacs-overlay.overlays.package {} pkgs) emacsPackagesFor;
|
|
|
|
|
mergedArgs = args // {
|
|
|
|
|
inherit emacsPackagesFor;
|
|
|
|
|
doomSource = doomemacs;
|
|
|
|
|
};
|
|
|
|
|
in
|
|
|
|
|
pkgs.callPackages self mergedArgs;
|
2024-05-25 20:30:33 +10:00
|
|
|
|
|
|
|
|
toInit = let
|
|
|
|
|
inherit (nixpkgs.lib) concatLines concatStringsSep isList isString mapAttrsToList toPretty;
|
|
|
|
|
in
|
|
|
|
|
attrs:
|
|
|
|
|
concatLines (
|
|
|
|
|
[ "(doom!" ]
|
|
|
|
|
++ (mapAttrsToList (
|
|
|
|
|
cat: modules:
|
|
|
|
|
(concatLines (
|
|
|
|
|
[ (":" + cat) ]
|
|
|
|
|
++ (map (
|
|
|
|
|
mod:
|
|
|
|
|
if isString mod then mod
|
|
|
|
|
else if isList mod then "(" + (concatStringsSep " " mod) + ")"
|
|
|
|
|
else abort "${toPretty mod} not supported"
|
|
|
|
|
))
|
|
|
|
|
modules
|
|
|
|
|
))
|
|
|
|
|
) attrs)
|
|
|
|
|
++ [ ")" ]
|
|
|
|
|
);
|
|
|
|
|
|
2024-04-06 23:41:35 +11:00
|
|
|
in {
|
2024-05-25 17:41:10 +10:00
|
|
|
checks = perSystemPackages (pkgs: pkgs.callPackages ./checks.nix {
|
2024-05-25 20:30:33 +10:00
|
|
|
inherit toInit;
|
2024-05-25 17:41:10 +10:00
|
|
|
makeDoomPackages = doomFromPackages pkgs;
|
|
|
|
|
});
|
2024-05-11 21:09:54 +10:00
|
|
|
packages = perSystemPackages (pkgs: {
|
|
|
|
|
doom-example = (doomFromPackages pkgs {
|
|
|
|
|
# TODO: drop after NixOS 24.05 release.
|
|
|
|
|
emacs = pkgs.emacs29;
|
|
|
|
|
doomDir = ./doomdirs/example;
|
|
|
|
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
|
|
|
|
}).doomEmacs;
|
|
|
|
|
doom-example-without-loader = (doomFromPackages pkgs {
|
|
|
|
|
# TODO: drop after NixOS 24.05 release.
|
|
|
|
|
emacs = pkgs.emacs29;
|
|
|
|
|
doomDir = ./doomdirs/example;
|
|
|
|
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
|
|
|
|
profileName = "";
|
|
|
|
|
}).doomEmacs;
|
2024-05-19 17:48:36 +10:00
|
|
|
# TODO: cache more packages, cache for more Emacsen.
|
2024-05-26 14:56:28 +10:00
|
|
|
cachix-packages = let
|
2024-05-26 16:31:12 +10:00
|
|
|
# (Shouldn't need doomFromPackages, see doomDirWithAllModules definition)
|
2024-05-26 14:56:28 +10:00
|
|
|
fullDoomDir = (doomFromPackages pkgs {
|
|
|
|
|
doomDir = pkgs.emptyDirectory;
|
2024-05-19 17:48:36 +10:00
|
|
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
2024-05-26 16:31:12 +10:00
|
|
|
}).doomDirWithAllModules;
|
2024-05-26 14:56:28 +10:00
|
|
|
in
|
|
|
|
|
pkgs.linkFarm "unstraightened-cachix-packages" {
|
|
|
|
|
inherit doomemacs;
|
|
|
|
|
full-emacs29 = (doomFromPackages pkgs {
|
|
|
|
|
emacs = pkgs.emacs29;
|
|
|
|
|
doomDir = fullDoomDir;
|
|
|
|
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
|
|
|
|
experimentalFetchTree = true;
|
|
|
|
|
}).doomEmacs.emacsWithPackages.deps;
|
|
|
|
|
};
|
2024-05-11 21:09:54 +10:00
|
|
|
});
|
2024-05-11 20:35:42 +10:00
|
|
|
overlays.default = final: prev: {
|
|
|
|
|
doomEmacs = args: (doomFromPackages final args).doomEmacs;
|
|
|
|
|
emacsWithDoom = args: (doomFromPackages final args).emacsWithDoom;
|
|
|
|
|
};
|
2024-04-29 14:58:41 +10:00
|
|
|
hmModule = import ./home-manager.nix {
|
2024-05-11 20:35:42 +10:00
|
|
|
inherit doomFromPackages;
|
2024-04-29 14:58:41 +10:00
|
|
|
};
|
2024-03-04 01:29:47 +11:00
|
|
|
};
|
|
|
|
|
}
|