refactor: limit use of with lib

This commit is contained in:
matt1432 2024-01-22 11:09:37 -05:00
parent 7fd12f5b04
commit 20dac8791e
16 changed files with 74 additions and 50 deletions

View file

@ -1,15 +1,17 @@
{lib, ...}: {
{lib, ...}: let
inherit (lib) fileContents;
# TODO: have different colors depending on host
textColor = "#e3e5e5";
firstColor = "#bd93f9";
secondColor = "#715895";
thirdColor = "#382c4a";
fourthColor = "#120e18";
in {
imports = [./programs.nix];
programs = {
starship = let
# TODO: have different colors depending on host
textColor = "#e3e5e5";
firstColor = "#bd93f9";
secondColor = "#715895";
thirdColor = "#382c4a";
fourthColor = "#120e18";
in {
starship = {
enable = true;
enableBashIntegration = true;
settings = {
@ -143,11 +145,11 @@
# Check if shell is interactive
[[ $- == *i* ]] || return 0
${lib.strings.fileContents ./config/dracula/less.sh}
${lib.strings.fileContents ./config/dracula/fzf.sh}
${fileContents ./config/dracula/less.sh}
${fileContents ./config/dracula/fzf.sh}
${lib.strings.fileContents ./config/colorgrid.sh}
${lib.strings.fileContents ./config/bashrc}
${fileContents ./config/colorgrid.sh}
${fileContents ./config/bashrc}
'';
#initExtra = ''
#'';

View file

@ -1,4 +1,4 @@
{
{...}: {
imports = [
./bash
./git

View file

@ -5,9 +5,9 @@
coc-stylelintplus-flake,
tree-sitter-hyprlang-flake,
...
}:
with lib; let
}: let
inherit (config.vars) neovimIde;
inherit (lib) fileContents optionalAttrs optionals;
javaSdk = pkgs.temurin-bin-17;
nvim-treesitter-hyprlang = tree-sitter-hyprlang-flake.packages.${pkgs.system}.default;

View file

@ -1,4 +1,4 @@
{
{...}: {
imports = [
./cachix.nix
./locale.nix

View file

@ -3,18 +3,18 @@
lib,
nixpkgs,
...
}:
with lib; let
}: let
inherit (config.sops.secrets) access-token;
inherit (lib) hasAttr optionalString;
in {
# Minimize dowloads of indirect nixpkgs flakes
nix = {
registry.nixpkgs.flake = nixpkgs;
nixPath = ["nixpkgs=${nixpkgs}"];
extraOptions =
if (hasAttr "sops" config)
then "!include ${access-token.path}"
else "";
optionalString (hasAttr "sops" config)
"!include ${access-token.path}";
};
# Global hm settings

View file

@ -3,7 +3,9 @@
pkgs,
...
} @ inputs:
with lib; let
let
inherit (lib) concatMapAttrs filterAttrs mkOption pathExists types;
mkPackage = name: v: {
${name} = pkgs.callPackage ./${name} inputs;
};

View file

@ -3,8 +3,9 @@
lib,
...
}: {
options.vars = with lib; let
inherit (config.vars) mainUser hostName;
options.vars = let
inherit (lib) mkOption types;
cfg = config.vars;
in {
mainUser = mkOption {
type = types.str;
@ -22,7 +23,7 @@
configDir = mkOption {
type = types.str;
default = "/home/${mainUser}/.nix/devices/${hostName}/config";
default = "/home/${cfg.mainUser}/.nix/devices/${cfg.hostName}/config";
description = ''
The path to where most of the devices' configs are in the .nix folder
'';