Skip to content

Commit

Permalink
with lib -> inherit (lib) ...
Browse files Browse the repository at this point in the history
  • Loading branch information
ahbk committed Jun 10, 2024
1 parent bf6f9cf commit 357f3c8
Show file tree
Hide file tree
Showing 29 changed files with 271 additions and 142 deletions.
4 changes: 0 additions & 4 deletions configurations/glesys.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{ lib, ... }:

with lib;

let
users = import ../users.nix;
sites = import ../sites.nix;
Expand Down
4 changes: 0 additions & 4 deletions configurations/stationary.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{ lib, ... }:

with lib;

let
users = import ../users.nix;
sites = import ../sites.nix;
Expand Down
6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
outputs =
{ self, ... }@inputs:

with inputs.nixpkgs.lib;
with inputs.home-manager.lib;
let
inherit (inputs.nixpkgs.lib) nixosSystem mapAttrs;
inherit (inputs.home-manager.lib) homeManagerConfiguration;
in

{
homeConfigurations = mapAttrs (
Expand Down
3 changes: 2 additions & 1 deletion hm-modules/all.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ inputs, ... }: {
{ inputs, ... }:
{
imports = [
inputs.nixvim.homeManagerModules.nixvim
./desktop-env.nix
Expand Down
29 changes: 14 additions & 15 deletions hm-modules/desktop-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
...
}:

with lib;

let
inherit (lib) mkIf getExe mkEnableOption;
inherit (builtins) substring;
inherit (theme) colors fonts;
theme = import ../theme.nix;
unhashedHexes = lib.mapAttrs (n: c: builtins.substring 1 6 c) theme.colors;
unhashedHexes = lib.mapAttrs (n: c: substring 1 6 c) theme.colors;
cfg = config.my-nixos-hm.desktop-env;
in
with theme.colors;
with theme.fonts;

{
options.my-nixos-hm.desktop-env = with types; {
options.my-nixos-hm.desktop-env = {
enable = mkEnableOption "Desktop Environment for this user";
};

config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
programs.foot = {
enable = true;
settings = {
main.font = "${monospace}:size=11";
main.font = "${fonts.monospace}:size=11";
main.dpi-aware = "no";
mouse.hide-when-typing = "yes";
colors = with unhashedHexes; {
Expand Down Expand Up @@ -65,7 +64,7 @@ with theme.fonts;
config.bind('<Ctrl-O>', 'back')
config.bind('<Ctrl-I>', 'forward')
'';
settings = {
settings = with colors; {
input = {
links_included_in_focus_chain = false;
};
Expand All @@ -84,7 +83,7 @@ with theme.fonts;
};
};
fonts = {
default_family = [ monospace ];
default_family = [ fonts.monospace ];
default_size = "11pt";
hints = "default_size default_family";
};
Expand Down Expand Up @@ -244,7 +243,7 @@ with theme.fonts;
mode = "year";
mode-mon-col = 3;
weeks-pos = "left";
format = {
format = with colors; {
months = "<span color='${green-400}'><b>{}</b></span>";
days = "<span color='${white-400}'><b>{}</b></span>";
weeks = "<span color='${purple-400}'><b>{}</b></span>";
Expand All @@ -255,9 +254,9 @@ with theme.fonts;
};
};
};
style = ''
style = with colors; ''
* {
font-family: ${monospace};
font-family: ${fonts.monospace};
background-color: ${bg-400};
}
#battery {
Expand All @@ -278,8 +277,8 @@ with theme.fonts;
settings = {
monitor = ",preferred,auto,1";
exec-once = [
"${lib.getExe pkgs.swaybg} -i ${config.home.file.wallpaper.target}"
"${lib.getExe pkgs.waybar}"
"${getExe pkgs.swaybg} -i ${config.home.file.wallpaper.target}"
"${getExe pkgs.waybar}"
];

general = {
Expand Down
15 changes: 9 additions & 6 deletions hm-modules/ide.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
...
}:

with lib;

let
cfg = config.my-nixos-hm.ide;
theme = import ../theme.nix;
inherit (lib)
types
mkIf
mkEnableOption
mkOption
;
inherit (theme) colors;
cfg = config.my-nixos-hm.ide;
in
with theme.colors;
with theme.fonts;

{

Expand Down Expand Up @@ -59,7 +62,7 @@ with theme.fonts;
enable = true;
settings = {
transparent = false;
colors.palette = {
colors.palette = with colors; {
katanaGray = black-100; # deprecated
fujiGray = black-200; # syn.comment term:bright black
sumiInk6 = black-300; # nontext whitespace
Expand Down
12 changes: 5 additions & 7 deletions hm-modules/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
...
}:

with lib;

let
inherit (lib) types mkIf mkEnableOption;
inherit (theme) colors;
cfg = config.my-nixos-hm.shell;
theme = import ../theme.nix;
in
with theme.colors;
with theme.fonts;

{
options.my-nixos-hm.shell = with types; {
enable = mkEnableOption (mkDoc "Enable shell for this user");
options.my-nixos-hm.shell = {
enable = mkEnableOption "Enable shell for this user";
};

config = mkIf cfg.enable {
Expand Down Expand Up @@ -91,7 +89,7 @@ with theme.fonts;
keyMode = "vi";
escapeTime = 10;
baseIndex = 1;
extraConfig = ''
extraConfig = with colors; ''
set-option -ga terminal-features ',foot:RGB'
set-option -g status-right "#{user}@#{host}"
set -ga terminal-overrides ",256col:Tc"
Expand Down
8 changes: 6 additions & 2 deletions hm-modules/user.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{ config, lib, ... }:

with lib;

let
inherit (lib)
types
mkIf
mkEnableOption
mkOption
;
cfg = config.my-nixos-hm.user;
in
{
Expand Down
7 changes: 3 additions & 4 deletions hm-modules/vd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
...
}:

with lib;

let
inherit (lib) mkIf mkEnableOption;
cfg = config.my-nixos-hm.vd;
in
{
options.my-nixos-hm.vd = {
enable = mkEnableOption (mkDoc "Enable visual design tools for this user");
enable = mkEnableOption "Enable visual design tools for this user";
};

config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
home.packages = with pkgs; [
inkscape
figma-linux
Expand Down
10 changes: 8 additions & 2 deletions modules/backup.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{ config, lib, ... }:

with lib;

let
inherit (lib)
filterAttrs
types
mkOption
mkIf
mapAttrs
mkEnableOption
;
cfg = config.my-nixos.backup;
eachTarget = filterAttrs (user: cfg: cfg.enable) cfg;
targetOpts = {
Expand Down
14 changes: 11 additions & 3 deletions modules/desktop-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
...
}:

with lib;

let
inherit (lib)
filterAttrs
types
mkOption
mkIf
mapAttrs
mkEnableOption
flatten
mapAttrsToList
;
cfg = config.my-nixos.desktop-env;
eachUser = filterAttrs (user: cfg: cfg.enable) cfg;
eachHMUser = filterAttrs (user: cfg: config.my-nixos.hm.${user}.enable) eachUser;

userOpts = with types; {
userOpts = {
options.enable = mkEnableOption "desktop environment for this user";
};
in
Expand Down
12 changes: 9 additions & 3 deletions modules/django-svelte.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{ config, lib, ... }:

with lib;
with builtins;

let
inherit (lib)
types
mkEnableOption
mkOption
mapAttrs
filterAttrs
mkIf
;
inherit (builtins) elemAt;
cfg = config.my-nixos.django-svelte;
eachSite = filterAttrs (hostname: cfg: cfg.enable) cfg.sites;

Expand Down
14 changes: 12 additions & 2 deletions modules/django.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@
...
}:

with lib;

let
inherit (lib)
types
mkEnableOption
mkOption
mkIf
filterAttrs
mapAttrsToList
mapAttrs
mapAttrs'
flatten
nameValuePair
;
lib' = (import ../lib.nix) { inherit lib pkgs; };
cfg = config.my-nixos.django;

Expand Down
12 changes: 9 additions & 3 deletions modules/fastapi-svelte.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{ config, lib, ... }:

with lib;
with builtins;

let
inherit (lib)
filterAttrs
types
mkOption
mkEnableOption
mkIf
mapAttrs
;
inherit (builtins) elemAt;
cfg = config.my-nixos.fastapi-svelte;
eachSite = filterAttrs (hostname: cfg: cfg.enable) cfg.sites;
siteOpts = {
Expand Down
15 changes: 13 additions & 2 deletions modules/fastapi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
...
}:

with lib;

let
inherit (lib)
filterAttrs
types
mkEnableOption
mkOption
mapAttrs
mapAttrsToList
flatten
getExe
mapAttrs'
mkIf
nameValuePair
;
lib' = (import ../lib.nix) { inherit lib pkgs; };
cfg = config.my-nixos.fastapi;

Expand Down
9 changes: 7 additions & 2 deletions modules/glesys-updaterecord.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
...
}:

with lib;

let
inherit (lib)
types
mkEnableOption
mkOption
mkIf
getExe
;
cfg = config.my-nixos.glesys.updaterecord;
in
{
Expand Down
12 changes: 9 additions & 3 deletions modules/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
...
}:

with lib;

let
inherit (lib)
filterAttrs
types
mkEnableOption
mkOption
mkIf
mapAttrs
;
cfg = config.my-nixos.hm;
eachUser = filterAttrs (user: cfg: cfg.enable) cfg;

userOpts = with types; {
userOpts = {
options.enable = mkEnableOption "home-manager for this user";
};
in
Expand Down
Loading

0 comments on commit 357f3c8

Please sign in to comment.