Refactor user home directory references to use config.hostSpec.home for consistency across configurations
This commit is contained in:
parent
2fd5d6df58
commit
cca85f737e
8 changed files with 41 additions and 68 deletions
|
@ -7,6 +7,10 @@
|
|||
hostSpec,
|
||||
...
|
||||
}:
|
||||
let
|
||||
username = config.hostSpec.username;
|
||||
homeDir = config.hostSpec.home;
|
||||
in
|
||||
{
|
||||
imports = lib.flatten [
|
||||
(map lib.custom.relativeToRoot [
|
||||
|
@ -31,15 +35,15 @@
|
|||
services.ssh-agent.enable = true;
|
||||
|
||||
home = {
|
||||
username = lib.mkDefault config.hostSpec.username;
|
||||
homeDirectory = lib.mkDefault config.hostSpec.home;
|
||||
username = lib.mkDefault username;
|
||||
homeDirectory = lib.mkDefault homeDir;
|
||||
stateVersion = lib.mkDefault "24.05";
|
||||
sessionPath = [
|
||||
"$HOME/.local/bin"
|
||||
"${homeDir}/.local/bin"
|
||||
];
|
||||
sessionVariables = {
|
||||
EDITOR = "micro";
|
||||
FLAKE = "$HOME/git/dot.nix";
|
||||
FLAKE = "${homeDir}/git/dot.nix";
|
||||
MANPAGER = "batman"; # see ./cli/bat.nix
|
||||
SHELL = "fish";
|
||||
TERM = "foot";
|
||||
|
|
|
@ -14,7 +14,7 @@ let
|
|||
# inherit pkgs;
|
||||
# };
|
||||
|
||||
user = config.hostSpec.username;
|
||||
homeDir = config.hostSpec.home;
|
||||
|
||||
borg-wrapper = pkgs.writeScript "borg-wrapper" ''
|
||||
#!${lib.getExe pkgs.fish}
|
||||
|
@ -176,7 +176,7 @@ in
|
|||
name = "Ryujinx w/ Borg Backups";
|
||||
comment = "Ryujinx Emulator with Borg Backups";
|
||||
exec = mkLaunchCommand {
|
||||
savePath = "/home/${user}/.config/Ryujinx/bis/user/save";
|
||||
savePath = "${homeDir}/.config/Ryujinx/bis/user/save";
|
||||
backupPath = "/pool/Backups/Switch/RyubingSaves";
|
||||
maxBackups = 30;
|
||||
command = "ryujinx";
|
||||
|
@ -206,7 +206,7 @@ in
|
|||
name = "Citron w/ Borg Backups";
|
||||
comment = "Citron Emulator with Borg Backups";
|
||||
exec = mkLaunchCommand {
|
||||
savePath = "/home/${user}/.local/share/citron/nand/user/save";
|
||||
savePath = "${homeDir}/.local/share/citron/nand/user/save";
|
||||
backupPath = "/pool/Backups/Switch/CitronSaves";
|
||||
maxBackups = 30;
|
||||
command = "citron-emu";
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hostSpec = config.hostSpec;
|
||||
in
|
||||
{
|
||||
imports = lib.flatten [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
|
@ -60,7 +57,7 @@ in
|
|||
enable = true;
|
||||
clean.enable = true;
|
||||
clean.extraArgs = "--keep-since 20d --keep 20";
|
||||
flake = "/home/${hostSpec.username}/git/dot.nix/";
|
||||
flake = "${config.hostSpec.home}/git/dot.nix/";
|
||||
};
|
||||
|
||||
## SUDO and Terminal ##
|
||||
|
@ -71,7 +68,7 @@ in
|
|||
security.sudo = {
|
||||
extraRules = [
|
||||
{
|
||||
users = [ hostSpec.username ];
|
||||
users = [ config.hostSpec.username ];
|
||||
commands = [
|
||||
{
|
||||
command = "ALL";
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
{ config, ... }:
|
||||
let
|
||||
username = config.hostSpec.username;
|
||||
homeDir = config.hostSpec.home;
|
||||
in
|
||||
{
|
||||
# For less permission issues with SSHFS
|
||||
programs.fuse.userAllowOther = true;
|
||||
|
||||
# Create the directories if they do not exist
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /pool 2775 ${config.hostSpec.username} ryot -"
|
||||
"d /home/${config.hostSpec.username}/git 2775 ${config.hostSpec.username} ryot -"
|
||||
"d /pool 2775 ${username} ryot -"
|
||||
"d ${homeDir}/git 2775 ${username} ryot -"
|
||||
];
|
||||
|
||||
# File system configuration
|
||||
fileSystems = {
|
||||
"/pool" = {
|
||||
device = "${config.hostSpec.username}@cloud:/pool";
|
||||
device = "${username}@cloud:/pool";
|
||||
fsType = "sshfs";
|
||||
options = [
|
||||
"defaults"
|
||||
"reconnect"
|
||||
"_netdev"
|
||||
"allow_other"
|
||||
"identityfile=/home/${config.hostSpec.username}/.ssh/pve"
|
||||
"identityfile=${homeDir}/.ssh/pve"
|
||||
];
|
||||
};
|
||||
|
||||
"/home/${config.hostSpec.username}/git" = {
|
||||
"${homeDir}/git" = {
|
||||
fsType = "none";
|
||||
device = "/pool/git";
|
||||
options = [
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
}:
|
||||
|
||||
{
|
||||
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
|
||||
imports = lib.flatten [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
(map lib.custom.relativeToRoot [
|
||||
"hosts/common/optional/system/pool.nix"
|
||||
])
|
||||
];
|
||||
|
||||
## Boot ##
|
||||
boot = {
|
||||
|
@ -63,27 +68,6 @@
|
|||
"dmask=0077"
|
||||
];
|
||||
};
|
||||
|
||||
"/pool" = {
|
||||
device = "${config.hostSpec.username}@cloud:/pool";
|
||||
fsType = "sshfs";
|
||||
options = [
|
||||
"defaults"
|
||||
"reconnect"
|
||||
"_netdev"
|
||||
"allow_other"
|
||||
"identityfile=/home/${config.hostSpec.username}/.ssh/pve"
|
||||
];
|
||||
};
|
||||
|
||||
"/home/${config.hostSpec.username}/git" = {
|
||||
fsType = "none";
|
||||
device = "/pool/git";
|
||||
options = [
|
||||
"bind"
|
||||
"nofail"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
swapDevices = [ { device = "/dev/disk/by-uuid/6586847d-eba9-4317-9077-98ae9b2812c9"; } ];
|
||||
|
|
|
@ -9,8 +9,11 @@ let
|
|||
username = config.hostSpec.username;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
imports = lib.flatten [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
(map lib.custom.relativeToRoot [
|
||||
"hosts/common/optional/system/pool.nix"
|
||||
])
|
||||
];
|
||||
|
||||
## Boot ##
|
||||
|
@ -48,27 +51,6 @@ in
|
|||
device = "/dev/disk/by-uuid/7ec7d686-6f4c-482f-8b9d-4337a06afc48";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
"/pool" = {
|
||||
device = "${username}@cloud:/pool";
|
||||
fsType = "sshfs";
|
||||
options = [
|
||||
"defaults"
|
||||
"reconnect"
|
||||
"_netdev"
|
||||
"allow_other"
|
||||
"identityfile=/home/${username}/.ssh/pve"
|
||||
];
|
||||
};
|
||||
|
||||
"/home/${username}/git" = {
|
||||
fsType = "none";
|
||||
device = "/pool/git";
|
||||
options = [
|
||||
"bind"
|
||||
"nofail"
|
||||
];
|
||||
};
|
||||
};
|
||||
swapDevices = [ ];
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ in
|
|||
|
||||
users.mutableUsers = false; # Only allow declarative credentials; Required for password to be set via sops during system activation!
|
||||
users.users.${hostSpec.username} = {
|
||||
home = "/home/${hostSpec.username}";
|
||||
home = "${hostSpec.home}";
|
||||
isNormalUser = true;
|
||||
createHome = true;
|
||||
description = "Admin";
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
}:
|
||||
let
|
||||
hostSpec = config.hostSpec;
|
||||
username = hostSpec.username;
|
||||
homeDir = hostSpec.home;
|
||||
pubKeys = lib.filesystem.listFilesRecursive ./keys;
|
||||
in
|
||||
{
|
||||
users.users.${hostSpec.username} = {
|
||||
users.users.${username} = {
|
||||
name = hostSpec.username;
|
||||
shell = pkgs.fish; # default shell
|
||||
|
||||
|
@ -21,11 +23,11 @@ in
|
|||
# Create ssh sockets directory for controlpaths when homemanager not loaded (i.e. isMinimal)
|
||||
systemd.tmpfiles.rules =
|
||||
let
|
||||
user = config.users.users.${hostSpec.username}.name;
|
||||
group = config.users.users.${hostSpec.username}.group;
|
||||
user = config.users.users.${username}.name;
|
||||
group = config.users.users.${username}.group;
|
||||
in
|
||||
[
|
||||
"d /home/${hostSpec.username}/.ssh 0750 ${user} ${group} -"
|
||||
"d ${homeDir}/.ssh 0750 ${user} ${group} -"
|
||||
];
|
||||
|
||||
# No matter what environment we are in we want these tools
|
||||
|
@ -38,11 +40,11 @@ in
|
|||
inherit pkgs inputs;
|
||||
hostSpec = config.hostSpec;
|
||||
};
|
||||
users.${hostSpec.username}.imports = lib.flatten (
|
||||
users.${username}.imports = lib.flatten (
|
||||
lib.optional (!hostSpec.isMinimal) [
|
||||
(
|
||||
{ config, ... }:
|
||||
import (lib.custom.relativeToRoot "home/${hostSpec.username}/${hostSpec.hostName}") {
|
||||
import (lib.custom.relativeToRoot "home/${username}/${hostSpec.hostName}") {
|
||||
inherit
|
||||
pkgs
|
||||
inputs
|
||||
|
|
Loading…
Add table
Reference in a new issue