From 031303170825e4606e856107c81aac50f70a6396 Mon Sep 17 00:00:00 2001 From: Arun Udayashankar Date: Thu, 1 Jun 2023 14:27:54 -0400 Subject: [PATCH] Experimental standalone home-manager configuration --- flake.nix | 51 ++++++++++++++++++++++++++++++---- profiles/home-manager/work.nix | 6 ++++ 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 profiles/home-manager/work.nix diff --git a/flake.nix b/flake.nix index b81f8f5..a6949ac 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,9 @@ ... } @ inputs: let + isDarwin = system: (builtins.elem system inputs.nixpkgs.lib.platforms.darwin); + homePrefix = system: if isDarwin system then "/Users" else "/home"; + #... Function to generate a base darwin configuration with the specified hostname, overlays, and any extraModules applied mkDarwinConfig = { system ? "aarch64-darwin", @@ -35,13 +38,37 @@ ], extraModules ? [], }: - inputs.darwin.lib.darwinSystem { - inherit system; - modules = baseModules ++ extraModules; - specialArgs = {inherit self inputs nixpkgs;}; - }; + inputs.darwin.lib.darwinSystem { + inherit system; + modules = baseModules ++ extraModules; + specialArgs = {inherit self inputs nixpkgs;}; + }; + + #... Function to generate home manager configuration usable on any unix system + mkHomeConfig = { + username, + system ? "x86_64-linux", + nixpkgs ? inputs.nixpkgs, + baseModules ? [ + ./modules/home-manager + { + home = { + inherit username; + homeDirectory = "${homePrefix system}/${username}"; + sessionVariables = { }; + }; + } + ], + extraModules ? [], + }: + inputs.home-manager.lib.homeMangerConfiguration rec { + extraSpecialArgs = {inherit self inputs nixpkgs;}; + modules = baseModules ++ extraModules; + }; in { + + #... MacOS Configurations darwinConfigurations = { Melbourne = mkDarwinConfig { system = "aarch64-darwin"; @@ -51,5 +78,19 @@ ]; }; }; + + #... Home Manager Configurations (for non-NixOS Linux installations) + homeConfigurations = { + nj1dvrdsdev01 = mkHomeConfig { + username = "audayashankar"; + system = "x86_64-linux"; + extraModules = [ ./profile/home-manager/work.nix ]; + }; + }; + + #... NixOS Configurations + nixosConfigurations = { + }; + }; } diff --git a/profiles/home-manager/work.nix b/profiles/home-manager/work.nix new file mode 100644 index 0000000..9d24ba7 --- /dev/null +++ b/profiles/home-manager/work.nix @@ -0,0 +1,6 @@ +{...}: { + programs.git = { + userEmail = "Arun.Udayashankar@tpicap.com"; + userName = "Arun Udayashankar"; + }; +}