diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/default.nix | 10 | ||||
| -rw-r--r-- | modules/scripts/default.nix | 29 | ||||
| -rw-r--r-- | modules/scripts/scripts/restart-network.sh | 3 | ||||
| -rw-r--r-- | modules/shell/bash/default.nix | 3 | ||||
| -rw-r--r-- | modules/shell/zsh/default.nix | 3 |
5 files changed, 47 insertions, 1 deletions
diff --git a/modules/default.nix b/modules/default.nix index b697a2c..5e01083 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,10 +1,18 @@ -{ ... }: +{ lib, ... }: { imports = [ ./desktop ./fonts + ./scripts ./shell ./tools ]; + + options = { + baseDirectory = lib.mkOption { + type = lib.types.str; + description = "Path to the base of the current home manager configuration."; + }; + }; } diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix new file mode 100644 index 0000000..c933a5e --- /dev/null +++ b/modules/scripts/default.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +{ + options.scripts = { + enable = lib.mkEnableOption "Enable scripts."; + }; + + config = lib.mkIf config.scripts.enable { + home.file."scripts" = { + source = ./scripts; + recursive = true; + }; + + home.file."scripts/home-manager-switch" = { + text = '' +#!/bin/sh +home-manager switch --flake ${config.baseDirectory}/#${config.home.username} + ''; + executable = true; + }; + + home.activation.modifyScripts = lib.mkAfter '' + for script in ${config.home.homeDirectory}/scripts/*.sh; do + [ -f "$script" ] && mv "$script" "''${script%.sh}" + done + chmod -R u+x ${config.home.homeDirectory}/scripts + ''; + }; +} diff --git a/modules/scripts/scripts/restart-network.sh b/modules/scripts/scripts/restart-network.sh new file mode 100644 index 0000000..fc2b712 --- /dev/null +++ b/modules/scripts/scripts/restart-network.sh @@ -0,0 +1,3 @@ +#!/bin/sh +sudo ip link set $1 down +sudo ip link set $1 up diff --git a/modules/shell/bash/default.nix b/modules/shell/bash/default.nix index b845ced..b14669e 100644 --- a/modules/shell/bash/default.nix +++ b/modules/shell/bash/default.nix @@ -23,6 +23,9 @@ ${if config.tools.utils.fzf.enable then "eval \"$(fzf --bash)\"" else ""} +${if config.scripts.enable then + "export PATH=${config.home.homeDirectory}/scripts:$PATH" +else ""} ''; home.activation.createBashCacheDirectory = diff --git a/modules/shell/zsh/default.nix b/modules/shell/zsh/default.nix index d599196..96df967 100644 --- a/modules/shell/zsh/default.nix +++ b/modules/shell/zsh/default.nix @@ -21,6 +21,9 @@ ${if config.tools.utils.fzf.enable then "eval \"$(fzf --zsh)\"" else ""} ${builtins.readFile ./zshrc} +${if config.scripts.enable then + "export PATH=${config.home.homeDirectory}/scripts:$PATH" +else ""} ''; }; } |
