From 1230ff387ba4e651ef8c4e33d46f65c32987f216 Mon Sep 17 00:00:00 2001 From: kat witch Date: Thu, 5 Aug 2021 21:47:54 +0100 Subject: [PATCH] home-manager kat user refactor --- config/hosts/beltane/nixos.nix | 6 ------ config/hosts/samhain/nixos.nix | 6 ------ config/hosts/yule/nixos.nix | 6 ------ config/users/kat/base.nix | 24 ------------------------ config/users/kat/default.nix | 27 ++++++++++++++++++--------- config/users/kat/dev.nix | 5 ----- config/users/kat/gui.nix | 5 ----- config/users/kat/media.nix | 5 ----- config/users/kat/personal.nix | 5 ----- config/users/kat/sway.nix | 5 ----- pkgs/lib/default.nix | 4 ++-- pkgs/lib/host-import.nix | 13 +++++++++++-- pkgs/lib/module-list.nix | 5 +++-- 13 files changed, 34 insertions(+), 82 deletions(-) delete mode 100644 config/users/kat/base.nix delete mode 100644 config/users/kat/dev.nix delete mode 100644 config/users/kat/gui.nix delete mode 100644 config/users/kat/media.nix delete mode 100644 config/users/kat/personal.nix delete mode 100644 config/users/kat/sway.nix diff --git a/config/hosts/beltane/nixos.nix b/config/hosts/beltane/nixos.nix index 58815d4d..c8445f00 100644 --- a/config/hosts/beltane/nixos.nix +++ b/config/hosts/beltane/nixos.nix @@ -19,12 +19,6 @@ with lib; ../../services/zfs.nix ]; - home-manager.users.kat = { - imports = [ - ./home.nix - ]; - }; - # File Systems and Swap boot.supportedFilesystems = singleton "zfs"; diff --git a/config/hosts/samhain/nixos.nix b/config/hosts/samhain/nixos.nix index 465a382d..61a5f945 100644 --- a/config/hosts/samhain/nixos.nix +++ b/config/hosts/samhain/nixos.nix @@ -23,12 +23,6 @@ in { ./nixos/virtualhosts.nix ]; - home-manager.users.kat = { - imports = [ - ./home.nix - ]; - }; - # File Systems and Swap boot.supportedFilesystems = [ "zfs" "xfs" ]; diff --git a/config/hosts/yule/nixos.nix b/config/hosts/yule/nixos.nix index b8393f32..ab43028f 100644 --- a/config/hosts/yule/nixos.nix +++ b/config/hosts/yule/nixos.nix @@ -18,12 +18,6 @@ with lib; ../../services/nginx.nix ]; - home-manager.users.kat = { - imports = [ - ./home.nix - ]; - }; - # File Systems and Swap boot.supportedFilesystems = singleton "zfs"; diff --git a/config/users/kat/base.nix b/config/users/kat/base.nix deleted file mode 100644 index 7caacdc3..00000000 --- a/config/users/kat/base.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - home-manager.users.kat = { - imports = [ ./base ] ++ lib.optional (builtins.pathExists ../../trusted/users/kat) (import ../../trusted/users/kat); - home.stateVersion = "20.09"; - }; - - users.users.kat = { - uid = 1000; - isNormalUser = true; - openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCocjQqiDIvzq+Qu3jkf7FXw5piwtvZ1Mihw9cVjdVcsra3U2c9WYtYrA3rS50N3p00oUqQm9z1KUrvHzdE+03ZCrvaGdrtYVsaeoCuuvw7qxTQRbItTAEsfRcZLQ5c1v/57HNYNEsjVrt8VukMPRXWgl+lmzh37dd9w45cCY1QPi+JXQQ/4i9Vc3aWSe4X6PHOEMSBHxepnxm5VNHm4PObGcVbjBf0OkunMeztd1YYA9sEPyEK3b8IHxDl34e5t6NDLCIDz0N/UgzCxSxoz+YJ0feQuZtud/YLkuQcMxW2dSGvnJ0nYy7SA5DkW1oqcy6CGDndHl5StOlJ1IF9aGh0gGkx5SRrV7HOGvapR60RphKrR5zQbFFka99kvSQgOZqSB3CGDEQGHv8dXKXIFlzX78jjWDOBT67vA/M9BK9FS2iNnBF5x6shJ9SU5IK4ySxq8qvN7Us8emkN3pyO8yqgsSOzzJT1JmWUAx0tZWG/BwKcFBHfceAPQl6pwxx28TM3BTBRYdzPJLTkAy48y6iXW6UYdfAPlShy79IYjQtEThTuIiEzdzgYdros0x3PDniuAP0KOKMgbikr0gRa6zahPjf0qqBnHeLB6nHAfaVzI0aNbhOg2bdOueE1FX0x48sjKqjOpjlIfq4WeZp9REr2YHEsoLFOBfgId5P3BPtpBQ== cardno:000612078454" - ]; - shell = pkgs.zsh; - extraGroups = [ "wheel" "video" "systemd-journal" "plugdev" ]; - hashedPassword = - "$6$i28yOXoo$/WokLdKds5ZHtJHcuyGrH2WaDQQk/2Pj0xRGLgS8UcmY2oMv3fw2j/85PRpsJJwCB2GBRYRK5LlvdTleHd3mB."; - }; - - systemd.tmpfiles.rules = [ - "f /var/lib/systemd/linger/kat" - ]; -} diff --git a/config/users/kat/default.nix b/config/users/kat/default.nix index 0ef42f6b..2bc2319c 100644 --- a/config/users/kat/default.nix +++ b/config/users/kat/default.nix @@ -1,11 +1,20 @@ -rec { - base = ./base.nix; - gui = ./gui.nix; - sway = ./sway.nix; - dev = ./dev.nix; - media = ./media.nix; - personal = ./personal.nix; - +let katUser = { lib }: let + userImport = profile: { config, ... }: { + config.home-manager.users.kat = { + imports = [ + (./. + "/${profile}") + ]; + }; +}; profileNames = [ + "gui" + "sway" + "dev" + "media" + "personal" +]; userProfiles = with userProfiles; + lib.genAttrs profileNames userImport // { + base = { imports = [ ./nixos.nix (userImport "base") ]; }; server = { imports = [ personal ]; }; guiFull = { imports = [ gui sway dev media personal ]; }; -} +}; in userProfiles; +in { __functor = self: katUser; isModule = false; } diff --git a/config/users/kat/dev.nix b/config/users/kat/dev.nix deleted file mode 100644 index df631346..00000000 --- a/config/users/kat/dev.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: - -{ - home-manager.users.kat = { imports = [ ./dev ]; }; -} diff --git a/config/users/kat/gui.nix b/config/users/kat/gui.nix deleted file mode 100644 index 7a8e0af0..00000000 --- a/config/users/kat/gui.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: - -{ - home-manager.users.kat = { imports = [ ./gui ]; }; -} diff --git a/config/users/kat/media.nix b/config/users/kat/media.nix deleted file mode 100644 index 381260ea..00000000 --- a/config/users/kat/media.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: - -{ - home-manager.users.kat = { imports = [ ./media ]; }; -} diff --git a/config/users/kat/personal.nix b/config/users/kat/personal.nix deleted file mode 100644 index 40f899aa..00000000 --- a/config/users/kat/personal.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: - -{ - home-manager.users.kat = { imports = [ ./personal ]; }; -} diff --git a/config/users/kat/sway.nix b/config/users/kat/sway.nix deleted file mode 100644 index 6218e9d6..00000000 --- a/config/users/kat/sway.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: - -{ - home-manager.users.kat = { imports = [ ./sway ]; }; -} diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index 5b867eac..497daaf6 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -8,9 +8,9 @@ }@args: let colorHelpers = import ./color-helpers.nix { inherit lib; }; lib = before // katlib // self; - katlib = with before; with katlib; with self; + katlib = with before; with katlib; with self; { inherit (colorHelpers) hextorgba; hostImport = import ./host-import.nix { inherit lib; }; - modList = import ./module-list.nix; + modList = import ./module-list.nix { inherit lib; }; }; in katlib diff --git a/pkgs/lib/host-import.nix b/pkgs/lib/host-import.nix index 88b52d67..f0d04251 100644 --- a/pkgs/lib/host-import.nix +++ b/pkgs/lib/host-import.nix @@ -1,6 +1,15 @@ -{ lib }: hostName: lib.filter builtins.pathExists [ +{ lib }: hostName: with lib; filter builtins.pathExists [ (../../config/hosts + "/${hostName}/nixos.nix") (../../config/trusted/hosts + "/${hostName}/nixos.nix") ../../config/trusted/profile ../../config/profiles/base -] +] ++ singleton { + options.home-manager.users = mkOption { + type = types.attrsOf (types.submoduleWith { + modules = filter builtins.pathExists [ + (../../config/hosts + "/${hostName}/home.nix") + (../../config/trusted/hosts + "/${hostName}/home.nix") + ]; + }); + }; +} diff --git a/pkgs/lib/module-list.nix b/pkgs/lib/module-list.nix index be9efda3..e546ea48 100644 --- a/pkgs/lib/module-list.nix +++ b/pkgs/lib/module-list.nix @@ -1,8 +1,9 @@ -{ modulesDir, defaultFile ? "default.nix", importAll ? false }: +{ lib }: { modulesDir, defaultFile ? "default.nix", importAll ? false }: with builtins; let + isModule = m: lib.isFunction m && (m.isModule or true); filterAttrNamesToList = filter: set: foldl' (a: b: a ++ b) [ ] (map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set)); @@ -20,7 +21,7 @@ let in { inherit name; - value = if (isFunction m) && !importAll then value else m; + value = if lib.isFunction m && ! isModule m then m { inherit lib; } else if isModule m && !importAll then value else m; }) files; in