aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2023-03-16 12:27:42 +0100
committerKarel Kočí <cynerd@email.cz>2023-03-16 12:32:36 +0100
commitdf7fdb5bc098ebf2220235b2337a1517267ef04d (patch)
treefe1b104e73f853b214223b37277e53bf89b9c25f /flake.nix
parent6f8f27349e074f2c9b6e7a359dad4f5656fc9db8 (diff)
downloadshellrc-df7fdb5bc098ebf2220235b2337a1517267ef04d.tar.gz
shellrc-df7fdb5bc098ebf2220235b2337a1517267ef04d.tar.bz2
shellrc-df7fdb5bc098ebf2220235b2337a1517267ef04d.zip
Rework the whole NixOS and packages
This uses now primarilly overlays and also variable NIX_PROFILES to chain-load shellrc from bashrc.d and zshrc.d.
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix136
1 files changed, 22 insertions, 114 deletions
diff --git a/flake.nix b/flake.nix
index 35c0231..013277b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,120 +1,28 @@
{
description = "Cynerd's shell configuration";
- outputs = { self, flake-utils, nixpkgs }:
- 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-generic = pkgs.stdenvNoCC.mkDerivation {
- name = "shellrc-profile";
- src = ./.;
- installPhase = ''
- mkdir -p "$out/etc/shellrc"
- cp -r ./shellrc.d/. "$out/etc/shellrc/"
- '';
- };
- shellrc-bashrc = pkgs.stdenvNoCC.mkDerivation {
- name = "shellrc-profile-bash";
- src = ./.;
- shellrc = shellrc-generic;
- installPhase = ''
- mkdir -p "$out/etc/bashrc.d"
- cp -r ./bashrc.d/. "$out/etc/bashrc.d/"
- cat >"$out/etc/bashrc.d/shellrc" <<EOF
- for sh in $shellrc/etc/shellrc/*; do
- [ -r "\$sh" ] && . "\$sh"
- done
- EOF
- '';
- };
- shellrc-zshrc = pkgs.stdenvNoCC.mkDerivation {
- name = "shellrc-profile-zsh";
- src = ./.;
- shellrc = shellrc-generic;
- installPhase = ''
- mkdir -p "$out/etc/zshrc.d"
- cp -r ./zshrc.d/. "$out/etc/zshrc.d/"
- cat >"$out/etc/zshrc.d/shellrc" <<EOF
- for sh in $shellrc/etc/shellrc/*; do
- [ -r "\$sh" ] && . "\$sh"
- done
- EOF
- '';
- };
- shellrc-completion = pkgs.stdenvNoCC.mkDerivation {
- 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
- '';
- };
- shellrc = pkgs.symlinkJoin {
- name = "shellrc";
- paths = [ shellrc-bashrc shellrc-zshrc shellrc-completion ];
- };
- default = shellrc;
- };
-
- in {
-
- overlays = {
- shellrc = final: prev: packages prev;
- default = self.overlays.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.";
- };
- };
+ outputs = {
+ self,
+ flake-utils,
+ nixpkgs,
+ }:
+ with flake-utils.lib;
+ {
+ overlays = {
+ shellrc = final: prev: import ./pkgs.nix {pkgs = prev;};
+ default = self.overlays.shellrc;
};
-
- config = mkIf config.programs.shellrc.enable {
-
- environment.interactiveShellInit = commonrc + optionalString config.programs.shellrc.desktop desktoprc;
-
- programs.bash.interactiveShellInit = bashrc;
- programs.bash.promptInit = ""; # Disable default prompt as we have our own
-
- 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 ];
-
+ nixosModules = {
+ shellrc = import ./nixos.nix [self.overlays.shellrc];
+ default = self.nixosModules.shellrc;
};
- };
- default = self.nixosModules.shellrc;
- };
-
- } // (flake-utils.lib.eachDefaultSystem (system: {
- packages = packages nixpkgs.legacyPackages.${system};
- }));
-
+ }
+ // eachDefaultSystem (system: let
+ pkgs = nixpkgs.legacyPackages.${system};
+ selfPkgs = filterPackages system (flattenTree (import ./pkgs.nix {inherit pkgs;}));
+ in {
+ packages = selfPkgs // {default = selfPkgs.shellrc-bash;};
+ legacyPackages = pkgs.extend self.overlays.default;
+ formatter = pkgs.alejandra;
+ });
}