about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--flake.nix12
-rw-r--r--hosts/configuration.nix11
-rw-r--r--hosts/default.nix25
-rw-r--r--hosts/luna/default.nix2
-rw-r--r--hosts/luna/hardware/chromebook/default.nix4
-rw-r--r--hosts/luna/hardware/chromebook/disks.nix (renamed from hosts/luna/disks.nix)11
-rw-r--r--hosts/luna/hardware/chromebook/hardware.nix (renamed from hosts/luna/hardware.nix)0
-rw-r--r--hosts/phobos/default.nix2
-rw-r--r--hosts/phobos/hardware/laptop/default.nix4
-rw-r--r--hosts/phobos/hardware/laptop/disks.nix (renamed from hosts/phobos/disks.nix)14
-rw-r--r--hosts/phobos/hardware/laptop/hardware.nix (renamed from hosts/phobos/hardware.nix)0
-rw-r--r--hosts/vm/default.nix2
-rw-r--r--hosts/vm/hardware/virtualbox/default.nix4
-rw-r--r--hosts/vm/hardware/virtualbox/disks.nix (renamed from hosts/vm/disks.nix)12
-rw-r--r--hosts/vm/hardware/virtualbox/hardware.nix (renamed from hosts/vm/hardware.nix)0
15 files changed, 74 insertions, 29 deletions
diff --git a/flake.nix b/flake.nix
index e5435fd..2becc78 100644
--- a/flake.nix
+++ b/flake.nix
@@ -37,6 +37,7 @@
         isNixOS = true;
         extraModules = [ ];
         isIso = false;
+        isHardware = true;
         inherit (nixpkgs) lib;
         inherit inputs user nixpkgs home-manager;
       };
@@ -45,6 +46,7 @@
         isNixOS = false;
         extraModules = [ ];
         isIso = false;
+        isHardware = false;
         #no COde duplication here: TODO
         inherit (nixpkgs) lib;
         inherit inputs user nixpkgs home-manager;
@@ -54,10 +56,20 @@
         isNixOS = true;
         extraModules = [ ];
         isIso = true;
+        isHardware = false;
         user = "nixos";
         #no COde duplication here: TODO
         inherit (nixpkgs) lib;
         inherit inputs nixpkgs home-manager;
       };
+
+      nixosNoHardwareConfigurations = import ./hosts {
+        isNixOS = true;
+        extraModules = [ ];
+        isIso = false;
+        isHardware = false;
+        inherit (nixpkgs) lib;
+        inherit inputs user nixpkgs home-manager;
+      };
     };
 }
diff --git a/hosts/configuration.nix b/hosts/configuration.nix
index bb0817c..5bf0cf0 100644
--- a/hosts/configuration.nix
+++ b/hosts/configuration.nix
@@ -168,17 +168,6 @@
     };
   };
 
-  environment.persistence."/persist" = {
-    directories = [
-      "/var/log"
-      "/var/lib"
-    ];
-    files = [
-      "/etc/machine-id"
-      "/etc/nix/id_rsa"
-    ];
-  };
-
   nix = {
     registry.nixpkgs.flake = inputs.nixpkgs;
     gc = {
diff --git a/hosts/default.nix b/hosts/default.nix
index 924187e..a43f2bd 100644
--- a/hosts/default.nix
+++ b/hosts/default.nix
@@ -1,14 +1,15 @@
-{ lib, inputs, extraModules, isNixOS, isIso, user, nixpkgs, home-manager, ... }:
+{ lib, inputs, extraModules, isNixOS, isIso, isHardware, user, nixpkgs, home-manager, ... }:
 let
   secrets = import ../secrets;
 
+  #TODO: Better implementation of hardare (not having to declare here but just in command)
   hosts = [
-    { hostname = "phobos"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
-    { hostname = "luna"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
-    { hostname = "vm"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
+    { host = "phobos"; hardware = "laptop"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
+    { host = "luna"; hardware = "chromebook"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
+    { host = "vm"; hardware = "virtualbox"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; }
   ];
 
-  mkHost = { hostname, system, timezone, location }: extraModules: isNixOS: isIso:
+  mkHost = { host, hardware, system, timezone, location }: extraModules: isNixOS: isIso: isHardware:
     let
       pkgs = import nixpkgs {
         inherit system;
@@ -22,8 +23,10 @@ let
           (import ../overlays)
         ];
       };
-      extraArgs = { inherit pkgs inputs isIso user secrets hostname timezone location; };
+      extraArgs = { inherit pkgs inputs isIso isHardware user secrets timezone location; hostname = host; };
+      #TODO: FIXME
       extraSpecialModules = if isIso then extraModules ++ [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" ] else extraModules;
+      megaSpecialModules = if isHardware then extraSpecialModules ++ [ ./${ host}/hardware/${hardware} ] else extraSpecialModules;
     in
     if isNixOS
     then
@@ -33,7 +36,7 @@ let
           specialArgs = extraArgs;
           modules = [
             ./configuration.nix
-            ./${hostname}
+            ./${host}
             home-manager.nixosModules.home-manager
             {
               home-manager.useGlobalPkgs = true;
@@ -42,11 +45,11 @@ let
               home-manager.users.${user} = {
                 imports = [
                   ./home.nix
-                  ./${ hostname }/home.nix
+                  ./${ host }/home.nix
                 ];
               };
             }
-          ] ++ extraSpecialModules;
+          ] ++ megaSpecialModules;
         }
     else
       home-manager.lib.homeManagerConfiguration
@@ -55,7 +58,7 @@ let
           extraSpecialArgs = extraArgs;
           modules = [
             ./home.nix
-            ./${ hostname }/home.nix
+            ./${ host }/home.nix
           ];
         };
 in
@@ -64,4 +67,4 @@ in
     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; } extraModules isNixOS isIso; }) hosts)
+builtins.listToAttrs (map ({ host, hardware, system, timezone, location }: { name = host; value = mkHost { inherit host hardware system timezone location; } extraModules isNixOS isIso isHardware; }) hosts)
diff --git a/hosts/luna/default.nix b/hosts/luna/default.nix
index f70c975..9fbe164 100644
--- a/hosts/luna/default.nix
+++ b/hosts/luna/default.nix
@@ -1,8 +1,6 @@
 { config, pkgs, lib, secrets, hostname, inputs, user, ... }: {
 
   imports = [
-    ./hardware.nix
-
     ../../modules/power-save
     ../../modules/bluetooth
   ];
diff --git a/hosts/luna/hardware/chromebook/default.nix b/hosts/luna/hardware/chromebook/default.nix
new file mode 100644
index 0000000..b0125ee
--- /dev/null
+++ b/hosts/luna/hardware/chromebook/default.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+  imports = [ ./hardware.nix ];
+}
diff --git a/hosts/luna/disks.nix b/hosts/luna/hardware/chromebook/disks.nix
index bb12ec9..ad0e014 100644
--- a/hosts/luna/disks.nix
+++ b/hosts/luna/hardware/chromebook/disks.nix
@@ -56,6 +56,17 @@ in
 {
   config = {
 
+    environment.persistence."/persist" = {
+      directories = [
+        "/var/log"
+        "/var/lib"
+      ];
+      files = [
+        "/etc/machine-id"
+        "/etc/nix/id_rsa"
+      ];
+    };
+
     fileSystems."/" = {
       device = "none";
       fsType = "tmpfs";
diff --git a/hosts/luna/hardware.nix b/hosts/luna/hardware/chromebook/hardware.nix
index 85b7227..85b7227 100644
--- a/hosts/luna/hardware.nix
+++ b/hosts/luna/hardware/chromebook/hardware.nix
diff --git a/hosts/phobos/default.nix b/hosts/phobos/default.nix
index 5bdd524..5d4e4cc 100644
--- a/hosts/phobos/default.nix
+++ b/hosts/phobos/default.nix
@@ -1,8 +1,6 @@
 { config, pkgs, lib, secrets, hostname, inputs, user, ... }: {
 
   imports = [
-    ./hardware.nix
-
     ../../modules/bluetooth
   ];
 
diff --git a/hosts/phobos/hardware/laptop/default.nix b/hosts/phobos/hardware/laptop/default.nix
new file mode 100644
index 0000000..b0125ee
--- /dev/null
+++ b/hosts/phobos/hardware/laptop/default.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+  imports = [ ./hardware.nix ];
+}
diff --git a/hosts/phobos/disks.nix b/hosts/phobos/hardware/laptop/disks.nix
index 2927fe5..07618df 100644
--- a/hosts/phobos/disks.nix
+++ b/hosts/phobos/hardware/laptop/disks.nix
@@ -1,5 +1,17 @@
 { config, lib, inputs, pkgs, modulesPath, isIso, ... }:
 {
+
+  environment.persistence."/persist" = {
+    directories = [
+      "/var/log"
+      "/var/lib"
+    ];
+    files = [
+      "/etc/machine-id"
+      "/etc/nix/id_rsa"
+    ];
+  };
+
   fileSystems."/" = {
     device = "none";
     fsType = "tmpfs";
@@ -33,7 +45,7 @@
 
   swapDevices = [ ];
 
-  services.btrfs.autoScrub.enable = if !isIso then true else false;
+  services.btrfs.autoScrub.enable = true;
 
   zramSwap.enable = true;
 
diff --git a/hosts/phobos/hardware.nix b/hosts/phobos/hardware/laptop/hardware.nix
index cbec828..cbec828 100644
--- a/hosts/phobos/hardware.nix
+++ b/hosts/phobos/hardware/laptop/hardware.nix
diff --git a/hosts/vm/default.nix b/hosts/vm/default.nix
index 0150cd6..4fbf51e 100644
--- a/hosts/vm/default.nix
+++ b/hosts/vm/default.nix
@@ -1,8 +1,6 @@
 { config, pkgs, lib, secrets, hostname, inputs, user, ... }: {
 
   imports = [
-    # Include the results of the hardware scan.
-    ./hardware.nix
   ];
 
   # Configure keymap in X11
diff --git a/hosts/vm/hardware/virtualbox/default.nix b/hosts/vm/hardware/virtualbox/default.nix
new file mode 100644
index 0000000..b0125ee
--- /dev/null
+++ b/hosts/vm/hardware/virtualbox/default.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+  imports = [ ./hardware.nix ];
+}
diff --git a/hosts/vm/disks.nix b/hosts/vm/hardware/virtualbox/disks.nix
index cabed80..6ba15ec 100644
--- a/hosts/vm/disks.nix
+++ b/hosts/vm/hardware/virtualbox/disks.nix
@@ -1,5 +1,17 @@
 { config, lib, inputs, pkgs, modulesPath, ... }:
 {
+
+  environment.persistence."/persist" = {
+    directories = [
+      "/var/log"
+      "/var/lib"
+    ];
+    files = [
+      "/etc/machine-id"
+      "/etc/nix/id_rsa"
+    ];
+  };
+
   fileSystems."/" = {
     device = "none";
     fsType = "tmpfs";
diff --git a/hosts/vm/hardware.nix b/hosts/vm/hardware/virtualbox/hardware.nix
index 470f733..470f733 100644
--- a/hosts/vm/hardware.nix
+++ b/hosts/vm/hardware/virtualbox/hardware.nix