From 4d9a6b6877fceb18dcb0c5ee35a56fc9f665c3af Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Tue, 6 Jun 2023 10:48:10 -0400 Subject: [PATCH] variables: Add username --- containers/rar.nix | 6 ++++-- containers/wine.nix | 3 ++- modules/default.nix | 6 ++++-- modules/ncmpcpp/default.nix | 6 ++++-- modules/xdg-user-dirs/default.nix | 14 ++++++++------ src/main.nix | 6 +++--- src/variables.nix | 1 + 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/containers/rar.nix b/containers/rar.nix index 4203e3ad..ba9f9d84 100644 --- a/containers/rar.nix +++ b/containers/rar.nix @@ -1,10 +1,12 @@ -{ +let + VARIABLES = import ../src/variables.nix; +in { containers.rar = { privateNetwork = true; bindMounts = { "/home/user" = { - hostPath = "/home/user/containers/rar"; + hostPath = "/home/${VARIABLES.username}/containers/rar"; isReadOnly = false; }; }; diff --git a/containers/wine.nix b/containers/wine.nix index e27d1030..6922d47d 100644 --- a/containers/wine.nix +++ b/containers/wine.nix @@ -1,4 +1,5 @@ {config, ...}: let + VARIABLES = import ../src/variables.nix; hostCfg = config; in { containers.wine = { @@ -6,7 +7,7 @@ in { bindMounts = { "/home/user" = { - hostPath = "/home/user/containers/wine"; + hostPath = "/home/${VARIABLES.username}/containers/wine"; isReadOnly = false; }; diff --git a/modules/default.nix b/modules/default.nix index 8d8ab9b1..7637008e 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,6 @@ -{pkgs, ...}: { +{pkgs, ...}: let + VARIABLES = import ../src/variables.nix; +in { imports = [ ./feh ./kitty @@ -150,7 +152,7 @@ }; initial_session = { command = "${pkgs.hyprland}/bin/Hyprland"; - user = "user"; + user = VARIABLES.username; }; }; }; diff --git a/modules/ncmpcpp/default.nix b/modules/ncmpcpp/default.nix index 9e80a44d..3d50d4b5 100644 --- a/modules/ncmpcpp/default.nix +++ b/modules/ncmpcpp/default.nix @@ -1,9 +1,11 @@ -{pkgs, ...}: { +{pkgs, ...}: let + VARIABLES = import ../../src/variables.nix; +in { home-manager.sharedModules = [ { services.mpd = { enable = true; - musicDirectory = "/home/user/Music"; + musicDirectory = "/home/${VARIABLES.username}/Music"; }; xdg.configFile."mpd/mpd.conf".text = '' diff --git a/modules/xdg-user-dirs/default.nix b/modules/xdg-user-dirs/default.nix index 10bc31f4..c4902375 100644 --- a/modules/xdg-user-dirs/default.nix +++ b/modules/xdg-user-dirs/default.nix @@ -1,4 +1,6 @@ -{ +let + VARIABLES = import ../../src/variables.nix; +in { home-manager.sharedModules = [ { xdg.userDirs = { @@ -8,11 +10,11 @@ templates = null; publicShare = null; - download = "/home/user/ダウンロード"; - documents = "/home/user/ドキュメント"; - music = "/home/user/音楽"; - pictures = "/home/user/画像"; - videos = "/home/user/ビデオ"; + download = "/home/${VARIABLES.username}/ダウンロード"; + documents = "/home/${VARIABLES.username}/ドキュメント"; + music = "/home/${VARIABLES.username}/音楽"; + pictures = "/home/${VARIABLES.username}/画像"; + videos = "/home/${VARIABLES.username}/ビデオ"; }; xdg.configFile."user-dirs.locale".text = "ja_JP"; diff --git a/src/main.nix b/src/main.nix index 69fd7160..a0826f1a 100644 --- a/src/main.nix +++ b/src/main.nix @@ -161,7 +161,7 @@ in { users = { mutableUsers = false; - users.user = { + users."${VARIABLES.username}" = { isNormalUser = true; uid = 1000; password = "user"; @@ -170,8 +170,8 @@ in { }; home-manager.users.user = { - home.username = "user"; - home.homeDirectory = "/home/user"; + home.username = VARIABLES.username; + home.homeDirectory = "/home/${VARIABLES.username}"; }; # dev diff --git a/src/variables.nix b/src/variables.nix index 72b8d917..0a2e29b2 100644 --- a/src/variables.nix +++ b/src/variables.nix @@ -6,4 +6,5 @@ stateVersion = "22.11"; defaultLocale = "ja_JP.UTF-8"; supportedLocales = ["ja_JP.UTF-8/UTF-8" "en_US.UTF-8/UTF-8" "fr_FR.UTF-8/UTF-8"]; + username = "user"; }