aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix98
1 files changed, 54 insertions, 44 deletions
diff --git a/flake.nix b/flake.nix
index 64040fe..83c6d6a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,11 +1,20 @@
{
description = "Cynerd's shell configuration";
- outputs = { self, nixpkgs }: {
+ outputs = { self, flake-utils, nixpkgs }:
+ let
- nixosModule = { config, lib, pkgs, ... }:
- with lib;
- let
+ loadrc = dir: ''
+ for sh in ${dir}/*; do
+ [ -r "$sh" ] && . "$sh"
+ done
+ '';
+ commonrc = loadrc ./shellrc.d;
+ desktoprc = loadrc ./shellrc-desktop.d;
+ bashrc = loadrc ./bashrc.d;
+ zshrc = loadrc ./zshrc.d;
+
+ packages = pkgs: rec {
shellrc-completion = pkgs.stdenv.mkDerivation rec {
name = "shellrc-completion";
src = ./.;
@@ -18,56 +27,57 @@
installShellCompletion --zsh --name "$${comp##*/}" "$comp"
done
'';
+ shellHook = commonrc + bashrc + ''
+ export _SHELLRC=develop
+ '';
};
- in {
+ default = shellrc-completion;
+ };
- options = {
- programs.shellrc = {
- enable = mkOption {
- type = types.bool;
- default = true;
- description = "If shellrc should be enabled.";
- };
- desktop = mkOption {
- type = types.bool;
- default = false;
- description = "If shellrc's desktop specific files should be used.";
+ in {
+
+ overlays = {
+ shellrc = final: prev: packages prev;
+ default = self.overlay.shellrc;
+ };
+
+ nixosModules = {
+ shellrc = { config, lib, pkgs, ... }: with lib; {
+ options = {
+ programs.shellrc = {
+ enable = mkOption {
+ type = types.bool;
+ default = true;
+ 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.interactiveShellInit = ''
- 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
- '';
+ config = mkIf config.programs.shellrc.enable {
- programs.bash.interactiveShellInit = ''
- for sh in ${./bashrc.d}/*; do
- [ -r "$sh" ] && . "$sh"
- done
- '';
- programs.bash.promptInit = ""; # Disable default prompt as we have our own
+ environment.interactiveShellInit = commonrc + optionalString config.programs.shellrc.desktop desktoprc;
- programs.zsh.interactiveShellInit = mkIf config.programs.zsh.enable ''
- for sh in ${./zshrc.d}/*; do
- [ -r "$sh" ] && . "$sh"
- done
- '';
- programs.zsh.promptInit = ""; # Disable default prompt as we have our own
+ programs.bash.interactiveShellInit = bashrc;
+ programs.bash.promptInit = ""; # Disable default prompt as we have our own
- environment.systemPackages = [
- shellrc-completion
- ];
+ programs.zsh.interactiveShellInit = mkIf config.programs.zsh.enable zshrc;
+ programs.zsh.promptInit = ""; # Disable default prompt as we have our own
- };
+ nixpkgs.overlays = [ self.overlays.shellrc ];
+ environment.systemPackages = [ pkgs.shellrc-completion ];
+ };
+ };
+ default = self.nixosModules.shellrc;
};
- };
+ } // (flake-utils.lib.eachDefaultSystem (system: {
+ packages = packages nixpkgs.legacyPackages.${system};
+ }));
+
}