diff --git a/flake.lock b/flake.lock index 11a8651..33bff6b 100644 --- a/flake.lock +++ b/flake.lock @@ -180,6 +180,26 @@ "type": "gitlab" } }, + "helpers": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1788016189, + "narHash": "sha256-O57BYyiEsgdQAluguEWMQtkog5puR2JjUx4+A1br7Q0=", + "ref": "refs/heads/main", + "rev": "6bb0221b270bf8a54c4efe646e8ec39d74e55f9f", + "revCount": 4, + "type": "git", + "url": "https://git.greyweather.dev/greyweather/nix-helper-flake" + }, + "original": { + "type": "git", + "url": "https://git.greyweather.dev/greyweather/nix-helper-flake" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -315,6 +335,7 @@ "inputs": { "firefox-addons": "firefox-addons", "flake-parts": "flake-parts", + "helpers": "helpers", "home-manager": "home-manager", "import-tree": "import-tree", "nh": "nh", diff --git a/flake.nix b/flake.nix index 9478c00..0e57d33 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,11 @@ import-tree.url = "github:vic/import-tree"; + helpers = { + url = "git+https://git.greyweather.dev/greyweather/nix-helper-flake"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + #nixpkgs-mesa-overlay.url = "github:nixos/nixpkgs/e4f9df8a27c2b4871c665368e65bdb6852dd93e6"; home-manager = { diff --git a/modules/components/shells/noctalia.nix b/modules/components/shells/noctalia.nix index a3949c5..434e514 100644 --- a/modules/components/shells/noctalia.nix +++ b/modules/components/shells/noctalia.nix @@ -9,14 +9,14 @@ home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) ({ lib, config, ... }: { home.activation = { - symlinkNoctaliaState = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".local/state/noctalia/settings.toml"; - source = "dotfiles/${config.info.hostName}/noctalia/settings.toml"; + symlinkNoctaliaState = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.users.grey.homeDir}/.local/state/noctalia/settings.toml"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/noctalia/settings.toml"; }); - symlinkNoctaliaStatePlugins = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".local/state/noctalia/plugins"; - source = "dotfiles/${config.info.hostName}/noctalia/plugins"; + symlinkNoctaliaStatePlugins = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.users.grey.homeDir}/.local/state/noctalia/plugins"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/noctalia/plugins"; isDir = true; }); }; diff --git a/modules/components/window-managers/niri.nix b/modules/components/window-managers/niri.nix index 632f968..7150017 100644 --- a/modules/components/window-managers/niri.nix +++ b/modules/components/window-managers/niri.nix @@ -38,9 +38,9 @@ }; home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) ({ lib, config, ... }: { - home.activation.symlinkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/niri/config.kdl"; - source = "dotfiles/${config.info.hostName}/niri.kdl"; + home.activation.symlinkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.users.grey.homeDir}/.config/niri/config.kdl"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/niri.kdl"; }); }); }; diff --git a/modules/features/applications/cli/fastfetch.nix b/modules/features/applications/cli/fastfetch.nix index a731cc4..556fbe0 100644 --- a/modules/features/applications/cli/fastfetch.nix +++ b/modules/features/applications/cli/fastfetch.nix @@ -2,13 +2,7 @@ flake.nixosModules.global = { pkgs, lib, config, ... }: { options.features.applications.cli.fastfetch.enable = lib.mkEnableOption "fastfetch"; - config = let - mkIfElse = with lib; p: yes: no: - mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.cli.fastfetch.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.cli.fastfetch.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.cli.fastfetch.enable = lib.mkDefault true; } { environment.systemPackages = [ pkgs.fastfetch ]; diff --git a/modules/features/applications/gui/equibop.nix b/modules/features/applications/gui/equibop.nix index fb3028f..5f6edc7 100644 --- a/modules/features/applications/gui/equibop.nix +++ b/modules/features/applications/gui/equibop.nix @@ -2,12 +2,7 @@ flake.nixosModules.graphics = { pkgs, lib, config, ...}: { options.features.applications.gui.equibop.enable = lib.mkEnableOption "equibop"; - config = let - mkIfElse = with lib; p: yes: no: mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.gui.equibop.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.gui.equibop.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.equibop.enable = lib.mkDefault true; } { environment.systemPackages = [ pkgs.equibop ]; @@ -21,19 +16,19 @@ programs.equibop.enable = true; home.activation = { - linkEquibopConfigSettings = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/equibop/settings.json"; - source = "dotfiles/${config.info.hostName}/equibop/settings.json"; + linkEquibopConfigSettings = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.home.homeDirectory}/.config/equibop/settings.json"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/equibop/settings.json"; }); - linkEquibopConfigEquicordSettings = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/equibop/settings/settings.json"; - source = "dotfiles/${config.info.hostName}/equibop/equicord-settings.json"; + linkEquibopConfigEquicordSettings = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.home.homeDirectory}/.config/equibop/settings/settings.json"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/equibop/equicord-settings.json"; }); - linkEquibopConfigQuickCss = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/equibop/settings/quickCss.css"; - source = "dotfiles/${config.info.hostName}/equibop/quickCss.css"; + linkEquibopConfigQuickCss = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.home.homeDirectory}/.config/equibop/settings/quickCss.css"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/equibop/quickCss.css"; }); }; }; diff --git a/modules/features/applications/gui/floorp.nix b/modules/features/applications/gui/floorp.nix index 0365c6d..f267256 100644 --- a/modules/features/applications/gui/floorp.nix +++ b/modules/features/applications/gui/floorp.nix @@ -2,12 +2,7 @@ flake.nixosModules.graphics = { pkgs, lib, config, ... }: { options.features.applications.gui.floorp.enable = lib.mkEnableOption "floorp"; - config = let - mkIfElse = with lib; p: yes: no: mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.gui.floorp.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.gui.floorp.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.floorp.enable = lib.mkDefault true; } { environment.systemPackages = [ pkgs.floorp-bin ]; diff --git a/modules/features/applications/gui/fluxer.nix b/modules/features/applications/gui/fluxer.nix index e2007a7..5cb1e4b 100644 --- a/modules/features/applications/gui/fluxer.nix +++ b/modules/features/applications/gui/fluxer.nix @@ -63,11 +63,6 @@ platforms = [ "x86_64-linux" ]; }; }; - mkIfElse = with lib; p: yes: no: - mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; in { flake.nixosModules.graphics = { pkgs, config, lib, ... }: { options.features.applications.gui = { @@ -75,13 +70,13 @@ in { fluxer-canary.enable = lib.mkEnableOption "fluxer-canary"; }; - config = lib.mkIf (config.features.applications.gui.fluxer.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.gui.fluxer.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.fluxer.enable = lib.mkDefault true; } { environment.systemPackages = [ (pkgs.callPackage (fluxer-package) {}) ]; - }) // lib.mkIf (config.features.applications.gui.fluxer-canary.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + }) // lib.mkIf (config.features.applications.gui.fluxer-canary.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.fluxer-canary.enable = lib.mkDefault true; } { environment.systemPackages = [ diff --git a/modules/features/applications/gui/kitty.nix b/modules/features/applications/gui/kitty.nix index cce4fc0..bc12c5f 100644 --- a/modules/features/applications/gui/kitty.nix +++ b/modules/features/applications/gui/kitty.nix @@ -3,11 +3,7 @@ options.features.applications.gui.kitty.enable = lib.mkEnableOption "kitty"; config = let - mkIfElse = with lib; p: yes: no: mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.gui.kitty.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + in lib.mkIf (config.features.applications.gui.kitty.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.kitty.enable = lib.mkDefault true; } { environment.systemPackages = [ pkgs.kitty ]; diff --git a/modules/features/applications/gui/remmina.nix b/modules/features/applications/gui/remmina.nix index fc596d6..8cb5b7a 100644 --- a/modules/features/applications/gui/remmina.nix +++ b/modules/features/applications/gui/remmina.nix @@ -2,13 +2,7 @@ flake.nixosModules.graphics = { pkgs, config, lib, ... }: { options.features.applications.gui.remmina.enable = lib.mkEnableOption "remmina"; - config = let - mkIfElse = with lib; p: yes: no: - mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.gui.remmina.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.gui.remmina.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.remmina.enable = lib.mkDefault true; } { environment.systemPackages = with pkgs; [ @@ -27,9 +21,9 @@ freerdp ]; - home.activation.linkRemminaPresets = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".local/share/remmina"; - source = "dotfiles/${config.info.hostName}/remmina"; + home.activation.linkRemminaPresets = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.home.homeDirectory}/.local/share/remmina"; + source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/remmina"; isDir = true; }); }; diff --git a/modules/features/applications/gui/spotify.nix b/modules/features/applications/gui/spotify.nix index 894b1f1..af90184 100644 --- a/modules/features/applications/gui/spotify.nix +++ b/modules/features/applications/gui/spotify.nix @@ -5,13 +5,7 @@ spicetify.enable = lib.mkEnableOption "spicetify"; }; - config = let - mkIfElse = with lib; p: yes: no: - mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.gui.spotify.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.gui.spotify.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.spotify = { enable = lib.mkDefault true; spicetify.enable = lib.mkDefault config.features.applications.gui.spotify.spicetify.enable; diff --git a/modules/features/applications/gui/vscode.nix b/modules/features/applications/gui/vscode.nix index b8c7b39..cfc0c75 100644 --- a/modules/features/applications/gui/vscode.nix +++ b/modules/features/applications/gui/vscode.nix @@ -2,12 +2,7 @@ flake.nixosModules.graphics = { config, pkgs, lib, ... }: { options.features.applications.gui.vscode.enable = lib.mkEnableOption "vscode"; - config = let - mkIfElse = with lib; p: yes: no: mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.applications.gui.vscode.enable) (mkIfElse (config.features.nixos.home-manager.enable) { + config = lib.mkIf (config.features.applications.gui.vscode.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) { home-manager.users.grey.features.applications.gui.vscode.enable = lib.mkDefault true; } { environment.systemPackages = [ pkgs.vscode ]; @@ -21,14 +16,14 @@ home.packages = [ pkgs.vscode ]; home.activation = { - linkVsCodeConfigSettings = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/Code/User/settings.json"; - source = "dotfiles/global/vscode/settings.json"; + linkVsCodeConfigSettings = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.home.homeDirectory}/.config/Code/User/settings.json"; + source = "${config.info.rootPath}/dotfiles/global/vscode/settings.json"; }); - linkVsCodeConfigKeybindings = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/Code/User/keybindings.json"; - source = "dotfiles/global/vscode/keybindings.json"; + linkVsCodeConfigKeybindings = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript { + target = "${config.home.homeDirectory}/.config/Code/User/keybindings.json"; + source = "${config.info.rootPath}/dotfiles/global/vscode/keybindings.json"; }); }; }; diff --git a/modules/features/nixos/stylix.nix b/modules/features/nixos/stylix.nix index 57e3da5..06f5b58 100644 --- a/modules/features/nixos/stylix.nix +++ b/modules/features/nixos/stylix.nix @@ -6,12 +6,7 @@ options.features.nixos.stylix.enable = lib.mkEnableOption "stylix"; - config = let - mkIfElse = with lib; p: yes: no: mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - in lib.mkIf (config.features.nixos.stylix.enable) { + config = lib.mkIf (config.features.nixos.stylix.enable) { stylix.enable = true; stylix.image = builtins.path { path = "${self}/modules/hosts/${config.info.hostName}/wallpaper.jpg"; }; stylix.polarity = "dark"; diff --git a/modules/global/helpers.nix b/modules/global/helpers.nix deleted file mode 100644 index 5e88113..0000000 --- a/modules/global/helpers.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ inputs, self, ... }: { - flake.nixosModules.global = { pkgs, config, lib, ... }: { - options.helpers = { - typeOf = lib.mkOption { - type = lib.types.functionTo lib.types.str; - default = value: ( - if builtins.isAttrs value then "attrs" else ( - if builtins.isBool value then "bool" else ( - if builtins.isFloat value then "float" else ( - if builtins.isFunction value then "function" else ( - if builtins.isInt value then "int" else ( - if builtins.isList value then "list" else ( - if builtins.isPath value then "path" else ( - if builtins.isString value then "str" else "" - ) - ) - ) - ) - ) - ) - ) - ); - readOnly = true; - }; - - attrByStrPath = lib.mkOption { - default = strPath: set: - lib.attrsets.attrByPath (lib.strings.splitString "." strPath) null set; - readOnly = true; - }; - - homeManagerInheritEnableOptionElse = lib.mkOption { - # type = lib.types.functionTo lib.types.attrs; - default = optionName: systemAttrs: let - mkIfElse = with lib; p: yes: no: mkMerge [ - (mkIf p yes) - (mkIf (!p) no) - ]; - - attrByStrPath = strPath: set: - lib.attrsets.attrByPath (lib.strings.splitString "." strPath) null set; - - setAttrByStrPath = strPath: value: - lib.attrsets.setAttrByPath (lib.strings.splitString "." strPath) value; - in builtins.trace "hi" lib.mkIf (attrByStrPath optionName config) (mkIfElse (config.features.nixos.home-manager.enable) { - home-manager.sharedModules = [ - ({ lib, ... }: (setAttrByStrPath optionName (lib.mkDefault true))) - ]; - } (systemAttrs)); - readOnly = true; - }; - }; - }; - - flake.homeModules.global = { pkgs, config, lib, ... }: { - options.helpers = { - mkSymlinkActivationScript = lib.mkOption { - type = lib.types.functionTo lib.types.str; - default = {target, source, isDir ? false}: '' - if [ ${if isDir then "-d" else "-f"} /home/grey/${target} ]; then - rm${if isDir then " -rf" else ""} /home/grey/${target} - fi - ln -s ${config.info.rootPath}/${source} /home/grey/${target} - ''; - readOnly = true; - }; - }; - }; -} \ No newline at end of file diff --git a/modules/global/global.nix b/modules/global/nixos.nix similarity index 88% rename from modules/global/global.nix rename to modules/global/nixos.nix index 9df5264..b6ad058 100644 --- a/modules/global/global.nix +++ b/modules/global/nixos.nix @@ -83,8 +83,12 @@ }; home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) { - info.isStandalone = lib.mkDefault false; - # home.stateVersion = lib.mkDefault config.info.stateVersion; + info = { + rootPath = lib.mkDefault config.info.rootPath; + hostName = lib.mkDefault config.info.hostName; + stateVersion = lib.mkDefault config.info.stateVersion; + isStandalone = lib.mkDefault false; + }; }; }; } \ No newline at end of file diff --git a/modules/hosts/kitagawa/kitagawa.nix b/modules/hosts/kitagawa/kitagawa.nix index 4a56858..b5201c4 100644 --- a/modules/hosts/kitagawa/kitagawa.nix +++ b/modules/hosts/kitagawa/kitagawa.nix @@ -96,11 +96,6 @@ graphics ]; - info = { - hostName = "kitagawa"; - stateVersion = "26.05"; - }; - features = { applications = { extraPackages = with pkgs; [ diff --git a/modules/hosts/takamaki/home/zsh.nix b/modules/hosts/takamaki/home/zsh.nix index 2b875df..3fa95bb 100644 --- a/modules/hosts/takamaki/home/zsh.nix +++ b/modules/hosts/takamaki/home/zsh.nix @@ -1,7 +1,8 @@ { inputs, self, ... }: { flake.homeModules.takamaki = { config, pkgs, ... }: { programs.zsh.shellAliases = { - apply-config = "zsh -c 'cd /home/grey/flake; git add .; home-manager switch --flake .#takamaki -b bak'"; + apply-config = "zsh -c 'cd ${config.info.rootPath}; git add .; home-manager switch --flake .#takamaki -b bak'"; + update-config = "zsh -c 'cd ${config.info.rootPath}; git add .; nix flake update; home-manager switch --flake .#takamaki -b bak'"; }; }; } \ No newline at end of file diff --git a/modules/hosts/takamaki/takamaki.nix b/modules/hosts/takamaki/takamaki.nix index 4312502..3463d2a 100644 --- a/modules/hosts/takamaki/takamaki.nix +++ b/modules/hosts/takamaki/takamaki.nix @@ -60,7 +60,7 @@ WRITTEN=$(echo $RESULT | grep -oP "Writing.+\(\K\d{1,3}\)" | sed 's/)//') CONTROL=$(echo $RESULT | grep -oP "Control.+\+/\K\d{1,3}/100" | sed 's/\/100//') LOOP_COUNTER=$(($LOOP_COUNTER + 1)) - [[ "$WRITTEN" != "$CONTROL" ]] && [ $LOOP_COUNTER -lt 10 ] + [[ "$WRITTEN" != "$CONTROL" ]] && [ $LOOP_COUNTER -lt 5 ] do true; done noctalia msg notification-show "Set brightness to $WRITTEN for display $PRETTY_NAME" @@ -74,7 +74,7 @@ WRITTEN=$(echo $RESULT | grep -oP "Writing.+\(\K\d{1,3}\)" | sed 's/)//') CONTROL=$(echo $RESULT | grep -oP "Control.+\+/\K\d{1,3}/100" | sed 's/\/100//') LOOP_COUNTER=$(($LOOP_COUNTER + 1)) - [[ "$WRITTEN" != "$CONTROL" ]] && [ $LOOP_COUNTER -lt 10 ] + [[ "$WRITTEN" != "$CONTROL" ]] && [ $LOOP_COUNTER -lt 5 ] do true; done noctalia msg notification-show "Set brightness to $WRITTEN for display $PRETTY_NAME"