about summary refs log tree commit diff
path: root/modules/common
diff options
context:
space:
mode:
authorazahi <azat@bahawi.net>2025-02-17 02:21:56 +0300
committerazahi <azat@bahawi.net>2025-02-17 02:21:56 +0300
commit59180328cda59817d71cd58c8f48ead047375064 (patch)
tree2cdd7d1bfa309839ef624c19daf283f510aacf69 /modules/common
parent2025-02-05 (diff)
2025-02-17
Diffstat (limited to 'modules/common')
-rw-r--r--modules/common/default.nix2
-rw-r--r--modules/common/home-manager.nix2
-rw-r--r--modules/common/locale.nix5
-rw-r--r--modules/common/nix.nix29
-rw-r--r--modules/common/secrets.nix9
-rw-r--r--modules/common/shell/default.nix2
-rw-r--r--modules/common/stylix.nix15
-rw-r--r--modules/common/users.nix15
-rw-r--r--modules/common/xdg.nix23
9 files changed, 51 insertions, 51 deletions
diff --git a/modules/common/default.nix b/modules/common/default.nix
index 38094e7..781e50f 100644
--- a/modules/common/default.nix
+++ b/modules/common/default.nix
@@ -1,4 +1,4 @@
 { lib, ... }:
 {
-  imports = lib.attrValues (lib.modulesIn ./.);
+  imports = lib.modulesIn ./. |> lib.attrValues;
 }
diff --git a/modules/common/home-manager.nix b/modules/common/home-manager.nix
index 118fc0e..31a11f6 100644
--- a/modules/common/home-manager.nix
+++ b/modules/common/home-manager.nix
@@ -28,7 +28,7 @@
   home-manager = {
     backupFileExtension = "bak";
     useUserPackages = true;
-    useGlobalPkgs = true;
+    useGlobalPkgs = false;
     verbose = true;
   };
 }
diff --git a/modules/common/locale.nix b/modules/common/locale.nix
index acd1ecd..82df387 100644
--- a/modules/common/locale.nix
+++ b/modules/common/locale.nix
@@ -4,7 +4,6 @@
   pkgs,
   ...
 }:
-with lib;
 {
   hm.home.language = {
     collate = "C";
@@ -16,7 +15,7 @@ with lib;
   };
 
   i18n = {
-    defaultLocale = mkDefault "en_GB.UTF-8";
+    defaultLocale = lib.mkDefault "en_GB.UTF-8";
     supportedLocales = [
       "C.UTF-8/UTF-8"
       "en_GB.UTF-8/UTF-8"
@@ -47,7 +46,7 @@ with lib;
   services.xserver.xkb = {
     layout = "us,ru";
     variant = ",phonetic";
-    options = concatStringsSep "," [
+    options = lib.concatStringsSep "," [
       "caps:escape"
       "compose:menu"
       "grp:win_space_toggle"
diff --git a/modules/common/nix.nix b/modules/common/nix.nix
index 0ce2ae4..6cb3787 100644
--- a/modules/common/nix.nix
+++ b/modules/common/nix.nix
@@ -6,7 +6,6 @@
   this,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.common.nix;
 in
@@ -16,24 +15,24 @@ in
     mixins-trusted-nix-caches
   ];
 
-  options.nixfiles.modules.common.nix.allowedUnfreePackages = mkOption {
+  options.nixfiles.modules.common.nix.allowedUnfreePackages = lib.mkOption {
     description = "A list of allowed unfree packages.";
-    type = with types; listOf str;
+    type = with lib.types; listOf str;
     default = [ ];
   };
 
   config = {
     _module.args = {
-      pkgsLocal = packages.useNixpkgs "${config.my.home}/src/nixpkgs"; # Impure!
+      pkgsLocal = lib.packages.useNixpkgs "${config.my.home}/src/nixpkgs"; # Impure!
     };
 
     hm = {
       # Used primarily in conjunction with the "nixfiles" script.
       home.file.".nix-defexpr/default.nix".text =
         let
-          hostname = strings.escapeNixIdentifier this.hostname;
+          hostname = lib.strings.escapeNixIdentifier this.hostname;
         in
-        optionalString this.isHeadful ''
+        lib.optionalString this.isHeadful ''
           let
             self = builtins.getFlake "nixfiles";
             configurations = self.nixosConfigurations;
@@ -54,16 +53,16 @@ in
 
     nix =
       let
-        notSelfInputs = filterAttrs (n: _: n != "self") inputs;
+        notSelfInputs = lib.filterAttrs (n: _: n != "self") inputs;
       in
       {
-        package = mkForce pkgs.nix; # Only use stable Nix.
+        package = lib.mkForce pkgs.nix; # Only use stable Nix.
 
-        nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [
+        nixPath = lib.mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [
           "nixfiles=${config.my.home}/src/nixfiles"
         ];
 
-        registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // {
+        registry = lib.mapAttrs (_: flake: { inherit flake; }) notSelfInputs // {
           nixfiles.flake = inputs.self;
         };
 
@@ -77,7 +76,7 @@ in
             "pipe-operators"
           ];
 
-          trusted-users = [ my.username ];
+          trusted-users = [ lib.my.username ];
 
           substituters = [
             "https://nix-community.cachix.org"
@@ -95,7 +94,7 @@ in
       };
 
     nixpkgs = {
-      config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages;
+      config.allowUnfreePredicate = p: lib.elem (lib.getName p) cfg.allowedUnfreePackages;
 
       overlays = [ inputs.self.overlays.default ];
     };
@@ -106,16 +105,16 @@ in
       defaultPackages = [ ];
       systemPackages =
         with pkgs;
-        optionals this.isHeadful [
+        lib.optionals this.isHeadful [
           nix-tree
           nixfiles
         ];
       variables = {
-        NIXFILES = optionalString this.isHeadful "${config.my.home}/src/nixfiles";
+        NIXFILES = lib.optionalString this.isHeadful "${config.my.home}/src/nixfiles";
         NIX_SHELL_PRESERVE_PROMPT = "1";
       };
     };
 
-    system.stateVersion = this.stateVersion or trivial.release;
+    system.stateVersion = this.stateVersion or lib.trivial.release;
   };
 }
diff --git a/modules/common/secrets.nix b/modules/common/secrets.nix
index 77dee44..2b8082e 100644
--- a/modules/common/secrets.nix
+++ b/modules/common/secrets.nix
@@ -6,11 +6,10 @@
   this,
   ...
 }:
-with lib;
 {
   imports = [
     inputs.agenix.nixosModules.default
-    (mkAliasOptionModule
+    (lib.mkAliasOptionModule
       [ "secrets" ]
       [
         "age"
@@ -22,9 +21,11 @@ with lib;
   config = {
     age.identityPaths =
       if this.isHeadful then
-        [ "${config.my.home}/.ssh/id_${my.ssh.type}" ]
+        [ "${config.my.home}/.ssh/id_${lib.my.ssh.type}" ]
       else
-        map (attr: attr.path) (filter (attr: attr.type == my.ssh.type) config.services.openssh.hostKeys);
+        config.services.openssh.hostKeys
+        |> lib.filter (attr: attr.type == lib.my.ssh.type)
+        |> map (attr: attr.path);
 
     environment.systemPackages = with pkgs; [
       age
diff --git a/modules/common/shell/default.nix b/modules/common/shell/default.nix
index 6c0b78f..7c6c835 100644
--- a/modules/common/shell/default.nix
+++ b/modules/common/shell/default.nix
@@ -182,7 +182,7 @@ in
         command-not-found.enable = false;
       };
 
-      home.packages = with pkgs; [ grc ];
+      home.packages = [ pkgs.grc ];
     };
 
     programs.command-not-found.enable = false;
diff --git a/modules/common/stylix.nix b/modules/common/stylix.nix
index 4476260..22c21c1 100644
--- a/modules/common/stylix.nix
+++ b/modules/common/stylix.nix
@@ -6,11 +6,10 @@
   this,
   ...
 }:
-with lib;
 {
   imports = [
     inputs.stylix.nixosModules.stylix
-    (mkAliasOptionModule
+    (lib.mkAliasOptionModule
       [ "colors" ]
       [
         "lib"
@@ -20,7 +19,7 @@ with lib;
     )
   ];
 
-  options.nixfiles.modules.common.stylix.fonts.extraPackages = mkOption {
+  options.nixfiles.modules.common.stylix.fonts.extraPackages = lib.mkOption {
     description = "Font packages.";
     default = with pkgs; [
       font-awesome
@@ -84,31 +83,31 @@ with lib;
     };
 
     fonts = {
-      packages = mkAfter config.nixfiles.modules.common.stylix.fonts.extraPackages;
+      packages = lib.mkAfter config.nixfiles.modules.common.stylix.fonts.extraPackages;
 
       fontconfig = {
         enable = this.isHeadful;
 
         defaultFonts = with config.stylix.fonts; {
-          serif = mkForce [
+          serif = lib.mkForce [
             serif.name
             "Sarasa Gothic"
             "Source Han Serif"
             "Noto Serif"
           ];
-          sansSerif = mkForce [
+          sansSerif = lib.mkForce [
             sansSerif.name
             "Sarasa Gothic"
             "Source Han Sans"
             "Noto Sans"
           ];
-          monospace = mkForce [
+          monospace = lib.mkForce [
             monospace.name
             "Sarasa Mono"
             "Source Han Mono"
             "Noto Sans Mono"
           ];
-          emoji = mkForce [
+          emoji = lib.mkForce [
             emoji.name
             "Noto Color Emoji"
           ];
diff --git a/modules/common/users.nix b/modules/common/users.nix
index e0811b7..ffe6234 100644
--- a/modules/common/users.nix
+++ b/modules/common/users.nix
@@ -1,16 +1,15 @@
 { lib, ... }:
-with lib;
 let
-  home = "/home/${my.username}";
+  home = "/home/${lib.my.username}";
 in
 {
   imports = [
-    (mkAliasOptionModule
+    (lib.mkAliasOptionModule
       [ "my" ]
       [
         "users"
         "users"
-        my.username
+        lib.my.username
       ]
     )
   ];
@@ -26,13 +25,13 @@ in
         password = null;
       };
 
-      ${my.username} = {
+      ${lib.my.username} = {
         isNormalUser = true;
         uid = 1000;
-        description = my.fullname;
+        description = lib.my.fullname;
         inherit home;
-        inherit (my) hashedPassword;
-        openssh.authorizedKeys.keys = [ my.ssh.key ];
+        inherit (lib.my) hashedPassword;
+        openssh.authorizedKeys.keys = [ lib.my.ssh.key ];
         extraGroups = [ "wheel" ];
       };
     };
diff --git a/modules/common/xdg.nix b/modules/common/xdg.nix
index e91d2c5..805afe1 100644
--- a/modules/common/xdg.nix
+++ b/modules/common/xdg.nix
@@ -93,21 +93,24 @@ in
     };
 
     hm.xdg = lib.mkMerge [
-      (with cfg; {
+      {
         enable = true;
 
-        inherit cacheHome;
-        inherit configHome;
-        inherit dataHome;
-        inherit stateHome;
-        inherit userDirs;
-      })
+        inherit (cfg)
+          cacheHome
+          configHome
+          dataHome
+          stateHome
+          userDirs
+          ;
+      }
       (lib.mkIf this.isHeadful {
         mimeApps = {
           enable = true;
-          defaultApplications = lib.mkMerge (
-            lib.mapAttrsToList (n: v: lib.genAttrs v (_: [ "${n}.desktop" ])) cfg.defaultApplications
-          );
+          defaultApplications =
+            cfg.defaultApplications
+            |> lib.mapAttrsToList (n: v: lib.genAttrs v (_: [ "${n}.desktop" ]))
+            |> lib.mkMerge;
         };
       })
     ];

Consider giving Nix/NixOS a try! <3