From 27100bacb770aace381d032880588b94976217dd Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Wed, 10 Jan 2024 00:25:45 +0100 Subject: [PATCH] modularise flake config: fix and modularise home-manager config generation unfortunately, homeConfigurations do not follow the pattern of having system-specific sub-attrs and thus are dependent on a specific system per-se. --- flake.nix | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/flake.nix b/flake.nix index 61e55a0..21a0317 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ }; outputs = - { self, nixpkgs, nur, lanzaboote, flake-utils, ... }@inputs: + { self, nixpkgs, nur, lanzaboote, flake-utils, home-manager, ... }@inputs: let # FIXME: allow different systems systems = flake-utils.lib.system; @@ -39,31 +39,34 @@ modules = defaultModules ++ extraModules; inherit system; }; + mkHomeManager = confName: user: system: # unfortunately, home-manager configs are still system-specific + # FIXME: this is thus still linux-x86_64 specific + home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + modules = [ + { + imports = [ + nur.hmModules.nur + # TODO: $name can be utilised to conditionally load other config files + ./home/home.nix + ]; + # extends the home config + home.username = user; + home.homeDirectory = "/home/${user}"; + } + ]; + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + extraSpecialArgs = { + inherit inputs system; + }; + }; in { nixosConfigurations = { thinknix = mkSystem systems.x86_64-linux [ ./hosts/thinknix inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t440s lanzaboote.nixosModules.lanzaboote ]; framenix = mkSystem systems.x86_64-linux [ ./hosts/framenix inputs.nixos-hardware.nixosModules.framework-13-7040-amd lanzaboote.nixosModules.lanzaboote ]; }; - # FIXME: see mkHomemanager - homeConfigurations.spiollinux = inputs.home-manager.lib.homeManagerConfiguration { - - modules = [ - { - imports = [ - nur.hmModules.nur - ./home/home.nix - ]; - # extends the home config - home.username = "spiollinux"; - home.homeDirectory = "/home/spiollinux"; - } - ]; - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - extraSpecialArgs = { - inherit inputs; - }; - }; + homeConfigurations.spiollinux = mkHomeManager "spiollinux" "spiollinux" systems.x86_64-linux; }; }