From 558ecfabd32986cbdaabd9713c0314208c72a53f Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Thu, 28 Nov 2024 02:25:07 +0000 Subject: [PATCH] Add home manager configuraiton --- flake.lock | 22 +++++++++++++++++++ flake.nix | 5 +++++ home-manager/machines/wsl/home.nix | 32 ++++++++++++++++++++++++++++ nixos/machines/wsl/configuration.nix | 27 ++++++++++++----------- nixos/modules/user.nix | 30 ++++++++++++++------------ 5 files changed, 90 insertions(+), 26 deletions(-) create mode 100644 home-manager/machines/wsl/home.nix diff --git a/flake.lock b/flake.lock index b4f58f8..0096fa9 100644 --- a/flake.lock +++ b/flake.lock @@ -85,6 +85,27 @@ "type": "github" } }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1732466619, + "narHash": "sha256-T1e5oceypZu3Q8vzICjv1X/sGs9XfJRMW5OuXHgpB3c=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "f3111f62a23451114433888902a55cf0692b408d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.11", + "repo": "home-manager", + "type": "github" + } + }, "lix": { "flake": false, "locked": { @@ -204,6 +225,7 @@ "root": { "inputs": { "flake-parts": "flake-parts", + "home-manager": "home-manager", "lix-module": "lix-module", "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs_2", diff --git a/flake.nix b/flake.nix index 856d6fc..5005ccd 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,10 @@ url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-2.tar.gz"; inputs.nixpkgs.follows = "nixpkgs"; }; + home-manager = { + url = "github:nix-community/home-manager/release-24.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -21,6 +25,7 @@ # 2. Add foo as a parameter to the outputs function # 3. Add here: foo.flakeModule ./nixos/machines/wsl/configuration.nix + ./home-manager/machines/wsl/home.nix ]; systems = [ "x86_64-linux" diff --git a/home-manager/machines/wsl/home.nix b/home-manager/machines/wsl/home.nix new file mode 100644 index 0000000..7f1bc11 --- /dev/null +++ b/home-manager/machines/wsl/home.nix @@ -0,0 +1,32 @@ +{ withSystem, inputs, ... }: +{ + # perSystem = { ... }: { config.packages.hello = ...; }; + + flake.homeConfigurations.wsl = withSystem "x86_64-linux" ( + ctx@{ config, inputs', ... }: + inputs.home-manager.lib.homeManagerConfiguration { + pkgs = inputs.nixpkgs.legacyPackages.${"x86_64-linux"}; + extraSpecialArgs = { + inherit inputs inputs'; + packages = config.packages; + }; + modules = [ + ( + { + config, + lib, + pkgs, + ... + }: + { + home.username = "nathan"; + home.homeDirectory = "/home/nathan/"; + programs.command-not-found.enable = true; + home.stateVersion = "24.11"; + programs.home-manager.enable = true; + } + ) + ]; + } + ); +} diff --git a/nixos/machines/wsl/configuration.nix b/nixos/machines/wsl/configuration.nix index a09f94d..e1fa598 100644 --- a/nixos/machines/wsl/configuration.nix +++ b/nixos/machines/wsl/configuration.nix @@ -27,13 +27,16 @@ { imports = [ - # WSL support + # WSL support inputs.nixos-wsl.nixosModules.default - # Our modules - (import ../../modules/base.nix {inherit inputs;}) - (import ../../modules/user.nix {inherit inputs;mutableUsers = true;}) + # Our modules + (import ../../modules/base.nix { inherit inputs; }) + (import ../../modules/user.nix { + inherit inputs; + mutableUsers = true; + }) ]; - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; wsl.enable = true; wsl.defaultUser = "nathan"; @@ -42,13 +45,13 @@ "nix-command" "flakes" ]; - - environment.systemPackages = with pkgs; [ - neovim - git - tmux - nixfmt-rfc-style - ]; + + environment.systemPackages = with pkgs; [ + neovim + git + tmux + nixfmt-rfc-style + ]; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/nixos/modules/user.nix b/nixos/modules/user.nix index 9fd2468..ac4fa39 100644 --- a/nixos/modules/user.nix +++ b/nixos/modules/user.nix @@ -12,19 +12,21 @@ }: { - security.polkit = { enable = true; }; - users = { - inherit mutableUsers; - users.${username} = { - home = homedir; - description = "Nathan McCarty"; - shell = pkgs.nushell; - isNormalUser = true; - extraGroups = [ - "wheel" - ]; - hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58."; - }; + security.polkit = { + enable = true; + }; + users = { + inherit mutableUsers; + users.${username} = { + home = homedir; + description = "Nathan McCarty"; + shell = pkgs.nushell; + isNormalUser = true; + extraGroups = [ + "wheel" + ]; + hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58."; + }; - }; + }; }