diff --git a/flake.nix b/flake.nix index ce5d31c..e559440 100644 --- a/flake.nix +++ b/flake.nix @@ -311,10 +311,16 @@ in rec { }; }; + }) // rec { + + ############################## SOME GLOBAL OUTPUTS ############################## + inherit inputs self; + ############################## NIXOS MODULES ############################## - nixosModules.default = { system, lib, config, ... }: { + nixosModules.default = { system, lib, config, pkgs, ... }: { options.mize = { - debuginary = lib.mkOption { + enable = lib.mkEnableOption "enable the mize damon"; + debugBinary = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; example = "/home/user/here/mize"; @@ -337,26 +343,24 @@ in rec { }; }; - systemd.user.services.mize = { + config = lib.mkIf config.mize.enable { + systemd.user.services.mize = { description = "the mize daemon"; wantedBy = [ "default.target" ]; - After = [ "graphical-session.target" ]; - PartOf = [ "graphical-session.target" ]; # this should mean DISPLAY and WAYLAND_DISPLAY are set in the service env... environment = { - MIZE_CONFIG_FILES = let fileInStore = (pkgs.formats.toml {}).generate "mize-daemon-config.toml" config.mize.config; in if config.mize.debugConfigFile then "${config.mize.debugConfigFile}" else "${fileInStore}"; + MIZE_CONFIG_FILES = let fileInStore = (pkgs.formats.toml {}).generate "mize-daemon-config.toml" config.mize.config; in if config.mize.debugConfigFile == null then "${fileInStore}" else "${config.mize.debugConfigFile}"; }; serviceConfig = { Restart = "on-failure"; - ExecStart = if config.mize.debuginary == null then "${self.packages.${system}.mize}/bin/mize daemon" else "${config.mize.debugBinary} daemon"; + ExecStart = if config.mize.debugBinary == null then "${self.packages.${system}.mize}/bin/mize daemon" else "${config.mize.debugBinary} daemon"; + After = [ "graphical-session.target" ]; + PartOf = [ "graphical-session.target" ]; # this should mean DISPLAY and WAYLAND_DISPLAY are set in the service env... }; + }; }; }; # for what we do the nixos and home-manager api is identical homeModules.default = nixosModules.default; - }) // { - -############################## SOME GLOBAL OUTPUTS ############################## - inherit inputs self; }; } diff --git a/packages/mize/src/platform/os/cli.rs b/packages/mize/src/platform/os/cli.rs index f81456e..66b1782 100644 --- a/packages/mize/src/platform/os/cli.rs +++ b/packages/mize/src/platform/os/cli.rs @@ -68,11 +68,7 @@ pub fn mount(sub_matches: &ArgMatches) -> MizeResult<()> { pub fn daemon(sub_matches: &ArgMatches) -> MizeResult<()> { let instance = Mize::with_config(config_from_cli_args(sub_matches)?)?; - - // load all parts we need for any mize application... making a fat daemon for now. - // in the future parts should be loaded on demand (from .so files and from parts.mize.works) - ppc - + instance.wait(); return Ok(()); diff --git a/packages/mize/src/platform/os/main.rs b/packages/mize/src/platform/os/main.rs index 8f21b75..ce688d5 100644 --- a/packages/mize/src/platform/os/main.rs +++ b/packages/mize/src/platform/os/main.rs @@ -39,7 +39,7 @@ fn main() { // match command let result = match cli_matches.subcommand() { // mi daemon - Some(("daemon", sub_matches)) => cli::run(sub_matches), + Some(("daemon", sub_matches)) => cli::daemon(sub_matches), Some(("is-running", sub_matches)) => cli::is_running(sub_matches),