summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.nix4
-rw-r--r--nix/default.nix (renamed from default.nix)2
-rw-r--r--nix/hm-module.nix82
3 files changed, 86 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 380c009..7af96cc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -29,7 +29,7 @@
formatter = forAllSystems (pkgs: pkgs.alejandra);
packages = forAllSystems (pkgs: rec {
- caelestia-shell = pkgs.callPackage ./default.nix {
+ caelestia-shell = pkgs.callPackage ./nix {
rev = self.rev or self.dirtyRev;
quickshell = inputs.quickshell.packages.${pkgs.system}.default.override {
withX11 = false;
@@ -51,5 +51,7 @@
CAELESTIA_BD_PATH = "${shell}/bin/beat_detector";
};
});
+
+ homeManagerModules.default = import ./nix/hm-module.nix self;
};
}
diff --git a/default.nix b/nix/default.nix
index 25902d2..8012721 100644
--- a/default.nix
+++ b/nix/default.nix
@@ -62,7 +62,7 @@ in
stdenv.mkDerivation {
pname = "caelestia-shell";
version = "${rev}";
- src = ./.;
+ src = ./..;
nativeBuildInputs = [gcc makeWrapper];
buildInputs = [quickshell aubio pipewire];
diff --git a/nix/hm-module.nix b/nix/hm-module.nix
new file mode 100644
index 0000000..631ee4a
--- /dev/null
+++ b/nix/hm-module.nix
@@ -0,0 +1,82 @@
+self: {
+ config,
+ pkgs,
+ lib,
+ ...
+}: let
+ cli-default = self.inputs.caelestia-cli.packages.${pkgs.system}.default;
+ shell-default = self.packages.${pkgs.system}.with-cli;
+
+ cfg = config.programs.caelestia;
+in {
+ options = with lib; {
+ programs.caelestia = {
+ enable = mkEnableOption "Enable Caelestia shell";
+ package = mkOption {
+ type = types.package;
+ default = shell-default;
+ description = "The package of Caelestia shell";
+ };
+ settings = mkOption {
+ type = types.attrs;
+ default = {};
+ description = "Caelestia shell settings";
+ };
+ extraConfig = mkOption {
+ type = types.str;
+ default = "";
+ description = "Caelestia shell extra configs written to shell.json";
+ };
+ cli = {
+ enable = mkEnableOption "Enable Caelestia CLI";
+ package = mkOption {
+ type = types.package;
+ default = cli-default;
+ description = "The package of Caelestia CLI"; # Doesn't override the shell's CLI, only change from home.packages
+ };
+ };
+ };
+ };
+
+ config = let
+ cli = cfg.cli.package or cli-default;
+ shell = cfg.package or shell-default;
+ in
+ lib.mkIf cfg.enable {
+ systemd.user.services.caelestia = {
+ Unit = {
+ Description = "Caelestia Shell Service";
+ After = ["graphical-session.target"];
+ PartOf = ["graphical-session.target"];
+ };
+
+ Service = {
+ Type = "exec";
+ ExecStart = "${shell}/bin/caelestia-shell";
+ Restart = "on-failure";
+ RestartSec = "5s";
+ TimeoutStopSec = "5s";
+ Environment = [
+ "QT_QPA_PLATFORM=wayland"
+ ];
+
+ Slice = "session.slice";
+ };
+
+ Install = {
+ WantedBy = ["graphical-session.target"];
+ };
+ };
+
+ xdg.configFile."caelestia/shell.json".text = let
+ extraConfig =
+ if cfg.extraConfig != ""
+ then cfg.extraConfig
+ else "{}";
+ in
+ builtins.toJSON (lib.recursiveUpdate
+ (cfg.settings or {}) (builtins.fromJSON extraConfig));
+
+ home.packages = [shell] ++ lib.optional cfg.cli.enable cli;
+ };
+}