From c6a8a7c34e4b9f9a8427839b4e12218f3eb0787f Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 24 Jun 2024 09:15:17 +0100 Subject: [PATCH] Fix correct username not being set Rather than set username in flake.nix, set a default value in default.nix (since it's always called), and set appropriate values in personal.nix (pixelifytica) and work.nix (elitherl), since the two files are mutually exclusive and only one or the other will be imported. --- default.nix | 10 ++++-- flake.nix | 93 +++++++++++++++++++++++++++------------------------- personal.nix | 19 ++++++----- work.nix | 15 +++++---- 4 files changed, 75 insertions(+), 62 deletions(-) diff --git a/default.nix b/default.nix index 9dea358..e66da68 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,8 @@ -{username, ...}: { +{ + config, + lib, + ... +}: { imports = [ # Programs ./programs/desktop/default.nix @@ -14,8 +18,8 @@ programs.home-manager.enable = true; nixpkgs.config.allowUnfree = true; home = { - inherit username; - homeDirectory = "/home/${username}"; + username = lib.mkDefault "pixelifytica"; + homeDirectory = "/home/${config.home.username}"; stateVersion = "23.05"; }; } diff --git a/flake.nix b/flake.nix index a590167..0e0a1c0 100644 --- a/flake.nix +++ b/flake.nix @@ -38,12 +38,10 @@ ... }: let defaultExtraSpecialArgs = { - system ? "x86_64-linux", - hostname ? "Atlas", - username ? "pixelifytica", - ... + hostname, + system, }: rec { - inherit hostname username; + inherit hostname; inherit (plasma-manager.packages.${system}) rc2nix; accentColourName = "base0D"; altAccentColourName = "base0C"; @@ -90,53 +88,58 @@ }; homeConfigurations = { # Server - "pixelifytica@Legion" = home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs {system = "x86_64-linux";}; - modules = defaultModules; - extraSpecialArgs = defaultExtraSpecialArgs { - system = "x86_64-linux"; - hostname = "Legion"; + "pixelifytica@Legion" = let + hostname = "Legion"; + system = "x86_64-linux"; + in + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs {inherit system;}; + modules = defaultModules; + extraSpecialArgs = defaultExtraSpecialArgs {inherit hostname system;}; }; - }; # Personal - "pixelifytica@Northstar" = home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs {system = "x86_64-linux";}; - modules = - defaultModules - ++ [ - ./personal.nix - {programs.plasma.configFile.kcminputrc."Libinput/1739/52759/SYNA32AA:00 06CB:CE17 Touchpad".NaturalScroll = true;} - ]; - extraSpecialArgs = defaultExtraSpecialArgs { - system = "x86_64-linux"; - hostname = "Northstar"; + "pixelifytica@Northstar" = let + hostname = "Northstar"; + system = "x86_64-linux"; + in + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs {inherit system;}; + modules = + defaultModules + ++ [ + ./personal.nix + {programs.plasma.configFile.kcminputrc."Libinput/1739/52759/SYNA32AA:00 06CB:CE17 Touchpad".NaturalScroll = true;} + ]; + extraSpecialArgs = defaultExtraSpecialArgs {inherit hostname system;}; }; - }; - "pixelifytica@Vanguard" = home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs {system = "x86_64-linux";}; - modules = defaultModules ++ [./personal.nix]; - extraSpecialArgs = defaultExtraSpecialArgs { - system = "x86_64-linux"; - hostname = "Vanguard"; + "pixelifytica@Vanguard" = let + hostname = "Vanguard"; + system = "x86_64-linux"; + in + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs {inherit system;}; + modules = defaultModules ++ [./personal.nix]; + extraSpecialArgs = defaultExtraSpecialArgs {inherit hostname system;}; }; - }; # Work - "elitherl@Tone" = home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs {system = "x86_64-linux";}; - modules = defaultModules ++ [./work.nix]; - extraSpecialArgs = defaultExtraSpecialArgs { - system = "x86_64-linux"; - hostname = "Tone"; + "elitherl@Tone" = let + hostname = "Tone"; + system = "x86_64-linux"; + in + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs {inherit system;}; + modules = defaultModules ++ [./work.nix]; + extraSpecialArgs = defaultExtraSpecialArgs {inherit hostname system;}; }; - }; - "elitherl@Scorch" = home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs {system = "x86_64-linux";}; - modules = defaultModules ++ [./work.nix]; - extraSpecialArgs = defaultExtraSpecialArgs { - system = "x86_64-linux"; - hostname = "Scorch"; + "elitherl@Scorch" = let + hostname = "Scorch"; + system = "x86_64-linux"; + in + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs {inherit system;}; + modules = defaultModules ++ [./work.nix]; + extraSpecialArgs = defaultExtraSpecialArgs {inherit hostname system;}; }; - }; }; }; } diff --git a/personal.nix b/personal.nix index 944a26a..5c06c69 100644 --- a/personal.nix +++ b/personal.nix @@ -4,12 +4,15 @@ ./programs/games/default.nix ./programs/streaming/default.nix ]; - home.packages = with pkgs; - with kdePackages; [ - blender - freecad - prusa-slicer - ktorrent - noson - ]; + home = { + username = "pixelifytica"; + packages = with pkgs; + with kdePackages; [ + blender + freecad + prusa-slicer + ktorrent + noson + ]; + }; } diff --git a/work.nix b/work.nix index ff14f80..f58364c 100644 --- a/work.nix +++ b/work.nix @@ -4,12 +4,15 @@ pkgs, ... }: { - home.packages = with pkgs; [ - twinkle - teams-for-linux - (writeShellScriptBin "ukaea-vpn-connect" - "sudo ${openfortivpn}/bin/openfortivpn -c ${./ukaea-vpn.conf}") - ]; + home = { + username = "elitherl"; + packages = with pkgs; [ + twinkle + teams-for-linux + (writeShellScriptBin "ukaea-vpn-connect" + "sudo ${openfortivpn}/bin/openfortivpn -c ${./ukaea-vpn.conf}") + ]; + }; programs = { git.userEmail = config.accounts.email.accounts.outlook.address; firefox.policies.Homepage.URL = "https://nucleus.ukaea.uk";