about summary refs log tree commit diff
path: root/hosts
diff options
context:
space:
mode:
authorBaitinq <30861839+Baitinq@users.noreply.github.com>2022-08-28 22:11:24 +0000
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-08-29 00:11:24 +0200
commitf4195828af618f3451b69a5c7ae09d2ecbdd5b72 (patch)
treeae04ae5afae4a599f06fe46cdb80beca54f27f18 /hosts
parentPackages: Remove xmonadctl (diff)
downloadnixos-config-f4195828af618f3451b69a5c7ae09d2ecbdd5b72.tar.gz
nixos-config-f4195828af618f3451b69a5c7ae09d2ecbdd5b72.tar.bz2
nixos-config-f4195828af618f3451b69a5c7ae09d2ecbdd5b72.zip
Implement non NixOS hosts support
Diffstat (limited to 'hosts')
-rw-r--r--hosts/default.nix46
1 files changed, 28 insertions, 18 deletions
diff --git a/hosts/default.nix b/hosts/default.nix
index 9c23363..5ad2c85 100644
--- a/hosts/default.nix
+++ b/hosts/default.nix
@@ -1,4 +1,4 @@
-{ lib, nixpkgs, inputs, home-manager, ... }:
+{ lib, inputs, isNixOS, nixpkgs, home-manager, ... }:
 let
   user = "baitinq";
 
@@ -10,7 +10,7 @@ let
     { hostname = "vm"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
   ];
 
-  mkHost = { hostname, system, timezone, location }:
+  mkHost = { hostname, system, timezone, location }: isNixOS:
     let
       pkgs = import nixpkgs {
         inherit system;
@@ -23,27 +23,37 @@ let
       };
       extraArgs = { inherit pkgs inputs user secrets hostname timezone location; };
     in
-    nixpkgs.lib.nixosSystem {
-      inherit system;
-      specialArgs = extraArgs;
-      modules = [
-        ./configuration.nix
-        ./${hostname}
-        home-manager.nixosModules.home-manager
+    if isNixOS
+    then
+      nixpkgs.lib.nixosSystem
         {
-          home-manager.useGlobalPkgs = true;
-          home-manager.useUserPackages = true;
-          home-manager.extraSpecialArgs = extraArgs;
-          home-manager.users.${user} = {
-            imports = [ ./home.nix ] ++ [ (import ./${ hostname }/home.nix) ];
-          };
+          inherit system;
+          specialArgs = extraArgs;
+          modules = [
+            ./configuration.nix
+            ./${hostname}
+            home-manager.nixosModules.home-manager
+            {
+              home-manager.useGlobalPkgs = true;
+              home-manager.useUserPackages = true;
+              home-manager.extraSpecialArgs = extraArgs;
+              home-manager.users.${user} = {
+                imports = [ ./home.nix ] ++ [ (import ./${ hostname }/home.nix) ];
+              };
+            }
+          ];
         }
-      ];
-    };
+    else
+      home-manager.lib.homeManagerConfiguration
+        {
+          inherit pkgs;
+          extraSpecialArgs = extraArgs;
+          modules = [ ./home.nix ] ++ [ (import ./${ hostname }/home.nix) ];
+        };
 in
   /*
     We have a list of sets.
     Map each element of the list applying the mkHost function to its elements and returning a set in the listToAttrs format
     builtins.listToAttrs on the result
   */
-builtins.listToAttrs (map ({ hostname, system, timezone, location }: { name = hostname; value = mkHost { inherit hostname system timezone location; }; }) hosts)
+builtins.listToAttrs (map ({ hostname, system, timezone, location }: { name = hostname; value = mkHost { inherit hostname system timezone location; } isNixOS; }) hosts)