Allow overriding username

More specifically, this assists with the Steam Deck.
This commit is contained in:
Spotlight 2024-01-24 12:48:54 -06:00
parent 252fcc6f6f
commit a2c941ea44
Signed by: spotlight
GPG key ID: 874AA355B3209BDC
3 changed files with 26 additions and 12 deletions

12
flake.lock generated
View file

@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1705169127,
"narHash": "sha256-j9OEtNxOIPWZWjbECVMkI1TO17SzlpHMm0LnVWKOR/g=",
"lastModified": 1706080884,
"narHash": "sha256-qhxisCrSraN5YWVb0lNCFH8ovqnCw5W9ldac4Dzr0Nw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "f2942f3385f1b35cc8a1abb03a45e29c9cb4d3c8",
"rev": "6b28ab2d798c1c84e24053d95f4ee1dd9d81e2fb",
"type": "github"
},
"original": {
@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1705133751,
"narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=",
"lastModified": 1705856552,
"narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d",
"rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d",
"type": "github"
},
"original": {

View file

@ -51,6 +51,16 @@
gpg = true;
};
};
# For a special case: with the Steam Deck, we have to assume the user
# is named `deck` due to its immutable system image.
x86_64-linux.homeConfigurations.deck = homeManager {
system = "x86_64-linux";
specialArgs = {
gpg = true;
username = "deck";
};
};
};
nixosModules.default = {

View file

@ -8,22 +8,26 @@ let
# Whether to configure various programs to leverage GPG.
gpg = specialArgs.gpg or false;
in
{
# It's standard convention that Darwin has the username
# "spot" - "spotlight" was reserved by the system at some point.
# "spot" - regretfully, "spotlight" is reserved by the system.
# (Sigh... the downsides of sharing a namesake.)
home.username =
nativeUsername =
if pkgs.stdenv.isDarwin then
"spot"
else
"spotlight";
username = specialArgs.username or nativeUsername;
in
{
home.username = username;
home.homeDirectory =
if pkgs.stdenv.isDarwin then
"/Users/spot"
"/Users/" + username
else
"/home/spotlight";
"/home/" + username;
# Git
programs.git = {