aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-04-04 15:54:26 +0200
committerKarel Kočí <cynerd@email.cz>2022-04-04 17:54:18 +0200
commit7e8cc7201949ad75daca5520c57479229711ed31 (patch)
tree544b15a25f53ba4923eff7e813732ab8ba81a996 /flake.nix
parent0cf542815d11b09e411a00267c89180e28623991 (diff)
downloadshellrc-7e8cc7201949ad75daca5520c57479229711ed31.tar.gz
shellrc-7e8cc7201949ad75daca5520c57479229711ed31.tar.bz2
shellrc-7e8cc7201949ad75daca5520c57479229711ed31.zip
Add flake.nix
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix71
1 files changed, 71 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..ec21822
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,71 @@
+{
+ description = "Cynerd's shell configuration";
+
+ outputs = { self, nixpkgs }: {
+
+ nixosModule = { config, lib, pkgs, ... }:
+ with lib;
+ let
+ zsh-completion = pkgs.stdenv.mkDerivation rec {
+ name = "shellrc-completion";
+ src = ./.;
+ nativeBuildInputs = [ pkgs.installShellFiles ];
+ installPhase = ''
+ for comp in bash-completion/*; do
+ installShellCompletion --bash --name "$${comp##*/}.bash" "$comp"
+ done
+ for comp in zsh-completion/*; do
+ installShellCompletion --zsh --name "$${comp##*/}" "$comp"
+ done
+ '';
+ };
+ in {
+
+ options = {
+ programs.shellrc = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = "If shellrc should be enabled.";
+ };
+ desktop = mkOption {
+ type = types.bool;
+ default = false;
+ description = "If shellrc's desktop specific files should be used.";
+ };
+ };
+ };
+
+ config = mkIf config.programs.shellrc.enable {
+ environment.loginShellInit = ''
+ for sh in ${./shellrc.d}/*; do
+ [ -r "$sh" ] && . "$sh"
+ done
+ '' + optionalString config.programs.shellrc.desktop ''
+ for sh in ${./shellrc-desktop.d}/*; do
+ [ -r "$sh" ] && . "$sh"
+ done
+ '';
+
+ programs.bash.loginShellInit = ''
+ for sh in ${./bashrc.d}/*; do
+ [ -r "$sh" ] && . "$sh"
+ done
+ '';
+
+ programs.zsh.loginShellInit = mkIf config.programs.zsh.enable ''
+ for sh in ${./zshrc.d}/*; do
+ [ -r "$sh" ] && . "$sh"
+ done
+ '';
+
+ environment.systemPackages = [
+ zsh-completion
+ ];
+
+ };
+
+ };
+
+ };
+}