2023-01-06 15:38:29 +00:00
|
|
|
{ config, pkgs, lib, sane-lib, ... }:
|
2022-05-22 08:27:02 +00:00
|
|
|
|
|
|
|
# installer docs: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/profiles/installation-device.nix
|
2022-07-31 18:35:15 +00:00
|
|
|
with lib;
|
|
|
|
let
|
2022-08-01 07:23:49 +00:00
|
|
|
cfg = config.sane.users;
|
2023-01-06 15:38:29 +00:00
|
|
|
fs = sane-lib.fs;
|
2022-07-31 18:35:15 +00:00
|
|
|
in
|
2022-05-22 08:27:02 +00:00
|
|
|
{
|
2022-07-31 18:35:15 +00:00
|
|
|
options = {
|
2022-08-01 07:23:49 +00:00
|
|
|
sane.users.guest.enable = mkOption {
|
2022-07-31 18:35:15 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
2022-05-22 08:27:02 +00:00
|
|
|
};
|
|
|
|
|
2022-07-31 18:35:15 +00:00
|
|
|
config = {
|
|
|
|
# Users are exactly these specified here;
|
|
|
|
# old ones will be deleted (from /etc/passwd, etc) upon upgrade.
|
|
|
|
users.mutableUsers = false;
|
2022-05-22 08:27:02 +00:00
|
|
|
|
2022-07-31 18:35:15 +00:00
|
|
|
# docs: https://nixpkgs-manual-sphinx-markedown-example.netlify.app/generated/options-db.xml.html#users-users
|
|
|
|
users.users.colin = {
|
|
|
|
# sets group to "users" (?)
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/colin";
|
2022-12-22 11:33:13 +00:00
|
|
|
createHome = true;
|
2023-01-04 07:14:38 +00:00
|
|
|
homeMode = "0700";
|
2022-07-31 18:35:15 +00:00
|
|
|
# i don't get exactly what this is, but nixos defaults to this non-deterministically
|
|
|
|
# in /var/lib/nixos/auto-subuid-map and i don't want that.
|
|
|
|
subUidRanges = [
|
|
|
|
{ startUid=100000; count=1; }
|
|
|
|
];
|
|
|
|
group = "users";
|
|
|
|
extraGroups = [
|
|
|
|
"wheel"
|
|
|
|
"nixbuild"
|
|
|
|
"networkmanager"
|
|
|
|
# phosh/mobile. XXX colin: unsure if necessary
|
|
|
|
"video"
|
|
|
|
"feedbackd"
|
|
|
|
"dialout" # required for modem access
|
|
|
|
];
|
2022-10-23 13:48:39 +00:00
|
|
|
|
|
|
|
# initial password is empty, in case anything goes wrong.
|
|
|
|
# if `colin-passwd` (a password hash) is successfully found/decrypted, that becomes the password at boot.
|
2022-07-31 18:35:15 +00:00
|
|
|
initialPassword = lib.mkDefault "";
|
2022-10-23 13:48:39 +00:00
|
|
|
passwordFile = lib.mkIf (config.sops.secrets ? "colin-passwd") config.sops.secrets.colin-passwd.path;
|
|
|
|
|
2022-07-31 18:35:15 +00:00
|
|
|
shell = pkgs.zsh;
|
2022-10-18 12:29:36 +00:00
|
|
|
|
2023-01-02 11:34:02 +00:00
|
|
|
# mount encrypted stuff at login
|
2022-12-28 09:30:29 +00:00
|
|
|
# some other nix pam users:
|
|
|
|
# - <https://github.com/g00pix/nixconf/blob/32c04f6fa843fed97639dd3f09e157668d3eea1f/profiles/sshfs.nix>
|
|
|
|
# - <https://github.com/lourkeur/distro/blob/11173454c6bb50f7ccab28cc2c757dca21446d1d/nixos/profiles/users/louis-full.nix>
|
|
|
|
# - <https://github.com/dnr/sample-nix-code/blob/03494480c1fae550c033aa54fd96aeb3827761c5/nixos/laptop.nix>
|
2023-01-02 11:34:02 +00:00
|
|
|
pamMount = let
|
|
|
|
priv = config.fileSystems."/home/colin/private";
|
|
|
|
in {
|
|
|
|
fstype = priv.fsType;
|
|
|
|
path = priv.device;
|
|
|
|
mountpoint = priv.mountPoint;
|
|
|
|
options = builtins.concatStringsSep "," priv.options;
|
2022-10-18 12:29:36 +00:00
|
|
|
};
|
2022-07-31 18:35:15 +00:00
|
|
|
};
|
|
|
|
|
2022-12-28 09:30:29 +00:00
|
|
|
security.pam.mount.enable = true;
|
|
|
|
|
2023-01-03 08:25:43 +00:00
|
|
|
# ensure ~ perms are known to sane.fs module.
|
|
|
|
# TODO: this is generic enough to be lifted up into sane.fs itself.
|
|
|
|
sane.fs."/home/colin".dir.acl = {
|
|
|
|
user = "colin";
|
|
|
|
group = config.users.users.colin.group;
|
|
|
|
mode = config.users.users.colin.homeMode;
|
|
|
|
};
|
|
|
|
|
2023-01-06 11:29:13 +00:00
|
|
|
sane.persist.home.plaintext = [
|
2023-01-03 07:35:42 +00:00
|
|
|
"archive"
|
|
|
|
"dev"
|
|
|
|
# TODO: records should be private
|
|
|
|
"records"
|
|
|
|
"ref"
|
|
|
|
"tmp"
|
|
|
|
"use"
|
|
|
|
"Music"
|
|
|
|
"Pictures"
|
|
|
|
"Videos"
|
|
|
|
|
2023-01-14 23:21:15 +00:00
|
|
|
".cache/nix"
|
2022-10-22 13:09:53 +00:00
|
|
|
".cargo"
|
|
|
|
".rustup"
|
|
|
|
];
|
|
|
|
|
2023-01-04 07:14:38 +00:00
|
|
|
# convenience
|
2023-01-06 15:38:29 +00:00
|
|
|
sane.fs."/home/colin/knowledge" = fs.wantedSymlinkTo "/home/colin/private/knowledge";
|
|
|
|
sane.fs."/home/colin/nixos" = fs.wantedSymlinkTo "/home/colin/dev/nixos";
|
|
|
|
sane.fs."/home/colin/Videos/servo" = fs.wantedSymlinkTo "/mnt/servo-media/Videos";
|
|
|
|
sane.fs."/home/colin/Videos/servo-incomplete" = fs.wantedSymlinkTo "/mnt/servo-media/incomplete";
|
|
|
|
sane.fs."/home/colin/Music/servo" = fs.wantedSymlinkTo "/mnt/servo-media/Music";
|
2023-01-04 07:14:38 +00:00
|
|
|
|
|
|
|
# used by password managers, e.g. unix `pass`
|
2023-01-06 15:38:29 +00:00
|
|
|
sane.fs."/home/colin/.password-store" = fs.wantedSymlinkTo "/home/colin/knowledge/secrets/accounts";
|
2023-01-04 07:14:38 +00:00
|
|
|
|
2023-01-06 11:29:13 +00:00
|
|
|
sane.persist.sys.plaintext = mkIf cfg.guest.enable [
|
2023-01-04 01:09:23 +00:00
|
|
|
# intentionally allow other users to write to the guest folder
|
|
|
|
{ directory = "/home/guest"; user = "guest"; group = "users"; mode = "0775"; }
|
2022-07-31 18:35:15 +00:00
|
|
|
];
|
|
|
|
users.users.guest = mkIf cfg.guest.enable {
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/guest";
|
|
|
|
subUidRanges = [
|
|
|
|
{ startUid=200000; count=1; }
|
|
|
|
];
|
|
|
|
group = "users";
|
|
|
|
initialPassword = lib.mkDefault "";
|
|
|
|
shell = pkgs.zsh;
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
# TODO: insert pubkeys that should be allowed in
|
|
|
|
];
|
|
|
|
};
|
2022-07-15 04:53:28 +00:00
|
|
|
|
2022-07-31 18:35:15 +00:00
|
|
|
security.sudo = {
|
|
|
|
enable = true;
|
|
|
|
wheelNeedsPassword = false;
|
|
|
|
};
|
2022-07-15 04:53:28 +00:00
|
|
|
|
2022-07-31 18:35:15 +00:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
2023-01-21 05:33:15 +00:00
|
|
|
settings.PermitRootLogin = "no";
|
|
|
|
settings.PasswordAuthentication = false;
|
2022-07-31 18:35:15 +00:00
|
|
|
};
|
|
|
|
};
|
2022-05-22 08:27:02 +00:00
|
|
|
}
|