From 279ff6251173e161cc50d8ae03cb3cd2e90a61a4 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Mon, 3 Jun 2024 18:28:35 +0530 Subject: global: init global contains shared data between home-manager and nixos modules. they're just structured data, it's doesn't contain any module functionally in the normal sense, an example is preferred monospace font or user's mail id `config.global.userdata.email` --- flake.nix | 4 ++-- global/default.nix | 5 +++++ global/userdata.nix | 26 ++++++++++++++++++++++++ home/common/home.nix | 2 +- home/common/modules/git.nix | 4 ++-- os/cez/configuration.nix | 2 +- os/cez/modules/getty.nix | 2 +- os/cez/modules/sshfs.nix | 4 ++-- os/cez/modules/wayland.nix | 2 +- os/cez/modules/wireguard.nix | 2 +- os/common/configuration.nix | 4 ++-- os/common/modules/dev.nix | 2 +- os/dspace/configuration.nix | 2 +- os/fscusat/modules/mirror/debian/default.nix | 4 ++-- os/kay/modules/acme.nix | 4 ++-- os/kay/modules/cgit.nix | 4 ++-- os/kay/modules/dendrite.nix | 2 +- os/kay/modules/mail.nix | 4 ++-- os/kay/modules/matrix-sliding-sync.nix | 2 +- os/kay/modules/sftp.nix | 2 +- os/kay/modules/www.nix | 2 +- userdata.nix | 30 ---------------------------- 22 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 global/default.nix create mode 100644 global/userdata.nix delete mode 100644 userdata.nix diff --git a/flake.nix b/flake.nix index f93be2e..f6d8161 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; } - ./userdata.nix + ./global ./os/${host}/configuration.nix sops-nix.nixosModules.sops ]; @@ -35,7 +35,7 @@ makeHome = useType: system: home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; modules = [ - ./userdata.nix + ./global ./home/${useType}/home.nix ]; }; diff --git a/global/default.nix b/global/default.nix new file mode 100644 index 0000000..5bcb1ba --- /dev/null +++ b/global/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + imports = [ + ./userdata.nix + ]; +} diff --git a/global/userdata.nix b/global/userdata.nix new file mode 100644 index 0000000..d591920 --- /dev/null +++ b/global/userdata.nix @@ -0,0 +1,26 @@ +{ config, lib, ... }: let + cfg = config.global.userdata; +in { + options.global.userdata = { + name = lib.mkOption { + type = lib.types.str; + default = "sinan"; + description = "Owner's username"; + }; + nameFq = lib.mkOption { + type = lib.types.str; + default = "sinanmohd"; + description = "Owner's fully qualified username"; + }; + domain = lib.mkOption { + type = lib.types.str; + default = "sinanmohd.com"; + description = "Owner's domain"; + }; + email = lib.mkOption { + type = lib.types.str; + default = "${cfg.name}@${cfg.domain}"; + description = "Owner's email"; + }; + }; +} diff --git a/home/common/home.nix b/home/common/home.nix index 4ee0d94..b2ca191 100644 --- a/home/common/home.nix +++ b/home/common/home.nix @@ -1,5 +1,5 @@ { config, ... }: let - username = config.userdata.name; + username = config.global.userdata.name; in { imports = [ ./modules/git.nix diff --git a/home/common/modules/git.nix b/home/common/modules/git.nix index 7337f7b..1f10da7 100644 --- a/home/common/modules/git.nix +++ b/home/common/modules/git.nix @@ -1,6 +1,6 @@ { config, ... }: let - userName = config.userdata.nameFq; - userEmail = config.userdata.email; + userName = config.global.userdata.nameFq; + userEmail = config.global.userdata.email; in { programs.git = { enable = true; diff --git a/os/cez/configuration.nix b/os/cez/configuration.nix index 00e755a..c7f865d 100644 --- a/os/cez/configuration.nix +++ b/os/cez/configuration.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: let - user = config.userdata.name; + user = config.global.userdata.name; in { imports = [ diff --git a/os/cez/modules/getty.nix b/os/cez/modules/getty.nix index 725eb4b..8c7f57e 100644 --- a/os/cez/modules/getty.nix +++ b/os/cez/modules/getty.nix @@ -1,5 +1,5 @@ { config, ... }: let - user = config.userdata.name; + user = config.global.userdata.name; in { systemd.services."getty@".serviceConfig.TTYVTDisallocate = "no"; diff --git a/os/cez/modules/sshfs.nix b/os/cez/modules/sshfs.nix index 2431b96..5fdbeaf 100644 --- a/os/cez/modules/sshfs.nix +++ b/os/cez/modules/sshfs.nix @@ -1,8 +1,8 @@ { config, pkgs, ... }: let - domain = config.userdata.domain; - user = config.userdata.name; + domain = config.global.userdata.domain; + user = config.global.userdata.name; uid = config.users.users.${user}.uid; gid = config.users.groups.users.gid; in diff --git a/os/cez/modules/wayland.nix b/os/cez/modules/wayland.nix index 1ce04cf..b6499b7 100644 --- a/os/cez/modules/wayland.nix +++ b/os/cez/modules/wayland.nix @@ -1,5 +1,5 @@ { config, pkgs, ... }: let - user = config.userdata.name; + user = config.global.userdata.name; in { # pkgs environment.systemPackages = with pkgs; [ diff --git a/os/cez/modules/wireguard.nix b/os/cez/modules/wireguard.nix index d8e8dd0..706751c 100644 --- a/os/cez/modules/wireguard.nix +++ b/os/cez/modules/wireguard.nix @@ -1,7 +1,7 @@ { config, ... }: let - domain = config.userdata.domain; + domain = config.global.userdata.domain; in { sops.secrets."misc/wireguard" = {}; diff --git a/os/common/configuration.nix b/os/common/configuration.nix index 76fe33c..a3dd494 100644 --- a/os/common/configuration.nix +++ b/os/common/configuration.nix @@ -2,8 +2,8 @@ let host = config.networking.hostName; - user = config.userdata.name; - email = config.userdata.email; + user = config.global.userdata.name; + email = config.global.userdata.email; in { disabledModules = [ diff --git a/os/common/modules/dev.nix b/os/common/modules/dev.nix index 285dfba..eb00619 100644 --- a/os/common/modules/dev.nix +++ b/os/common/modules/dev.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: let - user = config.userdata.name; + user = config.global.userdata.name; in { users.users.${user}.packages = with pkgs; [ diff --git a/os/dspace/configuration.nix b/os/dspace/configuration.nix index 0a28af6..0bcf330 100644 --- a/os/dspace/configuration.nix +++ b/os/dspace/configuration.nix @@ -1,7 +1,7 @@ { config, ... }: let - user = config.userdata.name; + user = config.global.userdata.name; in { imports = [ diff --git a/os/fscusat/modules/mirror/debian/default.nix b/os/fscusat/modules/mirror/debian/default.nix index c052bdd..c0a35cd 100644 --- a/os/fscusat/modules/mirror/debian/default.nix +++ b/os/fscusat/modules/mirror/debian/default.nix @@ -1,6 +1,6 @@ { config, ... }: let - name = config.userdata.name; - email = config.userdata.email; + name = config.global.userdata.name; + email = config.global.userdata.email; in { imports = [ ./ftpsync.nix ]; diff --git a/os/kay/modules/acme.nix b/os/kay/modules/acme.nix index f4ded0a..00819e7 100644 --- a/os/kay/modules/acme.nix +++ b/os/kay/modules/acme.nix @@ -1,6 +1,6 @@ { config, pkgs, ... }: let - email = config.userdata.email; - domain = config.userdata.domain; + email = config.global.userdata.email; + domain = config.global.userdata.domain; environmentFile = pkgs.writeText "acme-dns" "RFC2136_NAMESERVER='[2001:470:ee65::1]:53'"; diff --git a/os/kay/modules/cgit.nix b/os/kay/modules/cgit.nix index f8fb25c..0b0a6ec 100644 --- a/os/kay/modules/cgit.nix +++ b/os/kay/modules/cgit.nix @@ -1,8 +1,8 @@ { config, pkgs, ... }: let - domain = config.userdata.domain; - user = config.userdata.name; + domain = config.global.userdata.domain; + user = config.global.userdata.name; in { environment.systemPackages = with pkgs; [ diff --git a/os/kay/modules/dendrite.nix b/os/kay/modules/dendrite.nix index 8277e21..71266a5 100644 --- a/os/kay/modules/dendrite.nix +++ b/os/kay/modules/dendrite.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: let - domain = config.userdata.domain; + domain = config.global.userdata.domain; database = { connection_string = "postgres:///dendrite?host=/run/postgresql"; max_open_conns = 90; diff --git a/os/kay/modules/mail.nix b/os/kay/modules/mail.nix index 79e4019..ee91f78 100644 --- a/os/kay/modules/mail.nix +++ b/os/kay/modules/mail.nix @@ -1,8 +1,8 @@ { config, ... }: let ipv6 = "2001:470:ee65::1337"; - domain = config.userdata.domain; + domain = config.global.userdata.domain; - username = config.userdata.name; + username = config.global.userdata.name; secret = "$argon2i$v=19$m=4096,t=3,p=1$SWV5aWU3YWUgZWFTNm9oc28gTGFvdDdlRG8ga2FTaWVjaDYgYWV0aDFHb28$O/sDv7oy9wUxFjvKoxB5o8ZnPvjYJo9DjX0C/AZQFF0"; email = [ "${username}@${domain}" diff --git a/os/kay/modules/matrix-sliding-sync.nix b/os/kay/modules/matrix-sliding-sync.nix index ebdc34d..03ab9fc 100644 --- a/os/kay/modules/matrix-sliding-sync.nix +++ b/os/kay/modules/matrix-sliding-sync.nix @@ -1,7 +1,7 @@ { config, ... }: let - domain = config.userdata.domain; + domain = config.global.userdata.domain; in { sops.secrets."matrix-${domain}/sliding_sync" = {}; diff --git a/os/kay/modules/sftp.nix b/os/kay/modules/sftp.nix index bbe055e..f3c3538 100644 --- a/os/kay/modules/sftp.nix +++ b/os/kay/modules/sftp.nix @@ -2,7 +2,7 @@ let storage = "/hdd/users"; - user = config.userdata.name; + user = config.global.userdata.name; pubKeys = config.users.users.${user}.openssh.authorizedKeys.keys; in { diff --git a/os/kay/modules/www.nix b/os/kay/modules/www.nix index 3891bf6..54eab65 100644 --- a/os/kay/modules/www.nix +++ b/os/kay/modules/www.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: let - domain = config.userdata.domain; + domain = config.global.userdata.domain; fscusat = "fscusat.org"; mark = "themark.ing"; storage = "/hdd/users/sftp/shr"; diff --git a/userdata.nix b/userdata.nix deleted file mode 100644 index 564f1f0..0000000 --- a/userdata.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ config, lib, ... }: - -let - inherit (lib) mkOption types; - cfg = config.userdata; -in -{ - options.userdata = { - name = mkOption { - type = types.str; - default = "sinan"; - description = "Owner's username"; - }; - nameFq = mkOption { - type = types.str; - default = "sinanmohd"; - description = "Owner's fully qualified username"; - }; - domain = mkOption { - type = types.str; - default = "sinanmohd.com"; - description = "Owner's domain"; - }; - email = mkOption { - type = types.str; - default = "${cfg.name}@${cfg.domain}"; - description = "Owner's email"; - }; - }; -} -- cgit v1.2.3