From a137d1b61a32e496995ae54d3c23a4187ed2d567 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 2 Feb 2019 16:53:25 +0100 Subject: Nicer user configuration --- users.nix | 33 ++++++++++----------------------- users/gkleen.nix | 2 ++ users/ineumann.nix | 2 ++ users/lkellers.nix | 2 ++ users/llovisa.nix | 2 ++ users/mherold.nix | 2 ++ users/mkleen.nix | 2 ++ users/mtrinh.nix | 2 ++ users/mwagner.nix | 2 ++ users/sgoebels.nix | 2 ++ users/some.nix | 2 ++ users/sselle.nix | 2 ++ users/templates/xmpp.nix | 9 +++++++++ users/tkleen.nix | 2 ++ users/vkleen.nix | 2 ++ users/xmpp-template.nix | 8 -------- 16 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 users/templates/xmpp.nix delete mode 100644 users/xmpp-template.nix diff --git a/users.nix b/users.nix index 6f21c51d..06d465a2 100644 --- a/users.nix +++ b/users.nix @@ -1,30 +1,17 @@ -{config, ...}: +{ config, lib, ...}: + +with lib; let - baseUsers = { - "gkleen" = import ./users/gkleen.nix; - }; - extraUsers = { - ymir = { - "mherold" = import ./users/mherold.nix; - "some" = import ./users/some.nix; - "llovisa" = import ./users/llovisa.nix; - "vkleen" = import ./users/vkleen.nix; - "tkleen" = import ./users/tkleen.nix; - "mkleen" = import ./users/mkleen.nix; - "lkellers" = import ./users/lkellers.nix; - "mwgnr" = import ./users/mwagner.nix; - "ineumann" = import ./users/ineumann.nix; - "sselle" = import ./users/sselle.nix; - "sgoebels" = import ./users/sgoebels.nix; - "mtrinh" = import ./users/mtrinh.nix; - }; - odin = { - "mherold" = import ./users/mherold.nix; - }; + genUsersList = dirPath: concatLists (let contents = builtins.readDir dirPath; in map (name: (dirEntryToList."${contents."${name}"}" or (x: [])) "${dirPath}/${name}") (attrNames contents)); + dirEntryToList = { + "regular" = path: [(import (builtins.toPath path))]; }; + + users = genUsersList ./users; host = config.networking.hostName; in { users.mutableUsers = false; - users.extraUsers = baseUsers // (if builtins.hasAttr host extraUsers then builtins.getAttr host extraUsers else {}); + users.extraUsers = listToAttrs + (map (user: nameValuePair (user.name) (removeAttrs user ["hosts" "allHosts"])) (filter (user: elem host (user.hosts or []) || (user.allHosts or false)) users)); } diff --git a/users/gkleen.nix b/users/gkleen.nix index be52116b..e8bb7295 100644 --- a/users/gkleen.nix +++ b/users/gkleen.nix @@ -12,4 +12,6 @@ keys/gkleen-hel.pub ]; hashedPassword = "$6$rounds=500000$dOMgCU7DAk$yQFYGOURTEt12387LIYBnFKSWmtwXMUk1LJWnV0m7OFt.y2TnxQn2abdGA5dhwG9EmMB5wZGXf4J5F71c746C/"; + + allHosts = true; } diff --git a/users/ineumann.nix b/users/ineumann.nix index 30caff0e..f274baca 100644 --- a/users/ineumann.nix +++ b/users/ineumann.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$ZcddLLjh9A9nT$Wdciw5g.ZHnTYcRA54LbcDePkxP.jXVgV1hRZUfCvip0noAn7AHgMimCcd570JyBzj.7clacVPsFRQZLYxWy7/"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/lkellers.nix b/users/lkellers.nix index 8b211fa3..5be78d6c 100644 --- a/users/lkellers.nix +++ b/users/lkellers.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$KHcqXGtdlq$ofrsiltqq8hMfNv0hp2hjhoDOI4/R//7A4vowp4SAJ0YRWEX6gfGqw.hxjhBfaQb/mitsKUnynqy7.eytTECv/"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/llovisa.nix b/users/llovisa.nix index ef28ee18..65a7aa4a 100644 --- a/users/llovisa.nix +++ b/users/llovisa.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$LoQJQgUQT$ZrJlmnniXXNGWWYjorn6VlroOy0IE55MK2Frqy07HxC5ie4Cd7I1w5HNKZlXGY6a0PVkZ9bYv2SzNQZRUzSA2."; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/mherold.nix b/users/mherold.nix index 4a35d2b9..fb99b19c 100644 --- a/users/mherold.nix +++ b/users/mherold.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$y5qNae9r/U/7$HbSrmPcrPl9OQvRFMeo8PDYar32Y1i/C1R5di82rN4PPQZYxg/W.anHSI5Xws6fOQmDtvGsT0lCe4NFNxuTF41"; isNormalUser = true; + + hosts = ["ymir" "odin"]; } diff --git a/users/mkleen.nix b/users/mkleen.nix index 7a78f0bc..e6e716a6 100644 --- a/users/mkleen.nix +++ b/users/mkleen.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$bBm24zrmoktFD$kGLJA0I9q.jPgLSFej/1aqIyBo/KotXhA0pflByzF5LG/Vw9Vt0yfDvVYEHR6rTplJWYotdYaJXY3b4wnh9n.0"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/mtrinh.nix b/users/mtrinh.nix index f5c2ab63..6d0eda51 100644 --- a/users/mtrinh.nix +++ b/users/mtrinh.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$vs31Y5YPrwWe/b8$y/CclfM5NTCNq489E2YxKC7xWqPmU88CWg9lSk3XiG40RH6znl.R4Cw0n1XI8ydoABsgFWjkcm4JkCDT9Lj3L/"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/mwagner.nix b/users/mwagner.nix index 10bec079..4fac64e6 100644 --- a/users/mwagner.nix +++ b/users/mwagner.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$5l71DQxKPXJ$UDUyiQur9QcmsXrV5r0gD5AWWpsJLe37bhV5NhZMjN4yh5aZjE4uqm8AXemuYTx3kKi.SWaRTglLIVvgDYf5l1"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/sgoebels.nix b/users/sgoebels.nix index d3efcb5b..8cd93312 100644 --- a/users/sgoebels.nix +++ b/users/sgoebels.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$uzD2AbY6bZAdfqt$V3oUI5YGUOwfxbs0Nd5LoXIfG1xVHimMhNkfFC5sheal8daGR60fqmwx3qdZk674oUr/GEF4ytHu6UMzIRmRa/"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/some.nix b/users/some.nix index 505b3abd..4e9d9c90 100644 --- a/users/some.nix +++ b/users/some.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$ZOKcPFUxFCCxbS$PSjgCpHs5GfmmusjTVEBY89NFS.hvY21.iuscfiXW8R.B2UW6ScyrIWWWPJkL4ZfI.6pKwXuf01gxazmDjy251"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/sselle.nix b/users/sselle.nix index 396ffa12..c290b172 100644 --- a/users/sselle.nix +++ b/users/sselle.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=50000$/H9dRtR88aUK4$Pc5QMXMALeiLCzbMm1FlH.EH9OBJsadmcvb/udp9fi3owm9B/IzdXF9Vixz8Dk2eA9urbXzpQ6FTkSrjs3pOO."; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/templates/xmpp.nix b/users/templates/xmpp.nix new file mode 100644 index 00000000..c69c4e5e --- /dev/null +++ b/users/templates/xmpp.nix @@ -0,0 +1,9 @@ +{ + name = "${firstname[0]}${lastname}"; # lowercase ascii, please + description = "Firstname Lastname"; + extraGroups = ["xmpp"]; + group = "users"; + hashedPassword = "$(pwgen -s 32 1 | tee /dev/stderr | mkpasswd -s -m sha-512 -R 500000)"; + isNormalUser = true; + hosts = ["ymir"]; +} diff --git a/users/tkleen.nix b/users/tkleen.nix index a36cc747..ce8eabd5 100644 --- a/users/tkleen.nix +++ b/users/tkleen.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$bYwSamirigbgL6$h/VI5yxcsY25fJb9DwUdgSiSi8Re1iGwXUHaOPfVgrZDKkrkoKvDg36d/GQhlfEA9XWh58gFmW9rgVeHsse.C1"; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/vkleen.nix b/users/vkleen.nix index 5ef89d39..4fcfbee0 100644 --- a/users/vkleen.nix +++ b/users/vkleen.nix @@ -5,4 +5,6 @@ group = "users"; hashedPassword = "$6$rounds=500000$wOgtkxOshMT$3wT9nRqSCZRr9MkZcDQjMM3YbAekqCxEF0TwYcmjLqUk8Z44jeWQS96H/r3SKCfKWWcIWcQNp/dAxQ/QlcKAv."; isNormalUser = true; + + hosts = ["ymir"]; } diff --git a/users/xmpp-template.nix b/users/xmpp-template.nix deleted file mode 100644 index f1fdd620..00000000 --- a/users/xmpp-template.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - name = "${firstname[0]}${lastname}"; # lowercase ascii, please - description = "Firstname Lastname"; - extraGroups = ["xmpp"]; - group = "users"; - hashedPassword = "$(pwgen -s 32 1 | tee /dev/stderr | mkpasswd -s -m sha-512 -R 500000)"; - isNormalUser = true; -} -- cgit v1.2.3