Skip to content

Commit 39039c4

Browse files
authored
Merge pull request #11 from Ruixi-rebirth/main
feat: add flake support
2 parents 4d48679 + 1a55178 commit 39039c4

File tree

7 files changed

+308
-0
lines changed

7 files changed

+308
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.cache
22
/.vscode
3+
/result
34
config.h
45
maomao
56
maomao.o

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,67 @@ like `MAOMAOCONFIG=/home/xxx/maomao`
9999
- the fallback config path is in `/etc/maomao/config.conf`, you can find the default config here
100100

101101

102+
# NixOS+Home-manager
103+
```nix
104+
{
105+
inputs = {
106+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
107+
home-manager = {
108+
url = "github:nix-community/home-manager";
109+
inputs.nixpkgs.follows = "nixpkgs";
110+
};
111+
flake-parts.url = "github:hercules-ci/flake-parts";
112+
maomaowm.url = "github:DreamMaoMao/maomaowm";
113+
114+
};
115+
outputs =
116+
inputs@{ self, flake-parts, ... }:
117+
flake-parts.lib.mkFlake { inherit inputs; } {
118+
debug = true;
119+
systems = [ "x86_64-linux" ];
120+
flake = {
121+
nixosConfigurations = {
122+
hostname = inputs.nixpkgs.lib.nixosSystem {
123+
system = "x86_64-linux";
124+
modules = [
125+
inputs.home-manager.nixosModules.home-manager
126+
{
127+
home-manager = {
128+
useGlobalPkgs = true;
129+
useUserPackages = true;
130+
backupFileExtension = "backup";
131+
users."username".imports =
132+
[
133+
(
134+
{ ... }:
135+
{
136+
wayland.windowManager.maomaowm = {
137+
enable = true;
138+
settings = ''
139+
# see config.conf
140+
'';
141+
autostart_sh = ''
142+
# see autostart.sh
143+
'';
144+
};
145+
}
146+
)
147+
]
148+
++ [
149+
# Add maomaowm hm module
150+
inputs.maomaowm.hmModules.maomaowm
151+
];
152+
};
153+
}
154+
];
155+
};
156+
};
157+
};
158+
};
159+
}
160+
```
161+
162+
102163
# my dotfile
103164
[maomao-config](https://github.com/DreamMaoMao/dotfile/tree/main/maomao)
104165

flake.lock

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+
flake-parts.url = "github:hercules-ci/flake-parts";
5+
treefmt-nix = {
6+
url = "github:numtide/treefmt-nix";
7+
inputs.nixpkgs.follows = "nixpkgs";
8+
};
9+
};
10+
11+
outputs =
12+
{
13+
flake-parts,
14+
treefmt-nix,
15+
...
16+
}@inputs:
17+
flake-parts.lib.mkFlake { inherit inputs; } {
18+
imports = [
19+
inputs.flake-parts.flakeModules.easyOverlay
20+
];
21+
22+
flake.hmModules.maomaowm = import ./nix/hm-modules.nix;
23+
24+
perSystem =
25+
{
26+
config,
27+
pkgs,
28+
...
29+
}:
30+
let
31+
inherit (pkgs)
32+
callPackage
33+
;
34+
maomaowm = callPackage ./nix { };
35+
shellOverride = old: {
36+
nativeBuildInputs = old.nativeBuildInputs ++ [ ];
37+
buildInputs = old.buildInputs ++ [ ];
38+
};
39+
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
40+
in
41+
{
42+
packages.default = maomaowm;
43+
overlayAttrs = {
44+
inherit (config.packages) maomaowm;
45+
};
46+
packages = {
47+
inherit maomaowm;
48+
};
49+
devShells.default = maomaowm.overrideAttrs shellOverride;
50+
formatter = treefmtEval.config.build.wrapper;
51+
};
52+
systems = [ "x86_64-linux" ];
53+
};
54+
}

nix/default.nix

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
lib,
3+
libX11,
4+
libinput,
5+
libxcb,
6+
libxkbcommon,
7+
pixman,
8+
pkg-config,
9+
stdenv,
10+
wayland,
11+
wayland-protocols,
12+
wayland-scanner,
13+
wlroots_0_17,
14+
xcbutilwm,
15+
xwayland,
16+
enableXWayland ? true,
17+
meson,
18+
ninja,
19+
}:
20+
let
21+
pname = "maomaowm";
22+
in
23+
stdenv.mkDerivation {
24+
inherit pname;
25+
version = "nightly";
26+
27+
src = ../.;
28+
29+
nativeBuildInputs = [
30+
meson
31+
ninja
32+
pkg-config
33+
wayland-scanner
34+
];
35+
36+
buildInputs =
37+
[
38+
libinput
39+
libxcb
40+
libxkbcommon
41+
pixman
42+
wayland
43+
wayland-protocols
44+
wlroots_0_17
45+
]
46+
++ lib.optionals enableXWayland [
47+
libX11
48+
xcbutilwm
49+
xwayland
50+
];
51+
52+
meta = {
53+
mainProgram = "maomao";
54+
description = "A streamlined but feature-rich Wayland compositor";
55+
homepage = "https://github.com/DreamMaoMao/maomaowm";
56+
license = lib.licenses.mit;
57+
maintainers = with lib.maintainers; [ ];
58+
platforms = lib.platforms.unix;
59+
};
60+
}

nix/hm-modules.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
lib,
3+
config,
4+
pkgs,
5+
...
6+
}:
7+
8+
let
9+
maomaowm = pkgs.callPackage ./. { };
10+
in
11+
{
12+
options = {
13+
wayland.windowManager.maomaowm = {
14+
enable = lib.mkOption {
15+
type = lib.types.bool;
16+
default = false;
17+
};
18+
19+
settings = lib.mkOption {
20+
type = lib.types.str;
21+
default = "";
22+
};
23+
24+
autostart_sh = lib.mkOption {
25+
type = lib.types.str;
26+
default = "";
27+
};
28+
};
29+
};
30+
31+
config = lib.mkIf config.wayland.windowManager.maomaowm.enable {
32+
home.packages = [ maomaowm ];
33+
34+
home.file = {
35+
".config/maomao/config.conf" = {
36+
text = config.wayland.windowManager.maomaowm.settings;
37+
};
38+
39+
".config/maomao/autostart.sh" = {
40+
text = config.wayland.windowManager.maomaowm.autostart_sh;
41+
executable = true;
42+
};
43+
};
44+
};
45+
}

treefmt.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ ... }:
2+
3+
{
4+
projectRootFile = "flake.nix";
5+
programs = {
6+
nixfmt.enable = true;
7+
};
8+
}

0 commit comments

Comments
 (0)