From ede5b23ce38cb4cf96feb2b84b6e2bd8294a56f8 Mon Sep 17 00:00:00 2001 From: Superredstone Date: Tue, 6 May 2025 07:54:00 +0200 Subject: [PATCH] Now using currentSystemUser for username across machines --- Makefile | 4 ++++ home/default.nix | 4 ++-- machines/katana/default.nix | 11 ++++++++++- machines/katana/virtualisation.nix | 4 ++-- modules/nix-config/default.nix | 22 +++++++--------------- modules/nix-config/fonts.nix | 6 ++++++ 6 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 modules/nix-config/fonts.nix diff --git a/Makefile b/Makefile index 4949210..fd9cdf4 100644 --- a/Makefile +++ b/Makefile @@ -8,3 +8,7 @@ switch: test: nixos-rebuild test --flake ".#${HOSTNAME}" --use-remote-sudo + +clean: + sudo nix-collect-garbage -d + sudo nix-store --optimise diff --git a/home/default.nix b/home/default.nix index b7e0196..903cf26 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ currentSystemUser, ... }: { imports = [ ./nvim @@ -9,7 +9,7 @@ ./zoxide.nix ]; - home.username = "r3ddy"; + home.username = "${currentSystemUser}"; programs.home-manager.enable = true; diff --git a/machines/katana/default.nix b/machines/katana/default.nix index c044be9..4d56aa8 100644 --- a/machines/katana/default.nix +++ b/machines/katana/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ currentSystemUser, ... }: { imports = [ ./hardware.nix @@ -11,5 +11,14 @@ networking.hostName = "katana"; # Define your hostname. + # I still don't know why my configuration fails if i omit this + system.userActivationScripts = { + removeConflictingFiles = { + text = '' + rm -f /home/${currentSystemUser}/.gtkrc-2.0.backup + ''; + }; + }; + system.stateVersion = "24.05"; # Did you read the comment? } diff --git a/machines/katana/virtualisation.nix b/machines/katana/virtualisation.nix index f3ffe6d..892aa0f 100644 --- a/machines/katana/virtualisation.nix +++ b/machines/katana/virtualisation.nix @@ -1,10 +1,10 @@ -{ ... }: +{ currentSystemUser, ... }: { virtualisation.podman.enable = true; virtualisation.podman.dockerCompat = true; programs.virt-manager.enable = true; - users.groups.libvirtd.members = ["r3ddy"]; + users.groups.libvirtd.members = ["${currentSystemUser}"]; virtualisation.libvirtd.enable = true; virtualisation.spiceUSBRedirection.enable = true; } diff --git a/modules/nix-config/default.nix b/modules/nix-config/default.nix index a2511f4..c444e62 100644 --- a/modules/nix-config/default.nix +++ b/modules/nix-config/default.nix @@ -1,20 +1,16 @@ -{ pkgs, ... }: +{ pkgs, currentSystemUser, ... }: { + imports = [ + ./fonts.nix + ]; + nix.gc = { automatic = true; dates = "weekly"; options = "--delete-older-than 1w"; }; - # Remove old gtkrc file, otherwise it will not work - system.userActivationScripts = { - removeConflictingFiles = { - text = '' - rm -f /home/r3ddy/.gtkrc-2.0.backup - ''; - }; - }; - + nix.optimise.automatic = true; time.timeZone = "Europe/Rome"; @@ -40,16 +36,12 @@ }; programs.fish.enable = true; # This must be true before initializing my user - users.users.r3ddy = { + users.users.${currentSystemUser} = { isNormalUser = true; description = "Patrick Canal"; extraGroups = [ "networkmanager" "wheel" "docker" ]; shell = pkgs.fish; }; - fonts.packages = with pkgs; [ - nerd-fonts.jetbrains-mono - ]; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; } diff --git a/modules/nix-config/fonts.nix b/modules/nix-config/fonts.nix new file mode 100644 index 0000000..91cce75 --- /dev/null +++ b/modules/nix-config/fonts.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + fonts.packages = with pkgs; [ + nerd-fonts.jetbrains-mono + ]; +}