[emacs] Modularize more and better pkg

Attempts to select the right emacs package based on whether the machine
is x11 only or not.
This commit is contained in:
2024-09-10 17:03:04 -07:00
parent 9ba6006fca
commit 18afc61e33
6 changed files with 101 additions and 70 deletions

View File

@@ -11,7 +11,7 @@
}; };
outputs = { self, nixpkgs, ... } @ inputs: { outputs = { self, nixpkgs, ... } @ inputs: {
nixosConfigurations.z790prors-nix = nixpkgs.lib.nixosSystem { nixosConfigurations.z790prors-nix = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
./roles ./roles
@@ -20,13 +20,15 @@
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users.johno = import ./home/home-z790prors.nix; home-manager.users.johno = import ./home/home-z790prors.nix;
home-manager.extraSpecialArgs = {
customPkgs = nixpkgs.legacyPackages."${system}".callPackage ./packages {};
};
} }
]; ];
}; };
nixosConfigurations.nix-book = nixpkgs.lib.nixosSystem { nixosConfigurations.nix-book = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
./roles ./roles
@@ -35,13 +37,15 @@
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users.johno = import ./home/home-nix-book.nix; home-manager.users.johno = import ./home/home-nix-book.nix;
home-manager.extraSpecialArgs = {
customPkgs = nixpkgs.legacyPackages."${system}".callPackage ./packages {};
};
} }
]; ];
}; };
nixosConfigurations.boxy = nixpkgs.lib.nixosSystem { nixosConfigurations.boxy = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
./roles ./roles
@@ -50,8 +54,10 @@
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users.johno = import ./home/home-default.nix; home-manager.users.johno = import ./home/home-default.nix;
home-manager.extraSpecialArgs = {
customPkgs = nixpkgs.legacyPackages."${system}".callPackage ./packages {};
};
} }
]; ];
}; };

View File

@@ -1,8 +1,5 @@
{ pkgs, ... }: { pkgs, customPkgs, ... }:
let
nextcloudTalkDesktop = pkgs.callPackage ./modules/nextcloud-talk-desktop/package.nix {};
in
{ {
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
@@ -62,7 +59,7 @@ in
pkgs.wofi pkgs.wofi
pkgs.vlc pkgs.vlc
nextcloudTalkDesktop customPkgs.nextcloudTalkDesktop
]; ];
# Home Manager is pretty good at managing dotfiles. The primary way to manage # Home Manager is pretty good at managing dotfiles. The primary way to manage

View File

@@ -1,69 +1,67 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
emacs = pkgs.emacs29;
doomSync = (let doomSync = (let
git = pkgs.git; git = pkgs.git;
in '' in ''
export PATH=${emacs}/bin:${git}/bin:$PATH export PATH=${pkgs.emacs}/bin:${git}/bin:$PATH
${config.xdg.configHome}/emacs/bin/doom sync -u -j $((`nproc`/4*3)) ${config.xdg.configHome}/emacs/bin/doom sync -u -j $((`nproc`/4*3))
''); '');
in { in {
home.packages = [ config = {
pkgs.emacs-all-the-icons-fonts home.packages = [
pkgs.fontconfig pkgs.emacs-all-the-icons-fonts
pkgs.graphviz pkgs.fontconfig
pkgs.isort pkgs.graphviz
pkgs.nerdfonts pkgs.isort
pkgs.nil # nix lsp language server pkgs.nerdfonts
pkgs.nixfmt-rfc-style pkgs.nil # nix lsp language server
(pkgs.ripgrep.override {withPCRE2 = true;}) pkgs.nixfmt-rfc-style
pkgs.pipenv (pkgs.ripgrep.override {withPCRE2 = true;})
pkgs.poetry pkgs.pipenv
pkgs.python3 pkgs.poetry
]; pkgs.python3
];
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.file = { home.file = {
".config/emacs" = { ".config/emacs" = {
source = fetchGit { source = fetchGit {
url = "https://github.com/doomemacs/doomemacs.git"; url = "https://github.com/doomemacs/doomemacs.git";
# When updating me, remember to run `doom sync` # When updating me, remember to run `doom sync`
rev = "ac1122ae67d762e09fc6684945b52adff96cf1dc"; rev = "ac1122ae67d762e09fc6684945b52adff96cf1dc";
};
# We need to use recursive mode here or else doom fails to sync for
# some reason related to the permissions on the synced path. I'm not
# quite sure of everything that's going on here.
recursive = true;
# Because `recursive = true` will cause this to sync every single
# activation, we turn this off here.
#
# There's probably a way we could do better detection of this within
# our onChange shell?
#
# onChange = doomSync;
}; };
# We need to use recursive mode here or else doom fails to sync for };
# some reason related to the permissions on the synced path. I'm not
# quite sure of everything that's going on here.
recursive = true;
# Because `recursive = true` will cause this to sync every single home.sessionVariables = {
# activation, we turn this off here. DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
# EDITOR = "emacs -nw";
# There's probably a way we could do better detection of this within };
# our onChange shell?
# home.sessionPath = [
# onChange = doomSync; "${config.xdg.configHome}/emacs/bin"
];
xdg.configFile."doom" = {
source = ./doom;
# Sync doom if we updated the config
onChange = doomSync;
}; };
}; };
home.sessionVariables = {
DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
EDITOR = "emacs -nw";
};
home.sessionPath = [
"${config.xdg.configHome}/emacs/bin"
];
programs.emacs = {
enable = true;
package = emacs;
};
xdg.configFile."doom" = {
source = ./doom;
# Sync doom if we updated the config
onChange = doomSync;
};
} }

4
packages/default.nix Normal file
View File

@@ -0,0 +1,4 @@
{ pkgs, ... }:
{
nextcloudTalkDesktop = pkgs.callPackage ./nextcloud-talk-desktop {};
}

View File

@@ -4,6 +4,29 @@ with lib;
let let
cfg = config.roles.desktop; cfg = config.roles.desktop;
basePackages = with pkgs; [
];
x11BasePackages = with pkgs; [
];
x11OnlyPackages = with pkgs; [
emacs
];
waylandBasePackages = with pkgs; [
grim
slurp
wl-clipboard
mako
];
waylandOnlyPackages = with pkgs; [
emacs-gtk
];
in in
{ {
options.roles.desktop = { options.roles.desktop = {
@@ -40,12 +63,6 @@ in
programs.dconf.enable = true; programs.dconf.enable = true;
services.gnome.gnome-keyring.enable = true; services.gnome.gnome-keyring.enable = true;
environment.systemPackages = with pkgs; mkIf (!cfg.x11Only) [
grim
slurp
wl-clipboard
mako
];
programs.sway = mkIf (!cfg.x11Only) { programs.sway = mkIf (!cfg.x11Only) {
enable = true; enable = true;
wrapperFeatures.gtk = true; wrapperFeatures.gtk = true;
@@ -73,6 +90,15 @@ in
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
users.extraGroups.docker.members = [ "johno" ]; users.extraGroups.docker.members = [ "johno" ];
environment.systemPackages = with pkgs; mkMerge [
basePackages
x11BasePackages
(mkIf cfg.x11Only x11OnlyPackages)
# TODO: Do we need a "wayland only" mode?
(mkIf (!cfg.x11Only) waylandBasePackages)
(mkIf (!cfg.x11Only) waylandOnlyPackages)
];
}; };
} }