From 4d191a27ccff4153428bc2919767b251ea3321d0 Mon Sep 17 00:00:00 2001
From: Leyla Becker <git@jan-leila.com>
Date: Mon, 25 Nov 2024 00:59:05 -0600
Subject: [PATCH] moved local to modules

---
 README.md                             |  3 --
 enviroments/common/default.nix        | 14 ---------
 home-modules/default.nix              |  1 +
 home-modules/i18n.nix                 | 42 +++++++++++++++++++++++++++
 homes/ester/default.nix               |  2 ++
 homes/leyla/default.nix               |  1 +
 homes/leyla/i18n.nix                  | 12 ++++++++
 host-modules/default.nix              |  1 +
 host-modules/home-manager/default.nix |  1 +
 host-modules/home-manager/i18n.nix    | 26 +++++++++++++++++
 host-modules/i18n.nix                 |  3 ++
 host-modules/users.nix                |  2 +-
 12 files changed, 90 insertions(+), 18 deletions(-)
 create mode 100644 home-modules/i18n.nix
 create mode 100644 homes/leyla/i18n.nix
 create mode 100644 host-modules/home-manager/i18n.nix
 create mode 100644 host-modules/i18n.nix

diff --git a/README.md b/README.md
index 9ad4261..1f152e9 100644
--- a/README.md
+++ b/README.md
@@ -10,9 +10,6 @@
 | `threshold` |           Laptop           |       Eve        |  Laptop   |
 
 # Tooling
-## Lint
-`./lint.sh`
-
 ## Rebuilding
 `./rebuild.sh`
 
diff --git a/enviroments/common/default.nix b/enviroments/common/default.nix
index 83201c4..d6d44ed 100644
--- a/enviroments/common/default.nix
+++ b/enviroments/common/default.nix
@@ -1,18 +1,4 @@
 {...}: {
   # Enable networking
   networking.networkmanager.enable = true;
-
-  i18n.defaultLocale = "en_US.UTF-8";
-
-  i18n.extraLocaleSettings = {
-    LC_ADDRESS = "en_US.UTF-8";
-    LC_IDENTIFICATION = "en_US.UTF-8";
-    LC_MEASUREMENT = "en_US.UTF-8";
-    LC_MONETARY = "en_US.UTF-8";
-    LC_NAME = "en_US.UTF-8";
-    LC_NUMERIC = "en_US.UTF-8";
-    LC_PAPER = "en_US.UTF-8";
-    LC_TELEPHONE = "en_US.UTF-8";
-    LC_TIME = "en_US.UTF-8";
-  };
 }
diff --git a/home-modules/default.nix b/home-modules/default.nix
index 1fb9724..b3f5c45 100644
--- a/home-modules/default.nix
+++ b/home-modules/default.nix
@@ -1,5 +1,6 @@
 {...}: {
   imports = [
     ./flipperzero.nix
+    ./i18n.nix
   ];
 }
diff --git a/home-modules/i18n.nix b/home-modules/i18n.nix
new file mode 100644
index 0000000..2c93e59
--- /dev/null
+++ b/home-modules/i18n.nix
@@ -0,0 +1,42 @@
+{
+  lib,
+  config,
+  ...
+}: {
+  options = {
+    i18n = {
+      defaultLocale = lib.mkOption {
+        type = lib.types.str;
+        default = "en_US.UTF-8";
+        example = "nl_NL.UTF-8";
+        description = ''
+          The default locale.  It determines the language for program
+          messages, the format for dates and times, sort order, and so on.
+          It also determines the character set, such as UTF-8.
+        '';
+      };
+
+      extraLocaleSettings = lib.mkOption {
+        type = lib.types.attrsOf lib.types.str;
+        default = {};
+        example = {
+          LC_MESSAGES = "en_US.UTF-8";
+          LC_TIME = "de_DE.UTF-8";
+        };
+        description = ''
+          A set of additional system-wide locale settings other than
+          `LANG` which can be configured with
+          {option}`i18n.defaultLocale`.
+        '';
+      };
+    };
+  };
+
+  config = {
+    home.sessionVariables =
+      {
+        LANG = config.i18n.defaultLocale;
+      }
+      // config.i18n.extraLocaleSettings;
+  };
+}
diff --git a/homes/ester/default.nix b/homes/ester/default.nix
index 29d668f..181a487 100644
--- a/homes/ester/default.nix
+++ b/homes/ester/default.nix
@@ -37,6 +37,8 @@ in {
         # '';
       };
 
+      keyboard.layout = "it,us";
+
       # Home Manager can also manage your environment variables through
       # 'home.sessionVariables'. If you don't want to manage your shell through Home
       # Manager then you have to manually source 'hm-session-vars.sh' located at
diff --git a/homes/leyla/default.nix b/homes/leyla/default.nix
index a879526..ba8535d 100644
--- a/homes/leyla/default.nix
+++ b/homes/leyla/default.nix
@@ -4,6 +4,7 @@
   ...
 }: {
   imports = [
+    ./i18n.nix
     ./packages.nix
   ];
 
diff --git a/homes/leyla/i18n.nix b/homes/leyla/i18n.nix
new file mode 100644
index 0000000..a4f41dd
--- /dev/null
+++ b/homes/leyla/i18n.nix
@@ -0,0 +1,12 @@
+{...}: {
+  i18n = {
+    defaultLocale = "en_IE.UTF-8";
+
+    extraLocaleSettings = {
+      # LC_ADDRESS = "en_IE.UTF-8"; # lets just get used to this one now
+      # LC_TELEPHONE = "en_IE.UTF-8"; # lets just get used to this one now
+      LC_MONETARY = "en_US.UTF-8"; # to be changed once I move
+      LC_PAPER = "en_US.UTF-8"; # convient for american printers until I move
+    };
+  };
+}
diff --git a/host-modules/default.nix b/host-modules/default.nix
index a90caf1..4ad79d0 100644
--- a/host-modules/default.nix
+++ b/host-modules/default.nix
@@ -5,6 +5,7 @@
     ./users.nix
     ./desktop.nix
     ./nix-development.nix
+    ./i18n.nix
     ./home-manager
   ];
 }
diff --git a/host-modules/home-manager/default.nix b/host-modules/home-manager/default.nix
index 885e035..5454594 100644
--- a/host-modules/home-manager/default.nix
+++ b/host-modules/home-manager/default.nix
@@ -2,5 +2,6 @@
 {...}: {
   imports = [
     ./flipperzero.nix
+    ./i18n.nix
   ];
 }
diff --git a/host-modules/home-manager/i18n.nix b/host-modules/home-manager/i18n.nix
new file mode 100644
index 0000000..78b86fa
--- /dev/null
+++ b/host-modules/home-manager/i18n.nix
@@ -0,0 +1,26 @@
+{
+  lib,
+  config,
+  ...
+}: let
+  home-users = lib.attrsets.mapAttrsToList (_: user: user) config.home-manager.users;
+in {
+  config = {
+    i18n.supportedLocales =
+      lib.unique
+      (builtins.map (l: (lib.replaceStrings ["utf8" "utf-8" "UTF8"] ["UTF-8" "UTF-8" "UTF-8"] l) + "/UTF-8") (
+        [
+          "C.UTF-8"
+          "en_US.UTF-8"
+          config.i18n.defaultLocale
+        ]
+        ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
+        ++ (
+          map (user-config: user-config.i18n.defaultLocale) home-users
+        )
+        ++ (lib.lists.flatten (
+          map (user-config: lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") user-config.i18n.extraLocaleSettings)) home-users
+        ))
+      ));
+  };
+}
diff --git a/host-modules/i18n.nix b/host-modules/i18n.nix
new file mode 100644
index 0000000..eada12c
--- /dev/null
+++ b/host-modules/i18n.nix
@@ -0,0 +1,3 @@
+{...}: {
+  i18n.defaultLocale = "en_IE.UTF-8";
+}
diff --git a/host-modules/users.nix b/host-modules/users.nix
index 154de89..23771a3 100644
--- a/host-modules/users.nix
+++ b/host-modules/users.nix
@@ -53,7 +53,7 @@ in {
       }: {
         options = {
           name = lib.mkOption {
-            type = lib.types.string;
+            type = lib.types.str;
             default = name;
             description = ''
               What should this users name on the system be