mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-02 23:21:02 +01:00
tests/emacs: reorganize darwin and linux
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
e9bde7692e
commit
c283a23ef6
21 changed files with 14 additions and 15 deletions
9
tests/modules/services/emacs/linux/default.nix
Normal file
9
tests/modules/services/emacs/linux/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
emacs-service-27 = ./emacs-service-27.nix;
|
||||
emacs-service-28 = ./emacs-service-28.nix;
|
||||
emacs-service-28-after-graphical-session-target = ./emacs-service-28-after-graphical-session-target.nix;
|
||||
emacs-socket-27 = ./emacs-socket-27.nix;
|
||||
emacs-socket-28 = ./emacs-socket-28.nix;
|
||||
emacs-default-editor = ./emacs-default-editor.nix;
|
||||
emacs-socket-and-startWithUserSession = ./emacs-socket-and-startWithUserSession.nix;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
[Desktop Entry]
|
||||
Categories=Development;TextEditor;
|
||||
Comment=Edit text
|
||||
Exec=@emacs@/bin/emacsclient -c %F
|
||||
GenericName=Text Editor
|
||||
Icon=emacs
|
||||
Keywords=Text;Editor;
|
||||
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
|
||||
Name=Emacs Client
|
||||
StartupWMClass=Emacs
|
||||
Terminal=false
|
||||
Type=Application
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
[Desktop Entry]
|
||||
Categories=Development;TextEditor;
|
||||
Comment=Edit text
|
||||
Exec=@emacs@/bin/emacsclient -c %F
|
||||
GenericName=Text Editor
|
||||
Icon=emacs
|
||||
Keywords=Text;Editor;
|
||||
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
|
||||
Name=Emacs Client
|
||||
StartupWMClass=Emacsd
|
||||
Terminal=false
|
||||
Type=Application
|
||||
22
tests/modules/services/emacs/linux/emacs-default-editor.nix
Normal file
22
tests/modules/services/emacs/linux/emacs-default-editor.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
# Use `cat` instead of `echo` to prevent arguments from being
|
||||
# interpreted as an option.
|
||||
emacs = pkgs.writeShellScriptBin "emacsclient" ''${pkgs.coreutils}/bin/cat <<< "$*"'';
|
||||
})
|
||||
];
|
||||
|
||||
services.emacs = {
|
||||
defaultEditor = true;
|
||||
enable = true;
|
||||
};
|
||||
|
||||
nmt.script = "source ${
|
||||
pkgs.replaceVars ./emacs-default-editor.sh {
|
||||
inherit (pkgs) coreutils;
|
||||
}
|
||||
}";
|
||||
}
|
||||
18
tests/modules/services/emacs/linux/emacs-default-editor.sh
Normal file
18
tests/modules/services/emacs/linux/emacs-default-editor.sh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
set +u
|
||||
source $TESTED/home-path/etc/profile.d/hm-session-vars.sh
|
||||
set -u
|
||||
|
||||
check_arguments () {
|
||||
if [ "$1" != "$2" ]; then
|
||||
@coreutils@/bin/cat <<- EOF
|
||||
Expected arguments:
|
||||
$1
|
||||
but got:
|
||||
$2
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_arguments "--create-frame" "$($EDITOR)"
|
||||
check_arguments "foo bar baz" "$($EDITOR foo bar baz)"
|
||||
45
tests/modules/services/emacs/linux/emacs-service-27.nix
Normal file
45
tests/modules/services/emacs/linux/emacs-service-27.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(self: super: rec {
|
||||
emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // {
|
||||
outPath = "@emacs@";
|
||||
};
|
||||
emacsPackagesFor =
|
||||
_:
|
||||
lib.makeScope super.newScope (_: {
|
||||
emacsWithPackages = _: emacs;
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
programs.emacs.enable = true;
|
||||
services.emacs.enable = true;
|
||||
services.emacs.client.enable = true;
|
||||
services.emacs.extraOptions = [
|
||||
"-f"
|
||||
"exwm-enable"
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/systemd/user/emacs.socket
|
||||
assertFileExists home-files/.config/systemd/user/emacs.service
|
||||
assertFileExists home-path/share/applications/emacsclient.desktop
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.service \
|
||||
${pkgs.substitute {
|
||||
src = ./emacs-service-emacs.service;
|
||||
substitutions = [
|
||||
"--replace"
|
||||
"@runtimeShell@"
|
||||
pkgs.runtimeShell
|
||||
];
|
||||
}}
|
||||
|
||||
assertFileContent \
|
||||
home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-27-emacsclient.desktop}
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(self: super: rec {
|
||||
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.2" "" // {
|
||||
outPath = "@emacs@";
|
||||
};
|
||||
emacsPackagesFor =
|
||||
_:
|
||||
lib.makeScope super.newScope (_: {
|
||||
emacsWithPackages = _: emacs;
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
programs.emacs.enable = true;
|
||||
services.emacs.enable = true;
|
||||
services.emacs.client.enable = true;
|
||||
services.emacs.extraOptions = [
|
||||
"-f"
|
||||
"exwm-enable"
|
||||
];
|
||||
services.emacs.startWithUserSession = "graphical";
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/systemd/user/emacs.socket
|
||||
assertFileExists home-files/.config/systemd/user/emacs.service
|
||||
assertFileExists home-path/share/applications/emacsclient.desktop
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.service \
|
||||
${pkgs.substitute {
|
||||
src = ./emacs-service-emacs-after-graphical-session-target.service;
|
||||
substitutions = [
|
||||
"--replace"
|
||||
"@runtimeShell@"
|
||||
pkgs.runtimeShell
|
||||
];
|
||||
}}
|
||||
|
||||
assertFileContent \
|
||||
home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-28-emacsclient.desktop}
|
||||
'';
|
||||
}
|
||||
47
tests/modules/services/emacs/linux/emacs-service-28.nix
Normal file
47
tests/modules/services/emacs/linux/emacs-service-28.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
nixpkgs.overlays = [
|
||||
(self: super: rec {
|
||||
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.0.5" "" // {
|
||||
outPath = "@emacs@";
|
||||
};
|
||||
emacsPackagesFor =
|
||||
_:
|
||||
lib.makeScope super.newScope (_: {
|
||||
emacsWithPackages = _: emacs;
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
programs.emacs.enable = true;
|
||||
services.emacs.enable = true;
|
||||
services.emacs.client.enable = true;
|
||||
services.emacs.extraOptions = [
|
||||
"-f"
|
||||
"exwm-enable"
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/systemd/user/emacs.socket
|
||||
assertFileExists home-files/.config/systemd/user/emacs.service
|
||||
assertFileExists home-path/share/applications/emacsclient.desktop
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.service \
|
||||
${pkgs.substitute {
|
||||
src = ./emacs-service-emacs.service;
|
||||
substitutions = [
|
||||
"--replace"
|
||||
"@runtimeShell@"
|
||||
pkgs.runtimeShell
|
||||
];
|
||||
}}
|
||||
|
||||
assertFileContent \
|
||||
home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-28-emacsclient.desktop}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon -f exwm-enable"
|
||||
Restart=on-failure
|
||||
SuccessExitStatus=15
|
||||
Type=notify
|
||||
|
||||
[Unit]
|
||||
After=graphical-session.target
|
||||
Description=Emacs text editor
|
||||
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
|
||||
PartOf=graphical-session.target
|
||||
X-RestartIfChanged=false
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
[Install]
|
||||
WantedBy=default.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon -f exwm-enable"
|
||||
Restart=on-failure
|
||||
SuccessExitStatus=15
|
||||
Type=notify
|
||||
|
||||
[Unit]
|
||||
Description=Emacs text editor
|
||||
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
|
||||
X-RestartIfChanged=false
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
[Service]
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon=%t/emacs/server -f exwm-enable"
|
||||
ExecStartPost=@coreutils@/bin/chmod --changes -w %t/emacs
|
||||
ExecStopPost=@coreutils@/bin/chmod --changes +w %t/emacs
|
||||
Restart=on-failure
|
||||
SuccessExitStatus=15
|
||||
Type=notify
|
||||
|
||||
[Unit]
|
||||
Description=Emacs text editor
|
||||
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
|
||||
RefuseManualStart=true
|
||||
X-RestartIfChanged=false
|
||||
55
tests/modules/services/emacs/linux/emacs-socket-27.nix
Normal file
55
tests/modules/services/emacs/linux/emacs-socket-27.nix
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
nixpkgs.overlays = [
|
||||
(self: super: rec {
|
||||
emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // {
|
||||
outPath = "@emacs@";
|
||||
};
|
||||
emacsPackagesFor =
|
||||
_:
|
||||
lib.makeScope super.newScope (_: {
|
||||
emacsWithPackages = _: emacs;
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
programs.emacs.enable = true;
|
||||
services.emacs.enable = true;
|
||||
services.emacs.client.enable = true;
|
||||
services.emacs.extraOptions = [
|
||||
"-f"
|
||||
"exwm-enable"
|
||||
];
|
||||
services.emacs.socketActivation.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/systemd/user/emacs.socket
|
||||
assertFileExists home-files/.config/systemd/user/emacs.service
|
||||
assertFileExists home-path/share/applications/emacsclient.desktop
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.socket \
|
||||
${./emacs-socket-emacs.socket}
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.service \
|
||||
${pkgs.substitute {
|
||||
src = ./emacs-socket-27-emacs.service;
|
||||
substitutions = [
|
||||
"--replace"
|
||||
"@runtimeShell@"
|
||||
pkgs.runtimeShell
|
||||
"--replace"
|
||||
"@coreutils@"
|
||||
pkgs.coreutils
|
||||
];
|
||||
}}
|
||||
|
||||
assertFileContent \
|
||||
home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-27-emacsclient.desktop}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[Service]
|
||||
ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon=%t/emacs/server -f exwm-enable"
|
||||
Restart=on-failure
|
||||
SuccessExitStatus=15
|
||||
Type=notify
|
||||
|
||||
[Unit]
|
||||
Description=Emacs text editor
|
||||
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
|
||||
X-RestartIfChanged=false
|
||||
52
tests/modules/services/emacs/linux/emacs-socket-28.nix
Normal file
52
tests/modules/services/emacs/linux/emacs-socket-28.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
nixpkgs.overlays = [
|
||||
(self: super: rec {
|
||||
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.0.5" "" // {
|
||||
outPath = "@emacs@";
|
||||
};
|
||||
emacsPackagesFor =
|
||||
_:
|
||||
lib.makeScope super.newScope (_: {
|
||||
emacsWithPackages = _: emacs;
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
programs.emacs.enable = true;
|
||||
services.emacs.enable = true;
|
||||
services.emacs.client.enable = true;
|
||||
services.emacs.extraOptions = [
|
||||
"-f"
|
||||
"exwm-enable"
|
||||
];
|
||||
services.emacs.socketActivation.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/systemd/user/emacs.socket
|
||||
assertFileExists home-files/.config/systemd/user/emacs.service
|
||||
assertFileExists home-path/share/applications/emacsclient.desktop
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.socket \
|
||||
${./emacs-socket-emacs.socket}
|
||||
|
||||
assertFileContent \
|
||||
home-files/.config/systemd/user/emacs.service \
|
||||
${pkgs.substitute {
|
||||
src = ./emacs-socket-28-emacs.service;
|
||||
substitutions = [
|
||||
"--replace"
|
||||
"@runtimeShell@"
|
||||
pkgs.runtimeShell
|
||||
];
|
||||
}}
|
||||
|
||||
assertFileContent \
|
||||
home-path/share/applications/emacsclient.desktop \
|
||||
${./emacs-28-emacsclient.desktop}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
services.emacs = {
|
||||
enable = true;
|
||||
socketActivation.enable = true;
|
||||
startWithUserSession = true;
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: rec {
|
||||
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.0.5" "" // {
|
||||
outPath = "@emacs@";
|
||||
};
|
||||
emacsPackagesFor =
|
||||
_:
|
||||
lib.makeScope super.newScope (_: {
|
||||
emacsWithPackages = _: emacs;
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.config/systemd/user/emacs.service \
|
||||
"WantedBy=default.target"
|
||||
'';
|
||||
}
|
||||
14
tests/modules/services/emacs/linux/emacs-socket-emacs.socket
Normal file
14
tests/modules/services/emacs/linux/emacs-socket-emacs.socket
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[Install]
|
||||
RequiredBy=emacs.service
|
||||
WantedBy=sockets.target
|
||||
|
||||
[Socket]
|
||||
DirectoryMode=0700
|
||||
FileDescriptorName=server
|
||||
FlushPending=true
|
||||
ListenStream=%t/emacs/server
|
||||
SocketMode=0600
|
||||
|
||||
[Unit]
|
||||
Description=Emacs text editor
|
||||
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
|
||||
Loading…
Add table
Add a link
Reference in a new issue