default.nix (1956B) - Raw
1 { 2 config, 3 lib, 4 myData, 5 ... 6 }: 7 let 8 cfg = config.mj.base.users; 9 props = with lib.types; { 10 hashedPasswordFile = lib.mkOption { 11 type = nullOr path; 12 default = null; 13 }; 14 initialPassword = lib.mkOption { 15 type = nullOr str; 16 default = null; 17 }; 18 initialHashedPassword = lib.mkOption { 19 type = nullOr str; 20 default = null; 21 }; 22 23 extraGroups = lib.mkOption { 24 type = listOf str; 25 default = [ ]; 26 }; 27 }; 28 in 29 { 30 options.mj.base.users = with lib.types; { 31 enable = lib.mkEnableOption "enable motiejus and root"; 32 user = props; 33 root = props; 34 }; 35 36 config = lib.mkIf cfg.enable { 37 users = { 38 mutableUsers = false; 39 40 users = { 41 ${config.mj.username} = { 42 isNormalUser = true; 43 extraGroups = [ 44 "wheel" 45 "dialout" 46 "video" 47 "audio" 48 ] 49 ++ cfg.user.extraGroups; 50 uid = myData.uidgid.motiejus; 51 openssh.authorizedKeys.keys = 52 let 53 fqdn = "${config.networking.hostName}.${config.networking.domain}"; 54 in 55 lib.mkMerge [ 56 [ 57 myData.people_pubkeys.motiejus 58 myData.people_pubkeys.motiejus_work 59 myData.people_pubkeys.motiejus_macworx 60 ] 61 62 (lib.mkIf (builtins.hasAttr fqdn myData.hosts) [ 63 (''from="127.0.0.1,::1" '' + myData.hosts.${fqdn}.publicKey) 64 ]) 65 ]; 66 } 67 // lib.filterAttrs (n: v: n != "extraGroups" && v != null) cfg.user or { }; 68 69 root = lib.filterAttrs (_: v: v != null) cfg.root; 70 }; 71 }; 72 73 home-manager = { 74 useGlobalPkgs = true; 75 backupFileExtension = "bk"; 76 users.${config.mj.username} = { 77 imports = [ ../../../shared/home ]; 78 home = { 79 inherit (config.mj) stateVersion username; 80 }; 81 }; 82 }; 83 }; 84 }