mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-03 06:46:38 -04:00
feat: add flake support
This commit is contained in:
parent
fb990c196d
commit
c983ac8a44
8 changed files with 362 additions and 7 deletions
64
nix/default.nix
Normal file
64
nix/default.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
lib,
|
||||
libX11,
|
||||
libinput,
|
||||
libxcb,
|
||||
libxkbcommon,
|
||||
pixman,
|
||||
pkg-config,
|
||||
stdenv,
|
||||
wayland,
|
||||
wayland-protocols,
|
||||
wayland-scanner,
|
||||
wlroots_0_17,
|
||||
xcbutilwm,
|
||||
xwayland,
|
||||
enableXWayland ? true,
|
||||
meson,
|
||||
ninja,
|
||||
}:
|
||||
let
|
||||
pname = "maomaowm";
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
inherit pname;
|
||||
version = "nightly";
|
||||
|
||||
src = ../.;
|
||||
|
||||
patches = [
|
||||
./install-config-to-etc.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
wayland-scanner
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
[
|
||||
libinput
|
||||
libxcb
|
||||
libxkbcommon
|
||||
pixman
|
||||
wayland
|
||||
wayland-protocols
|
||||
wlroots_0_17
|
||||
]
|
||||
++ lib.optionals enableXWayland [
|
||||
libX11
|
||||
xcbutilwm
|
||||
xwayland
|
||||
];
|
||||
|
||||
meta = {
|
||||
mainProgram = "maomao";
|
||||
description = "A streamlined but feature-rich Wayland compositor";
|
||||
homepage = "https://github.com/DreamMaoMao/maomaowm";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ ];
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
}
|
||||
47
nix/hm-modules.nix
Normal file
47
nix/hm-modules.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
maomaowm = pkgs.callPackage ./. { };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
wayland.windowManager.maomaowm = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
};
|
||||
|
||||
autostart_sh = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.wayland.windowManager.maomaowm.enable {
|
||||
home.packages = [ maomaowm ];
|
||||
|
||||
home.file =
|
||||
lib.optionalAttrs (config.wayland.windowManager.maomaowm.settings != "") {
|
||||
".config/maomao/config.conf" = {
|
||||
text = config.wayland.windowManager.maomaowm.settings;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (config.wayland.windowManager.maomaowm.autostart_sh != "") {
|
||||
".config/maomao/autostart.sh" = {
|
||||
text = config.wayland.windowManager.maomaowm.autostart_sh;
|
||||
executable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
45
nix/install-config-to-etc.patch
Normal file
45
nix/install-config-to-etc.patch
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
diff --git a/meson.build b/meson.build
|
||||
index eeec918..e0de85a 100644
|
||||
--- a/meson.build
|
||||
+++ b/meson.build
|
||||
@@ -4,6 +4,10 @@ project('maomao', ['c', 'cpp'],
|
||||
|
||||
subdir('protocols')
|
||||
|
||||
+sysconfdir = get_option('sysconfdir')
|
||||
+prefix = get_option('prefix')
|
||||
+add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c')
|
||||
+
|
||||
# fs = import('fs')
|
||||
#
|
||||
# # 获取用户的主目录
|
||||
@@ -68,8 +72,7 @@ executable('maomao',
|
||||
c_args : c_args
|
||||
)
|
||||
|
||||
-prefix = get_option('prefix')
|
||||
desktop_install_dir = join_paths(prefix, 'share/wayland-sessions')
|
||||
install_data('maomao.desktop', install_dir : desktop_install_dir)
|
||||
-install_data('config.conf', install_dir : '/etc/maomao')
|
||||
+install_data('config.conf', install_dir : join_paths(sysconfdir, 'maomao'))
|
||||
|
||||
diff --git a/parse_config.h b/parse_config.h
|
||||
index 395251d..e241f00 100644
|
||||
--- a/parse_config.h
|
||||
+++ b/parse_config.h
|
||||
@@ -1024,7 +1024,7 @@ void parse_config(void) {
|
||||
// 检查文件是否存在
|
||||
if (access(filename, F_OK) != 0) {
|
||||
// 如果文件不存在,则使用 /etc/maomao/config.conf
|
||||
- snprintf(filename, sizeof(filename), "/etc/maomao/config.conf");
|
||||
+ snprintf(filename, sizeof(filename), "%s/maomao/config.conf", SYSCONFDIR);
|
||||
}
|
||||
} else {
|
||||
// 使用 MAOMAOCONFIG 环境变量作为配置文件夹路径
|
||||
@@ -1049,4 +1049,4 @@ void reload_config(const Arg *arg) {
|
||||
}
|
||||
}
|
||||
arrange(selmon, false);
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+}
|
||||
Loading…
Add table
Add a link
Reference in a new issue