refactor: indirections f. user,[home,flake,xdg]Dir

This commit is contained in:
Leon Schwarzäugl 2025-03-22 22:32:32 +01:00
parent 5c207050a3
commit 9c1df052a2
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
34 changed files with 416 additions and 281 deletions

View file

@ -1,4 +1,4 @@
{ self, config, pkgs, lib, ... }:
{ self, config, pkgs, lib, primaryUser, ... }:
let
profilesPath = "${self}/profiles";
in
@ -44,9 +44,8 @@ in
rootDisk = "/dev/vda";
};
home-manager.users.swarsel.swarselsystems = {
home-manager.users."${primaryUser}".swarselsystems = {
isNixos = true;
isPublic = true;
flakePath = "/home/swarsel/.dotfiles";
};
}

View file

@ -1,4 +1,4 @@
{ self, pkgs, inputs, outputs, config, lib, modulesPath, ... }:
{ self, pkgs, inputs, outputs, config, lib, modulesPath, primaryUser ? "swarsel", ... }:
let
pubKeys = lib.filesystem.listFilesRecursive "${self}/secrets/keys/ssh";
in
@ -12,13 +12,13 @@ in
inputs.home-manager.nixosModules.home-manager
{
home-manager.users.swarsel.imports = [
home-manager.users."${primaryUser}".imports = [
"${self}/profiles/home/common/settings.nix"
] ++ (builtins.attrValues outputs.homeModules);
}
];
home-manager.users.swarsel.home = {
home-manager.users."${primaryUser}".home = {
file = {
".bash_history" = {
source = self + /programs/bash/.bash_history;
@ -49,15 +49,15 @@ in
config.allowUnfree = true;
};
services.getty.autologinUser = lib.mkForce "swarsel";
services.getty.autologinUser = lib.mkForce primaryUser;
users = {
allowNoPasswordLogin = true;
groups.swarsel = { };
users = {
swarsel = {
name = "swarsel";
group = "swarsel";
name = primaryUser;
group = primaryUser;
isNormalUser = true;
password = "setup"; # this is overwritten after install
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
@ -65,7 +65,7 @@ in
};
root = {
# password = lib.mkForce config.users.users.swarsel.password; # this is overwritten after install
openssh.authorizedKeys.keys = config.users.users.swarsel.openssh.authorizedKeys.keys;
openssh.authorizedKeys.keys = config.users.users."${primaryUser}".openssh.authorizedKeys.keys;
};
};
};
@ -81,10 +81,10 @@ in
system.activationScripts.cache = {
text = ''
mkdir -p -m=0777 /home/swarsel/.local/state/nix/profiles
mkdir -p -m=0777 /home/swarsel/.local/state/home-manager/gcroots
mkdir -p -m=0777 /home/swarsel/.local/share/nix/
printf '{\"extra-substituters\":{\"https://nix-community.cachix.org\":true,\"https://nix-community.cachix.org https://cache.ngi0.nixos.org/\":true},\"extra-trusted-public-keys\":{\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=\":true,\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=\":true}}' | tee /home/swarsel/.local/share/nix/trusted-settings.json > /dev/null
mkdir -p -m=0777 /home/${primaryUser}/.local/state/nix/profiles
mkdir -p -m=0777 /home/${primaryUser}/.local/state/home-manager/gcroots
mkdir -p -m=0777 /home/${primaryUser}/.local/share/nix/
printf '{\"extra-substituters\":{\"https://nix-community.cachix.org\":true,\"https://nix-community.cachix.org https://cache.ngi0.nixos.org/\":true},\"extra-trusted-public-keys\":{\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=\":true,\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=\":true}}' | tee /home/${primaryUser}/.local/share/nix/trusted-settings.json > /dev/null
mkdir -p /root/.local/share/nix/
printf '{\"extra-substituters\":{\"https://nix-community.cachix.org\":true,\"https://nix-community.cachix.org https://cache.ngi0.nixos.org/\":true},\"extra-trusted-public-keys\":{\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=\":true,\"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=\":true}}' | tee /root/.local/share/nix/trusted-settings.json > /dev/null
'';

View file

@ -1,10 +1,11 @@
{ self, inputs, pkgs, lib, ... }:
{ self, inputs, pkgs, lib, primaryUser, ... }:
let
secretsDirectory = builtins.toString inputs.nix-secrets;
profilesPath = "${self}/profiles";
sharedOptions = {
isBtrfs = true;
isLinux = true;
sharescreen = "eDP-2";
};
in
{
@ -25,7 +26,7 @@ in
inputs.home-manager.nixosModules.home-manager
{
home-manager.users.swarsel.imports = [
home-manager.users."${primaryUser}".imports = [
"${profilesPath}/home/optional/gaming.nix"
"${profilesPath}/home/optional/work.nix"
];
@ -110,11 +111,12 @@ in
}
sharedOptions;
home-manager.users.swarsel.swarselsystems = lib.recursiveUpdate
home-manager.users."${primaryUser}".swarselsystems = lib.recursiveUpdate
{
isLaptop = true;
isNixos = true;
flakePath = "/home/swarsel/.dotfiles";
isSecondaryGpu = true;
SecondaryGpuCard = "pci-0000_03_00_0";
cpuCount = 16;
temperatureHwmon = {
isAbsolutePath = true;
@ -132,7 +134,6 @@ in
{ command = "1password"; }
{ command = "feishin"; }
];
sharescreen = "eDP-2";
lowResolution = "1280x800";
highResolution = "2560x1600";
monitors = {

View file

@ -1,4 +1,4 @@
{ self, inputs, lib, ... }:
{ self, inputs, lib, primaryUser, ... }:
let
profilesPath = "${self}/profiles";
in
@ -10,7 +10,7 @@ in
inputs.home-manager.nixosModules.home-manager
{
home-manager.users.swarsel.imports = [
home-manager.users."${primaryUser}".imports = [
"${profilesPath}/home/server"
];
}

View file

@ -1,4 +1,4 @@
{ self, inputs, outputs, pkgs, lib, ... }:
{ self, inputs, outputs, pkgs, lib, primaryUser, ... }:
let
profilesPath = "${self}/profiles";
sharedOptions = {
@ -25,7 +25,7 @@ in
inputs.home-manager.nixosModules.home-manager
{
home-manager.users.swarsel.imports = [
home-manager.users."${primaryUser}".imports = [
inputs.sops-nix.homeManagerModules.sops
"${profilesPath}/home/common/settings.nix"
"${profilesPath}/home/common/sops.nix"
@ -73,11 +73,10 @@ in
}
sharedOptions;
home-manager.users.swarsel.swarselsystems = lib.recursiveUpdate
home-manager.users."${primaryUser}".swarselsystems = lib.recursiveUpdate
{
isLaptop = false;
isNixos = true;
flakePath = "/home/swarsel/.dotfiles";
}
sharedOptions;

View file

@ -1,4 +1,4 @@
{ self, inputs, ... }:
{ self, inputs, primaryUser, ... }:
let
profilesPath = "${self}/profiles";
in
@ -12,7 +12,7 @@ in
inputs.home-manager.nixosModules.home-manager
{
home-manager.users.swarsel.imports = [
home-manager.users."${primaryUser}".imports = [
"${profilesPath}/home/server"
];
}
@ -37,7 +37,6 @@ in
isImpermanence = false;
isBtrfs = false;
isLinux = true;
flakePath = "/home/swarsel/.dotfiles";
server = {
enable = true;
kavita = true;