2024-05-16 20:19:01 +01:00
|
|
|
{ pkgs, inputs, config, lib, ... }:
|
|
|
|
let
|
2024-05-25 18:44:35 +01:00
|
|
|
username = "media";
|
2024-05-16 20:19:01 +01:00
|
|
|
pubKeys = lib.filesystem.listFilesRecursive (../keys);
|
2024-05-17 01:07:42 +01:00
|
|
|
hostname = config.networking.hostName;
|
2024-05-25 18:44:35 +01:00
|
|
|
sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."passwords/${username}".path;
|
2024-05-23 10:48:00 +01:00
|
|
|
secretsDirectory = builtins.toString inputs.nix-secrets;
|
|
|
|
secretsFile = "${secretsDirectory}/secrets.yaml";
|
2024-05-24 21:23:56 +01:00
|
|
|
|
2024-05-28 20:19:30 +01:00
|
|
|
in
|
2024-05-16 20:19:01 +01:00
|
|
|
{
|
2024-05-25 18:45:48 +01:00
|
|
|
users.users.${username} = {
|
2024-05-16 20:19:01 +01:00
|
|
|
isNormalUser = true;
|
|
|
|
shell = pkgs.zsh; # default shell
|
2024-05-23 15:21:30 +01:00
|
|
|
hashedPasswordFile = sopsHashedPasswordFile;
|
2024-05-16 20:19:01 +01:00
|
|
|
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
|
|
|
|
|
|
|
|
extraGroups =
|
2024-06-06 18:07:59 +01:00
|
|
|
[
|
|
|
|
"wheel"
|
|
|
|
];
|
2024-05-16 20:19:01 +01:00
|
|
|
|
2024-05-25 18:44:35 +01:00
|
|
|
packages = with pkgs; [
|
|
|
|
flatpak
|
|
|
|
gnome.gnome-software
|
|
|
|
];
|
2024-05-16 20:19:01 +01:00
|
|
|
};
|
|
|
|
|
2024-05-23 16:57:41 +01:00
|
|
|
environment.persistence."/persist" = {
|
|
|
|
hideMounts = true;
|
2024-06-06 18:07:59 +01:00
|
|
|
users.${username} = {
|
|
|
|
directories = [
|
|
|
|
"Sync"
|
|
|
|
"Keep"
|
|
|
|
".ssh"
|
2024-06-06 19:55:17 +01:00
|
|
|
".config"
|
2024-06-06 18:07:59 +01:00
|
|
|
".mozilla"
|
|
|
|
".local"
|
2024-06-06 19:55:17 +01:00
|
|
|
".zotero"
|
2024-06-10 14:05:06 +01:00
|
|
|
".var"
|
|
|
|
".steam"
|
2024-06-06 18:07:59 +01:00
|
|
|
];
|
|
|
|
files = [
|
|
|
|
];
|
2024-05-23 16:57:41 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-25 20:26:55 +01:00
|
|
|
sops.secrets = {
|
|
|
|
"passwords/${username}" = {
|
|
|
|
sopsFile = "${secretsFile}";
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
|
|
|
"ssh_keys/${username}/id_ed25519" = {
|
|
|
|
path = "/home/${username}/.ssh/id_ed25519";
|
|
|
|
mode = "0600";
|
|
|
|
owner = "${username}";
|
2024-06-06 18:07:59 +01:00
|
|
|
};
|
2024-05-25 20:26:55 +01:00
|
|
|
"ssh_keys/${username}/id_ed25519.pub" = {
|
|
|
|
path = "/home/${username}/.ssh/id_ed25519.pub";
|
|
|
|
mode = "0644";
|
|
|
|
owner = "${username}";
|
|
|
|
};
|
2024-05-23 10:48:00 +01:00
|
|
|
};
|
|
|
|
|
2024-05-31 22:52:54 +01:00
|
|
|
# The containing ssh folders are created as root and if this is the first ~/.ssh/ entry when writing keys,
|
|
|
|
# the ownership is busted and home-manager can't target because it can't write into .ssh...
|
|
|
|
# FIXME: We might not need this depending on how https://github.com/Mic92/sops-nix/issues/381 is fixed
|
2024-06-06 18:07:59 +01:00
|
|
|
system.activationScripts.sopsSetSshOwnwership =
|
|
|
|
let
|
|
|
|
sshFolder = "/home/${username}/.ssh";
|
|
|
|
user = config.users.users.${username}.name;
|
|
|
|
group = config.users.users.${username}.group;
|
|
|
|
in
|
|
|
|
''
|
|
|
|
mkdir -p ${sshFolder} || true
|
|
|
|
chown -R ${user}:${group} /home/${username}/.ssh
|
|
|
|
'';
|
2024-05-31 22:52:54 +01:00
|
|
|
|
2024-05-24 14:32:18 +01:00
|
|
|
services.flatpak.enable = true;
|
|
|
|
|
2024-05-16 20:19:01 +01:00
|
|
|
programs.zsh.enable = true;
|
2024-05-17 01:07:42 +01:00
|
|
|
programs.fuse.userAllowOther = true;
|
2024-05-17 10:54:53 +01:00
|
|
|
|
2024-05-17 01:07:42 +01:00
|
|
|
home-manager = {
|
|
|
|
extraSpecialArgs = { inherit inputs; };
|
|
|
|
users = {
|
2024-05-25 18:45:48 +01:00
|
|
|
${username} = import ../../../../home/${hostname}.nix;
|
2024-05-17 01:07:42 +01:00
|
|
|
};
|
|
|
|
};
|
2024-05-16 20:19:01 +01:00
|
|
|
}
|