diff --git a/common/default.nix b/common/default.nix index 93ff389..7e4beff 100644 --- a/common/default.nix +++ b/common/default.nix @@ -32,9 +32,9 @@ nix = { # Allow deleting store files with '.' in the name - package = pkgs.nix.overrideAttrs (oldAttrs: { + package = pkgs.nix.overrideAttrs (o: { patches = - (oldAttrs.patches or []) + (o.patches or []) ++ [ ./overlays/nix/patch ]; @@ -65,7 +65,6 @@ extraArgs = "--keep-since 30d"; }; }; - environment.variables.FLAKE = lib.mkDefault "/home/matt/.nix"; services = { fwupd.enable = true; @@ -83,8 +82,13 @@ default = { imports = [ # Make the vars be the same on Nix and HM - ./vars - {vars = config.vars;} + { + options.vars = lib.mkOption { + type = lib.types.attrs; + readOnly = true; + default = config.vars; + }; + } nur.hmModules.nur @@ -109,7 +113,12 @@ home.stateVersion = mainUserConf.home.stateVersion; }; - # TODO: make user an array? + greeter = + default + // { + home.stateVersion = mainUserConf.home.stateVersion; + }; + ${mainUser} = default; }; } diff --git a/common/nix-on-droid.nix b/common/nix-on-droid.nix index 4189f53..e4024af 100644 --- a/common/nix-on-droid.nix +++ b/common/nix-on-droid.nix @@ -1,5 +1,6 @@ { config, + lib, nur, ... }: { @@ -39,8 +40,13 @@ home-manager.config = { imports = [ # Make the vars be the same on Nix and HM - ./vars - {vars = config.vars;} + { + options.vars = lib.mkOption { + type = lib.types.attrs; + readOnly = true; + default = config.vars; + }; + } nur.hmModules.nur diff --git a/common/vars/default.nix b/common/vars/default.nix index 097906a..865efff 100644 --- a/common/vars/default.nix +++ b/common/vars/default.nix @@ -2,12 +2,12 @@ config, lib, ... -}: { - options.vars = let - inherit (lib) mkOption types; - flakeDir = config.environment.variables.FLAKE; - cfg = config.vars; - in { +}: let + inherit (lib) mkOption types; + flakeDir = config.environment.variables.FLAKE; + cfg = config.vars; +in { + options.vars = { mainUser = mkOption { type = types.str; description = '' @@ -34,8 +34,7 @@ default = import ./prompt-schemes.nix cfg.promptMainColor; - # FIXME: doesn't work when passing vars to home-manager - # readOnly = true; + readOnly = true; type = with types; submodule { options = { @@ -83,4 +82,8 @@ default = true; }; }; + + config = { + environment.variables.FLAKE = lib.mkDefault "/home/${cfg.mainUser}/.nix"; + }; } diff --git a/modules/ags/default.nix b/modules/ags/default.nix index 0b1d843..56b1223 100644 --- a/modules/ags/default.nix +++ b/modules/ags/default.nix @@ -26,14 +26,7 @@ in { ... }: let symlink = config.lib.file.mkOutOfStoreSymlink; - inherit (lib) optionals; - - astalTypes = config.home.file.".local/share/io.Aylur.Astal/types"; - astalConfigDir = ".nix/modules/ags/astal"; # FIXME: figure out way to use $FLAKE - - # https://github.com/Aylur/ags/blob/e1f2d311ceb496a69ef6daa6aebb46ce511b2f22/nix/hm-module.nix#L69 - agsTypes = config.home.file.".local//share/com.github.Aylur.ags/types"; - agsConfigDir = ".nix/modules/ags/config"; # FIXME: figure out way to use $FLAKE + inherit (lib) hasPrefix mdDoc optionals removePrefix; configJs = /* @@ -44,7 +37,19 @@ in { export default (await transpileTypeScript('${hostName}')).default; ''; + + agsConfigDir = "${removePrefix "/home/${mainUser}/" flakeDir}/modules/ags"; in { + assertions = [ + { + assertion = hasPrefix "/home/${mainUser}/" flakeDir; + message = mdDoc '' + Your $FLAKE environment variable needs to point to a directory in + the main users' home to use the AGS module. + ''; + } + ]; + # Experimental Gtk4 ags programs.astal = { enable = true; @@ -58,13 +63,15 @@ in { home = { file = { + # Astal symlinks. ${./astal}, types and config.js ".config/astal".source = symlink "${flakeDir}/modules/ags/astal"; - "${astalConfigDir}/types".source = astalTypes.source; - "${astalConfigDir}/config.js".text = configJs; + "${agsConfigDir}/astal/types".source = "${config.programs.astal.finalPackage}/share/io.Aylur.Astal/types"; + "${agsConfigDir}/astal/config.js".text = configJs; + # AGS symlinks. ${./config}, types and config.js ".config/ags".source = symlink "${flakeDir}/modules/ags/config"; - "${agsConfigDir}/types".source = agsTypes.source; - "${agsConfigDir}/config.js".text = configJs; + "${agsConfigDir}/config/types".source = "${config.programs.ags.finalPackage}/share/com.github.Aylur.ags/types"; + "${agsConfigDir}/config/config.js".text = configJs; } // (import ./icons.nix {inherit pkgs agsConfigDir;}); @@ -96,15 +103,15 @@ in { ++ optionals isTouchscreen ["squeekboard"]; bind = [ - "$mainMod SHIFT, E , exec, ags -t powermenu" - "$mainMod , D , exec, ags -t applauncher" + "$mainMod SHIFT, E, exec, ags -t powermenu" + "$mainMod , D, exec, ags -t applauncher" ]; binde = [ ## Brightness control ", XF86MonBrightnessUp, exec, ags -r 'Brightness.screen += 0.05'" ", XF86MonBrightnessDown, exec, ags -r 'Brightness.screen -= 0.05'" ]; - bindn = [",Escape, exec, ags run-js 'closeAll()'"]; + bindn = [" , Escape, exec, ags -r 'closeAll()'"]; bindr = ["CAPS, Caps_Lock, exec, ags -r 'Brightness.fetchCapsState()'"]; }; }; diff --git a/modules/ags/icons.nix b/modules/ags/icons.nix index 092856b..b885efa 100644 --- a/modules/ags/icons.nix +++ b/modules/ags/icons.nix @@ -3,17 +3,17 @@ pkgs, ... }: { - "${agsConfigDir}/icons/mouse-razer-symbolic.svg".source = pkgs.fetchurl { + "${agsConfigDir}/config/icons/mouse-razer-symbolic.svg".source = pkgs.fetchurl { url = "https://raw.githubusercontent.com/bithatch/razer-icon-font/main/src/devices/mouse.svg"; hash = "sha256-A1+eIp2VEFDyY23GIHKhbnByHXrnVS3QgIJ9sjjtuZw="; }; - "${agsConfigDir}/icons/down-large-symbolic.svg".source = pkgs.fetchurl { + "${agsConfigDir}/config/icons/down-large-symbolic.svg".source = pkgs.fetchurl { url = "https://www.svgrepo.com/download/158537/down-chevron.svg"; hash = "sha256-mOfNjgZh0rt6XosKA2kpLY22lJldSS1XCphgrnvZH1s="; }; - "${agsConfigDir}/icons/nixos-logo-symbolic.svg".text = + "${agsConfigDir}/config/icons/nixos-logo-symbolic.svg".text = /* xml */ diff --git a/modules/greetd/astal.nix b/modules/greetd/astal.nix index 6c1db7b..4019ddd 100644 --- a/modules/greetd/astal.nix +++ b/modules/greetd/astal.nix @@ -16,7 +16,6 @@ in { home-manager.users.greeter = { imports = [ astal.homeManagerModules.default - ../../common/vars ../../home/theme ]; @@ -51,8 +50,5 @@ in { ''; }; }; - - vars = config.vars; - home.stateVersion = "24.05"; }; }