From f3a8dac9480c217292faab3047e684932af38fda Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 25 May 2024 18:44:35 +0100 Subject: [PATCH] parameterised username in users --- hosts/common/users/media/default.nix | 24 +++++++++++------------- hosts/sparky/default.nix | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/hosts/common/users/media/default.nix b/hosts/common/users/media/default.nix index aca15be..552bffa 100644 --- a/hosts/common/users/media/default.nix +++ b/hosts/common/users/media/default.nix @@ -1,15 +1,15 @@ { pkgs, inputs, config, lib, ... }: let + username = "media"; pubKeys = lib.filesystem.listFilesRecursive (../keys); hostname = config.networking.hostName; - sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."passwords/${user}".path; + sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."passwords/${username}".path; secretsDirectory = builtins.toString inputs.nix-secrets; secretsFile = "${secretsDirectory}/secrets.yaml"; - username = "media"; in { - users.users.${username} = { + users.users."${username}" = { isNormalUser = true; shell = pkgs.zsh; # default shell hashedPasswordFile = sopsHashedPasswordFile; @@ -20,11 +20,15 @@ in "wheel" "video" "audio" "disk" "networkmanager" ]; + packages = with pkgs; [ + flatpak + gnome.gnome-software + ]; }; environment.persistence."/persist" = { hideMounts = true; - users.${user}= { + users."${username}"= { directories = [ "sync" "keep" @@ -48,22 +52,16 @@ in sops.secrets."ssh_keys/${username}/id_ed25519" = { path = "/home/${username}/.ssh/id_ed25519"; mode = "0600"; - owner = config.users.users.${username}.name; + owner = "${username}"; }; sops.secrets."ssh_keys/${username}/id_ed25519.pub" = { path = "/home/${username}/.ssh/id_ed25519.pub"; mode = "0644"; - owner = config.users.users.${username}.name; + owner = "${username}"; }; services.flatpak.enable = true; - users.users.${username} = { - packages = with pkgs; [ - flatpak - gnome.gnome-software - ]; - }; programs.zsh.enable = true; programs.fuse.userAllowOther = true; @@ -71,7 +69,7 @@ in home-manager = { extraSpecialArgs = { inherit inputs; }; users = { - ${username} = import ../../../../home/${hostname}.nix; + "${username}" = import ../../../../home/${hostname}.nix; }; }; } diff --git a/hosts/sparky/default.nix b/hosts/sparky/default.nix index a1fb0b6..f27eb2c 100644 --- a/hosts/sparky/default.nix +++ b/hosts/sparky/default.nix @@ -7,7 +7,7 @@ in [ # Disk configuration inputs.disko.nixosModules.disko - (import ../common/disks/std-disk-config.nix { device = ${dev}; }) + (import ../common/disks/std-disk-config.nix { device = dev; }) ../common/optional/btrfs-impermanence.nix # Create users for this host