From 62e400ddebc4897a8185d6564a42d08ea53dcffa Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 7 Jul 2024 17:12:00 -0400 Subject: [PATCH] move user settings from nixosModules to userModules --- flake.nix | 4 ++ hosts/fallarbor/default.nix | 1 - nixosModules/default.nix | 1 - nixosModules/options.nix | 62 ------------------- nixosModules/services/syncthing/default.nix | 4 +- nixosModules/users/default.nix | 25 -------- .../users => userModules}/aly/default.nix | 10 +-- userModules/default.nix | 24 +++++++ .../users => userModules}/dustin/default.nix | 2 +- .../users => userModules}/morgan/default.nix | 2 +- userModules/options.nix | 42 +++++++++++++ 11 files changed, 79 insertions(+), 98 deletions(-) delete mode 100644 nixosModules/users/default.nix rename {nixosModules/users => userModules}/aly/default.nix (75%) create mode 100644 userModules/default.nix rename {nixosModules/users => userModules}/dustin/default.nix (91%) rename {nixosModules/users => userModules}/morgan/default.nix (91%) create mode 100644 userModules/options.nix diff --git a/flake.nix b/flake.nix index 9af40e69..23be6171 100644 --- a/flake.nix +++ b/flake.nix @@ -78,6 +78,9 @@ nixosModules.nixos = import ./nixosModules inputs; + nixosModules.users = + import ./userModules inputs; + nixosConfigurations = inputs.nixpkgs.lib.genAttrs [ "fallarbor" @@ -100,6 +103,7 @@ inputs.nur.nixosModules.nur inputs.raffauflabs.nixosModules.raffauflabs self.nixosModules.nixos + self.nixosModules.users { home-manager = { diff --git a/hosts/fallarbor/default.nix b/hosts/fallarbor/default.nix index 0936502a..4c2e649f 100644 --- a/hosts/fallarbor/default.nix +++ b/hosts/fallarbor/default.nix @@ -4,7 +4,6 @@ inputs, lib, pkgs, - self, ... }: { imports = [ diff --git a/nixosModules/default.nix b/nixosModules/default.nix index c9081ed1..4829d8b5 100644 --- a/nixosModules/default.nix +++ b/nixosModules/default.nix @@ -10,6 +10,5 @@ inputs: { ./desktop ./options.nix ./services - ./users ]; } diff --git a/nixosModules/options.nix b/nixosModules/options.nix index 02a00ce5..fa2a83c4 100644 --- a/nixosModules/options.nix +++ b/nixosModules/options.nix @@ -108,67 +108,5 @@ }; }; }; - - users = { - defaultGroups = lib.mkOption { - description = "Default groups for desktop users."; - default = [ - "dialout" - "docker" - "libvirtd" - "lp" - "networkmanager" - "scanner" - "transmission" - "video" - "wheel" - ]; - }; - - aly = { - enable = lib.mkEnableOption "Aly's user."; - - manageHome = lib.mkOption { - description = "Whether to enable aly's home directory."; - type = lib.types.bool; - default = config.ar.users.aly.enable; - }; - - password = lib.mkOption { - description = "Hashed password for aly."; - type = lib.types.str; - }; - }; - - dustin = { - enable = lib.mkEnableOption "Dustin's user."; - - manageHome = lib.mkOption { - description = "Whether to manage dustin's home directory."; - type = lib.types.bool; - default = config.ar.users.dustin.enable; - }; - - password = lib.mkOption { - description = "Hashed password for dustin."; - type = lib.types.str; - }; - }; - - morgan = { - enable = lib.mkEnableOption "Morgan's user."; - - manageHome = lib.mkOption { - description = "Whether to manage morgan's home directory."; - type = lib.types.bool; - default = config.ar.users.morgan.enable; - }; - - password = lib.mkOption { - description = "Hashed password for morgan."; - type = lib.types.str; - }; - }; - }; }; } diff --git a/nixosModules/services/syncthing/default.nix b/nixosModules/services/syncthing/default.nix index 02de0180..209b5948 100644 --- a/nixosModules/services/syncthing/default.nix +++ b/nixosModules/services/syncthing/default.nix @@ -1,7 +1,7 @@ { - pkgs, - lib, config, + lib, + pkgs, ... }: { imports = [./syncMusic.nix]; diff --git a/nixosModules/users/default.nix b/nixosModules/users/default.nix deleted file mode 100644 index 38f06fcd..00000000 --- a/nixosModules/users/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - config, - inputs, - lib, - pkgs, - self, - ... -}: { - imports = [ - ./aly - ./dustin - ./morgan - ]; - - users = { - mutableUsers = false; - - users.root.openssh.authorizedKeys.keyFiles = [ - ../../secrets/publicKeys/aly_lavaridge.pub - ../../secrets/publicKeys/aly_mauville.pub - ../../secrets/publicKeys/aly_petalburg.pub - ../../secrets/publicKeys/aly_rustboro.pub - ]; - }; -} diff --git a/nixosModules/users/aly/default.nix b/userModules/aly/default.nix similarity index 75% rename from nixosModules/users/aly/default.nix rename to userModules/aly/default.nix index 3859d931..cad67464 100644 --- a/nixosModules/users/aly/default.nix +++ b/userModules/aly/default.nix @@ -8,7 +8,7 @@ home-manager.users.aly = lib.attrsets.optionalAttrs config.ar.users.aly.manageHome - (import ../../../homes/aly); + (import ../../homes/aly); users.users.aly = { description = "Aly Raffauf"; @@ -24,10 +24,10 @@ ]; keyFiles = [ - ../../../secrets/publicKeys/aly_lavaridge.pub - ../../../secrets/publicKeys/aly_mauville.pub - ../../../secrets/publicKeys/aly_petalburg.pub - ../../../secrets/publicKeys/aly_rustboro.pub + ../../secrets/publicKeys/aly_lavaridge.pub + ../../secrets/publicKeys/aly_mauville.pub + ../../secrets/publicKeys/aly_petalburg.pub + ../../secrets/publicKeys/aly_rustboro.pub ]; }; diff --git a/userModules/default.nix b/userModules/default.nix new file mode 100644 index 00000000..baf5e2b3 --- /dev/null +++ b/userModules/default.nix @@ -0,0 +1,24 @@ +inputs: { + config, + pkgs, + lib, + ... +}: { + imports = [ + ./aly + ./dustin + ./morgan + ./options.nix + ]; + + users = { + mutableUsers = false; + + users.root.openssh.authorizedKeys.keyFiles = [ + ../secrets/publicKeys/aly_lavaridge.pub + ../secrets/publicKeys/aly_mauville.pub + ../secrets/publicKeys/aly_petalburg.pub + ../secrets/publicKeys/aly_rustboro.pub + ]; + }; +} diff --git a/nixosModules/users/dustin/default.nix b/userModules/dustin/default.nix similarity index 91% rename from nixosModules/users/dustin/default.nix rename to userModules/dustin/default.nix index 9b3215cb..756832e7 100644 --- a/nixosModules/users/dustin/default.nix +++ b/userModules/dustin/default.nix @@ -8,7 +8,7 @@ home-manager.users.dustin = lib.attrsets.optionalAttrs config.ar.users.dustin.manageHome - (import ../../../homes/dustin); + (import ../../homes/dustin); users.users.dustin = { description = "Dustin Raffauf"; diff --git a/nixosModules/users/morgan/default.nix b/userModules/morgan/default.nix similarity index 91% rename from nixosModules/users/morgan/default.nix rename to userModules/morgan/default.nix index 92b500cf..2b93f190 100644 --- a/nixosModules/users/morgan/default.nix +++ b/userModules/morgan/default.nix @@ -8,7 +8,7 @@ home-manager.users.morgan = lib.attrsets.optionalAttrs config.ar.users.morgan.manageHome - (import ../../../homes/morgan); + (import ../../homes/morgan); users.users.morgan = { description = "Morgan Tamayo"; diff --git a/userModules/options.nix b/userModules/options.nix new file mode 100644 index 00000000..9af90273 --- /dev/null +++ b/userModules/options.nix @@ -0,0 +1,42 @@ +{ + config, + lib, + pkgs, + ... +}: { + options.ar.users = let + mkUser = user: { + enable = lib.mkEnableOption "${user}."; + + manageHome = lib.mkOption { + description = "Whether to manage ${user}'s home directory."; + type = lib.types.bool; + default = true; + }; + + password = lib.mkOption { + description = "Hashed password for ${user}."; + type = lib.types.str; + }; + }; + in { + defaultGroups = lib.mkOption { + description = "Default groups for desktop users."; + default = [ + "dialout" + "docker" + "libvirtd" + "lp" + "networkmanager" + "scanner" + "transmission" + "video" + "wheel" + ]; + }; + + aly = mkUser "aly"; + dustin = mkUser "dustin"; + morgan = mkUser "morgan"; + }; +}