mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
glance: add darwin support
This commit is contained in:
@@ -74,15 +74,31 @@ in
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.glance" pkgs lib.platforms.linux)
|
||||
];
|
||||
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."glance/glance.yml".source = settingsFile;
|
||||
xdg.configFile."glance/glance.yml" = {
|
||||
source = settingsFile;
|
||||
onChange = mkIf pkgs.stdenv.hostPlatform.isDarwin ''
|
||||
/bin/launchctl kickstart -k "gui/$(id -u)/org.nix-community.home.glance" 2>/dev/null || true
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.user.services.glance = lib.mkIf (cfg.package != null) {
|
||||
launchd.agents.glance = mkIf (cfg.package != null) {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [
|
||||
(getExe cfg.package)
|
||||
"--config"
|
||||
configFilePath
|
||||
];
|
||||
RunAtLoad = true;
|
||||
KeepAlive = true;
|
||||
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/glance.err";
|
||||
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/glance.log";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.glance = mkIf (cfg.package != null) {
|
||||
Unit = {
|
||||
Description = "Glance feed dashboard server";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
services.glance.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
configFile=home-files/.config/glance/glance.yml
|
||||
serviceFile=home-files/.config/systemd/user/glance.service
|
||||
serviceFile=$(normalizeStorePaths $serviceFile)
|
||||
|
||||
assertFileContent $configFile ${./glance-default-config.yml}
|
||||
assertFileContent $serviceFile ${./glance.service}
|
||||
'';
|
||||
nmt.script = lib.mkMerge [
|
||||
''
|
||||
configFile=home-files/.config/glance/glance.yml
|
||||
assertFileContent $configFile ${./glance-default-config.yml}
|
||||
''
|
||||
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux ''
|
||||
serviceFile=home-files/.config/systemd/user/glance.service
|
||||
serviceFile=$(normalizeStorePaths $serviceFile)
|
||||
assertFileContent $serviceFile ${./glance.service}
|
||||
'')
|
||||
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin ''
|
||||
serviceFile=LaunchAgents/org.nix-community.home.glance.plist
|
||||
serviceFile=$(normalizeStorePaths $serviceFile)
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileContent "$serviceFile" ${./glance.plist}
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
{
|
||||
glance-default-settings = ./default-settings.nix;
|
||||
glance-example-settings = ./example-settings.nix;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
services.glance = {
|
||||
enable = true;
|
||||
@@ -23,12 +24,21 @@
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
configFile=home-files/.config/glance/glance.yml
|
||||
serviceFile=home-files/.config/systemd/user/glance.service
|
||||
serviceFile=$(normalizeStorePaths $serviceFile)
|
||||
|
||||
assertFileContent $configFile ${./glance-example-config.yml}
|
||||
assertFileContent $serviceFile ${./glance.service}
|
||||
'';
|
||||
nmt.script = lib.mkMerge [
|
||||
''
|
||||
configFile=home-files/.config/glance/glance.yml
|
||||
assertFileContent $configFile ${./glance-example-config.yml}
|
||||
''
|
||||
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux ''
|
||||
serviceFile=home-files/.config/systemd/user/glance.service
|
||||
serviceFile=$(normalizeStorePaths $serviceFile)
|
||||
assertFileContent $serviceFile ${./glance.service}
|
||||
'')
|
||||
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin ''
|
||||
serviceFile=LaunchAgents/org.nix-community.home.glance.plist
|
||||
serviceFile=$(normalizeStorePaths $serviceFile)
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileContent "$serviceFile" ${./glance.plist}
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
||||
22
tests/modules/services/glance/glance.plist
Normal file
22
tests/modules/services/glance/glance.plist
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
<key>Label</key>
|
||||
<string>org.nix-community.home.glance</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/bin/sh</string>
|
||||
<string>-c</string>
|
||||
<string>/bin/wait4path /nix/store && exec /nix/store/00000000000000000000000000000000-glance/bin/glance --config /home/hm-user/.config/glance/glance.yml</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/home/hm-user/Library/Logs/glance.err</string>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/home/hm-user/Library/Logs/glance.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user