chore: Inherit builtins where possible

Possibly makes things easier to read.
This commit is contained in:
Donovan Glover 2024-04-04 17:55:46 -04:00
parent 8d4a7f780c
commit 721ead4572
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
3 changed files with 21 additions and 14 deletions

View File

@ -24,6 +24,7 @@
outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: let outputs = { self, nixpkgs, home-manager, stylix, ... } @ attrs: let
inherit (nixpkgs.lib) nixosSystem; inherit (nixpkgs.lib) nixosSystem;
inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage;
inherit (builtins) attrValues attrNames listToAttrs map replaceStrings readDir;
checkArgs = { checkArgs = {
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
@ -52,10 +53,10 @@
"/share/fonts" "/share/fonts"
]; ];
nixpkgs.overlays = builtins.attrValues self.overlays; nixpkgs.overlays = attrValues self.overlays;
imports = builtins.attrValues self.nixosModules; imports = attrValues self.nixosModules;
home-manager.sharedModules = builtins.attrValues self.homeManagerModules; home-manager.sharedModules = attrValues self.homeManagerModules;
environment.systemPackages = builtins.attrValues self.packages.x86_64-linux; environment.systemPackages = attrValues self.packages.x86_64-linux;
modules = { modules = {
hardware = { hardware = {
@ -83,18 +84,18 @@
neovim = import ./tests/neovim.nix checkArgs; neovim = import ./tests/neovim.nix checkArgs;
}; };
} // } //
(builtins.listToAttrs (listToAttrs
(builtins.map (map
(attributeName: { (attributeName: {
name = attributeName; name = attributeName;
value = let value = let
directory = builtins.replaceStrings flakeOutputs flakeDirectories attributeName; directory = replaceStrings flakeOutputs flakeDirectories attributeName;
attributeValue = (builtins.listToAttrs attributeValue = (listToAttrs
(builtins.map (map
(file: { (file: {
name = builtins.replaceStrings [ ".nix" ] [ "" ] file; name = replaceStrings [ ".nix" ] [ "" ] file;
value = if directory == packageDirectory then callPackage ./${directory}/${file} { } else import ./${directory}/${file}; }) value = if directory == packageDirectory then callPackage ./${directory}/${file} { } else import ./${directory}/${file}; })
(builtins.attrNames (builtins.readDir ./${directory})))); (attrNames (readDir ./${directory}))));
attributeSet = if directory == packageDirectory then { x86_64-linux = attributeValue; } else attributeValue; attributeSet = if directory == packageDirectory then { x86_64-linux = attributeValue; } else attributeValue;
in (attributeSet); }) in (attributeSet); })
(flakeOutputs))); (flakeOutputs)));

View File

@ -1,7 +1,10 @@
{ pkgs, ... }: { pkgs, ... }:
let
inherit (builtins) attrValues;
in
{ {
home.packages = builtins.attrValues { home.packages = attrValues {
inherit (pkgs) tig mgitstatus; inherit (pkgs) tig mgitstatus;
}; };

View File

@ -1,12 +1,15 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
inherit (builtins) attrValues toJSON;
inherit (lib) singleton; inherit (lib) singleton;
in in
{ {
home.packages = with pkgs; [ ironbar ]; home.packages = attrValues {
inherit (pkgs) ironbar;
};
xdg.configFile."ironbar/config.json".text = builtins.toJSON { xdg.configFile."ironbar/config.json".text = toJSON {
name = "main"; name = "main";
icon_theme = "Fluent-dark"; icon_theme = "Fluent-dark";
position = "bottom"; position = "bottom";