diff --git a/flake.nix b/flake.nix index 0194a81..42e0933 100644 --- a/flake.nix +++ b/flake.nix @@ -24,22 +24,12 @@ inherit username system; }; in { - nixosConfigurations.dekomori = nixpkgs.lib.nixosSystem { - inherit specialArgs; - modules = [ - ./hosts/dekomori - ./modules/desktop - ./options/desktop + nixosConfigurations = import ./hosts ( + {inherit specialArgs;} // {isNixOS = true;} + ); - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - - home-manager.extraSpecialArgs = specialArgs; - home-manager.users."${username}" = ./home/desktop; - } - ]; - }; + homeConfigurations = import ./hosts ( + {inherit specialArgs;} // {isNixOS = false;} + ); }; } diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..3954764 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,54 @@ +{ + specialArgs, + isNixOS, + ... +}: let + username = "${specialArgs.username}"; + mkHost = host: type: let + lib = specialArgs.inputs.nixpkgs.lib; + home-manager = specialArgs.inputs.home-manager; + nixpkgs = specialArgs.inputs.nixpkgs; + in + if isNixOS + then + lib.nixosSystem { + inherit specialArgs; + modules = [ + ./${host} + ../modules/${type} + ../options/${type} + home-manager.nixosModules.home-manager + { + home-manager = { + # Because we use Home-Manager as a pure configuration manager. + useUserPackages = lib.mkForce false; + useGlobalPkgs = lib.mkForce true; + + extraSpecialArgs = specialArgs; + users."${username}" = { + imports = [ + ../home/${type} + ]; + }; + }; + } + ]; + } + else + home-manager.lib.homeManagerConfiguration { + extraSpecialArgs = specialArgs; + pkgs = import nixpkgs {config.allowUnfree = lib.mkForce true;}; + modules = [ + ../home/${type} + ]; + }; +in + builtins.listToAttrs (builtins.attrValues (builtins.mapAttrs (host: type: { + name = + if isNixOS + then host + else "${username}@${host}"; + value = mkHost host type; + }) { + "dekomori" = "desktop"; + })) diff --git a/modules/core/user.nix b/modules/core/user.nix index 71b96fe..0ad3862 100644 --- a/modules/core/user.nix +++ b/modules/core/user.nix @@ -3,7 +3,7 @@ users.groups."${username}" = {}; users.users."${username}" = { # TODO: probably not needed - #home = "/home/yunfachi"; + #home = "/home/${username}"; isNormalUser = true; description = "${username}"; extraGroups = [