refactor: switch all mentions of flake dir to $FLAKE and fix vars readonly
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-03-26 15:32:48 -04:00
parent 3f288f3e8f
commit 9698b40420
6 changed files with 59 additions and 38 deletions

View file

@ -32,9 +32,9 @@
nix = { nix = {
# Allow deleting store files with '.' in the name # Allow deleting store files with '.' in the name
package = pkgs.nix.overrideAttrs (oldAttrs: { package = pkgs.nix.overrideAttrs (o: {
patches = patches =
(oldAttrs.patches or []) (o.patches or [])
++ [ ++ [
./overlays/nix/patch ./overlays/nix/patch
]; ];
@ -65,7 +65,6 @@
extraArgs = "--keep-since 30d"; extraArgs = "--keep-since 30d";
}; };
}; };
environment.variables.FLAKE = lib.mkDefault "/home/matt/.nix";
services = { services = {
fwupd.enable = true; fwupd.enable = true;
@ -83,8 +82,13 @@
default = { default = {
imports = [ imports = [
# Make the vars be the same on Nix and HM # 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 nur.hmModules.nur
@ -109,7 +113,12 @@
home.stateVersion = mainUserConf.home.stateVersion; home.stateVersion = mainUserConf.home.stateVersion;
}; };
# TODO: make user an array? greeter =
default
// {
home.stateVersion = mainUserConf.home.stateVersion;
};
${mainUser} = default; ${mainUser} = default;
}; };
} }

View file

@ -1,5 +1,6 @@
{ {
config, config,
lib,
nur, nur,
... ...
}: { }: {
@ -39,8 +40,13 @@
home-manager.config = { home-manager.config = {
imports = [ imports = [
# Make the vars be the same on Nix and HM # 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 nur.hmModules.nur

View file

@ -2,12 +2,12 @@
config, config,
lib, lib,
... ...
}: { }: let
options.vars = let inherit (lib) mkOption types;
inherit (lib) mkOption types; flakeDir = config.environment.variables.FLAKE;
flakeDir = config.environment.variables.FLAKE; cfg = config.vars;
cfg = config.vars; in {
in { options.vars = {
mainUser = mkOption { mainUser = mkOption {
type = types.str; type = types.str;
description = '' description = ''
@ -34,8 +34,7 @@
default = import ./prompt-schemes.nix cfg.promptMainColor; default = import ./prompt-schemes.nix cfg.promptMainColor;
# FIXME: doesn't work when passing vars to home-manager readOnly = true;
# readOnly = true;
type = with types; type = with types;
submodule { submodule {
options = { options = {
@ -83,4 +82,8 @@
default = true; default = true;
}; };
}; };
config = {
environment.variables.FLAKE = lib.mkDefault "/home/${cfg.mainUser}/.nix";
};
} }

View file

@ -26,14 +26,7 @@ in {
... ...
}: let }: let
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
inherit (lib) optionals; inherit (lib) hasPrefix mdDoc optionals removePrefix;
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
configJs = configJs =
/* /*
@ -44,7 +37,19 @@ in {
export default (await transpileTypeScript('${hostName}')).default; export default (await transpileTypeScript('${hostName}')).default;
''; '';
agsConfigDir = "${removePrefix "/home/${mainUser}/" flakeDir}/modules/ags";
in { 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 # Experimental Gtk4 ags
programs.astal = { programs.astal = {
enable = true; enable = true;
@ -58,13 +63,15 @@ in {
home = { home = {
file = file =
{ {
# Astal symlinks. ${./astal}, types and config.js
".config/astal".source = symlink "${flakeDir}/modules/ags/astal"; ".config/astal".source = symlink "${flakeDir}/modules/ags/astal";
"${astalConfigDir}/types".source = astalTypes.source; "${agsConfigDir}/astal/types".source = "${config.programs.astal.finalPackage}/share/io.Aylur.Astal/types";
"${astalConfigDir}/config.js".text = configJs; "${agsConfigDir}/astal/config.js".text = configJs;
# AGS symlinks. ${./config}, types and config.js
".config/ags".source = symlink "${flakeDir}/modules/ags/config"; ".config/ags".source = symlink "${flakeDir}/modules/ags/config";
"${agsConfigDir}/types".source = agsTypes.source; "${agsConfigDir}/config/types".source = "${config.programs.ags.finalPackage}/share/com.github.Aylur.ags/types";
"${agsConfigDir}/config.js".text = configJs; "${agsConfigDir}/config/config.js".text = configJs;
} }
// (import ./icons.nix {inherit pkgs agsConfigDir;}); // (import ./icons.nix {inherit pkgs agsConfigDir;});
@ -96,15 +103,15 @@ in {
++ optionals isTouchscreen ["squeekboard"]; ++ optionals isTouchscreen ["squeekboard"];
bind = [ bind = [
"$mainMod SHIFT, E , exec, ags -t powermenu" "$mainMod SHIFT, E, exec, ags -t powermenu"
"$mainMod , D , exec, ags -t applauncher" "$mainMod , D, exec, ags -t applauncher"
]; ];
binde = [ binde = [
## Brightness control ## Brightness control
", XF86MonBrightnessUp, exec, ags -r 'Brightness.screen += 0.05'" ", XF86MonBrightnessUp, exec, ags -r 'Brightness.screen += 0.05'"
", XF86MonBrightnessDown, 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()'"]; bindr = ["CAPS, Caps_Lock, exec, ags -r 'Brightness.fetchCapsState()'"];
}; };
}; };

View file

@ -3,17 +3,17 @@
pkgs, 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"; url = "https://raw.githubusercontent.com/bithatch/razer-icon-font/main/src/devices/mouse.svg";
hash = "sha256-A1+eIp2VEFDyY23GIHKhbnByHXrnVS3QgIJ9sjjtuZw="; 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"; url = "https://www.svgrepo.com/download/158537/down-chevron.svg";
hash = "sha256-mOfNjgZh0rt6XosKA2kpLY22lJldSS1XCphgrnvZH1s="; hash = "sha256-mOfNjgZh0rt6XosKA2kpLY22lJldSS1XCphgrnvZH1s=";
}; };
"${agsConfigDir}/icons/nixos-logo-symbolic.svg".text = "${agsConfigDir}/config/icons/nixos-logo-symbolic.svg".text =
/* /*
xml xml
*/ */

View file

@ -16,7 +16,6 @@ in {
home-manager.users.greeter = { home-manager.users.greeter = {
imports = [ imports = [
astal.homeManagerModules.default astal.homeManagerModules.default
../../common/vars
../../home/theme ../../home/theme
]; ];
@ -51,8 +50,5 @@ in {
''; '';
}; };
}; };
vars = config.vars;
home.stateVersion = "24.05";
}; };
} }