dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit 73fb4b76a50f05abe674c920d3b6e591ba9a79ce parent e4eff17138761270e25bede37d76f56bfdb7bf1a Author: maydayv7 <maydayv7@gmail.com> Date: Tue, 31 May 2022 12:40:31 +0530 feat(lib): Add `map.array` Also Refactor Code Formatters
Diffstat:
| M | lib/README.md | | | 1 | + |
| M | lib/map.nix | | | 3 | +++ |
| M | modules/default.nix | | | 6 | +++--- |
| M | modules/nix/default.nix | | | 6 | ++++-- |
| A | modules/nix/format.nix | | | 8 | ++++++++ |
| A | packages/overlays/miscellaneous.nix | | | 4 | ++++ |
| M | scripts/nixos.nix | | | 42 | ++++++++++++++++++++---------------------- |
| M | shells/format.nix | | | 8 | +------- |
| M | site/content/anime.md | | | 4 | +++- |
9 files changed, 47 insertions(+), 35 deletions(-)
diff --git a/lib/README.md b/lib/README.md @@ -15,6 +15,7 @@ The `lib` directory contains custom-made pure Flakes-compatible utility function - [`map`](./map.nix): Mapping functions primarily aimed at shortening code complexity - + - `array`: Maps required parameter to all elements present in `list` - `filter`: Filters out unneeded `attrs` and maps required ones to specified function - `list`: Lists all toplevel `attrs` of `attrset` and returns a space-separated string - `files`: Maps all files with a particular extension stored in a directory as an `attrset` acted upon by specified function. Use `files'` in order to recursively search inside directories diff --git a/lib/map.nix b/lib/map.nix @@ -14,6 +14,8 @@ (lib) flatten filterAttrs + forEach + getAttrFromPath hasPrefix hasSuffix id @@ -25,6 +27,7 @@ ; in rec { ## Mapping Functions ## + array = list: func: forEach list (name: getAttrFromPath [name] func); filter = name: func: attrs: filterAttrs name (mapAttrs' func attrs); list = func: foldl' (x: y: x + y + " ") "" (attrNames func); diff --git a/modules/default.nix b/modules/default.nix @@ -5,7 +5,7 @@ files, }: let inherit (inputs) self generators; - inherit (lib) extend forEach getAttrFromPath makeOverridable mkForce mkIf; + inherit (lib) extend makeOverridable mkForce mkIf; inherit (builtins) any @@ -44,6 +44,7 @@ in { pkgs = self.channels."${system}"."${channel}"; # System Libraries + util = lib'.util; lib' = extend (final: prev: with input.lib; {inherit nixosSystem trivial;}); @@ -101,8 +102,7 @@ in { then [(getAttr format generators.nixosModules)] else [] ) - ++ forEach hardware.modules or [] - (name: getAttrFromPath [name] inputs.hardware.nixosModules); + ++ util.map.array (hardware.modules or []) inputs.hardware.nixosModules; inherit apps gui hardware shell; # Device Name diff --git a/modules/nix/default.nix b/modules/nix/default.nix @@ -1,15 +1,17 @@ { + lib, inputs, pkgs, ... -}: { +}: +with {inherit (lib.util.map) array;}; { imports = [./index.nix inputs.utils.nixosModules.autoGenFromInputs]; ## Nix Settings ## config = { # Utilities user.persist.dirs = [".cache/nix" ".cache/manix"]; - environment.systemPackages = with pkgs; [cachix manix]; + environment.systemPackages = [pkgs.cachix] ++ array (import ./format.nix) pkgs.unstable; # Settings nix = { diff --git a/modules/nix/format.nix b/modules/nix/format.nix @@ -0,0 +1,8 @@ +[ + "alejandra" + "manix" + "nix-linter" + "prettier" + "shellcheck" + "statix" +] diff --git a/packages/overlays/miscellaneous.nix b/packages/overlays/miscellaneous.nix @@ -0,0 +1,4 @@ +final: prev: { + ## Miscellaneous Overlays ## + prettier = final.nodePackages.prettier; +} diff --git a/scripts/nixos.nix b/scripts/nixos.nix @@ -8,7 +8,7 @@ }: with files; let inherit (inputs) self; - inherit (util.map) list; + inherit (util.map) array list; inherit (lib) licenses recursiveUpdate util; devShells = list self.devShells."${system}"; @@ -76,27 +76,25 @@ in }; } (pkgs.writeShellApplication { name = "nixos"; - runtimeInputs = with pkgs; [ - unstable.alejandra - cachix - coreutils - apps.deploy - apps.generators - git - gnupg - gnused - gparted - jq - manix - nixFlakes - nix-linter - parted - nodePackages.prettier - sops - tree - wine.mkwindowsapp-tools - zfs - ]; + runtimeInputs = with pkgs; + [ + cachix + coreutils + apps.deploy + apps.generators + git + gnupg + gnused + gparted + jq + nixFlakes + parted + sops + tree + wine.mkwindowsapp-tools + zfs + ] + ++ array (import ../modules/nix/format.nix) pkgs.unstable; text = '' set +eu diff --git a/shells/format.nix b/shells/format.nix @@ -1,11 +1,5 @@ pkgs: { name = "Formatter"; shellHook = ''echo "## Formatting Shell ##"''; - packages = with pkgs; [ - unstable.alejandra - nix-linter - nodePackages.prettier - shellcheck - statix - ]; + packages = (import ../lib/map.nix {lib = pkgs.lib;}).array (import ../modules/nix/format.nix) pkgs.unstable; } diff --git a/site/content/anime.md b/site/content/anime.md @@ -12,7 +12,8 @@ comments = true - 3D Kanojo - 86 <sup>\*</sup> <sup>#</sup> - A Silent Voice -- Ao-chan can't Study +- Akudama Drive +- Ao can't Study - Bunny Girl Senpai - Chuunibyou demo Koi ga Shitai! <sup>#</sup> - Clannad <sup>#</sup> @@ -30,6 +31,7 @@ comments = true - Kimi ni Todoke - Kokoro Connect - Komi Can't Communicate <sup>\*</sup> <sup>#</sup> +- Konosuba <sup>#</sup> - My Dress Up Darling <sup>\*</sup> - My Senpai is Annoying - Nisekoi