Commit 9585a26bb5be

Vincent Demeester <vincent@sbr.pm>
2020-05-25 18:01:42
users: add an options to load machines.nix
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 8514595
Changed files (3)
modules/profiles/users.nixos.nix
@@ -18,49 +18,62 @@ in
         type = types.str;
       };
       # add more options (like openssh keys and config)
-    };
-  };
-  config = mkIf cfg.enable {
-    users = {
-      extraUsers = {
-        ${cfg.user} = {
-          isNormalUser = true;
-          uid = 1000;
-          createHome = true;
-          extraGroups = [ "wheel" "input" ] ++ optionals config.profiles.desktop.enable [ "audio" "video" "lp" "scanner" "networkmanager" ]
-            ++ optionals config.profiles.docker.enable [ "docker" ]
-            ++ optionals config.profiles.buildkit.enable [ "buildkit" ]
-            ++ optionals config.profiles.virtualization.enable [ "libvirtd" "vboxusers" ];
-          shell = if config.programs.fish.enable then pkgs.fish else pkgs.zsh;
-          initialPassword = "changeMe";
-          openssh.authorizedKeys.keys =
-            with import ../../assets/machines.nix; [ ssh.yubikey.key ssh.yubikey5.key ssh.wakasu.key ssh.vincent.key ssh.houbeb.key ssh.hokkaido.key ssh.okinawa.key ];
-          subUidRanges = [{ startUid = 100000; count = 65536; }];
-          subGidRanges = [{ startGid = 100000; count = 65536; }];
-        };
+      withMachines = mkOption {
+        default = true;
+        description = "Load machines.nix";
+        type = types.bool;
       };
     };
-    programs.ssh.extraConfig = with import ../../assets/machines.nix; ''
-      Host kerkouane kerkouane.sbr.pm
-        Hostname kerkouane.sbr.pm
-        Port ${toString ssh.kerkouane.port}
-      Host kerkouane.vpn ${wireguard.ips.kerkouane}
-        Hostname ${wireguard.ips.kerkouane}
-        Port ${toString ssh.kerkouane.port}
-      Host carthage carthage.sbr.pm
-        Hostname carthage.sbr.pm
-        Port ${toString ssh.carthage.port}
-      Host carthage.vpn ${wireguard.ips.carthage}
-        Hostname ${wireguard.ips.carthage}
-        Port ${toString ssh.carthage.port}
-      Host hokkaido.vpn ${wireguard.ips.hokkaido}
-        Hostname ${wireguard.ips.hokkaido}
-      Host honshu.vpn ${wireguard.ips.honshu}
-        Hostname ${wireguard.ips.honshu}
-      Host okinawa.vpn ${wireguard.ips.okinawa}
-        Hostname ${wireguard.ips.okinawa}
-      Host wakasu.vpn ${wireguard.ips.wakasu}
-        Hostname ${wireguard.ips.wakasu}
-    '';
   };
+  config = mkIf cfg.enable (mkMerge [
+    {
+      users = {
+        extraUsers = {
+          ${cfg.user} = {
+            isNormalUser = true;
+            uid = 1000;
+            createHome = true;
+            extraGroups = [ "wheel" "input" ] ++ optionals config.profiles.desktop.enable [ "audio" "video" "lp" "scanner" "networkmanager" ]
+              ++ optionals config.profiles.docker.enable [ "docker" ]
+              ++ optionals config.profiles.buildkit.enable [ "buildkit" ]
+              ++ optionals config.profiles.virtualization.enable [ "libvirtd" "vboxusers" ];
+            shell = if config.programs.fish.enable then pkgs.fish else pkgs.zsh;
+            initialPassword = "changeMe";
+            subUidRanges = [{ startUid = 100000; count = 65536; }];
+            subGidRanges = [{ startGid = 100000; count = 65536; }];
+          };
+        };
+      };
+    }
+    (
+      mkIf cfg.withMachines {
+        users.extraUsers."${cfg.user}" = {
+          openssh.authorizedKeys.keys =
+            with import ../../assets/machines.nix; [ ssh.yubikey.key ssh.yubikey5.key ssh.wakasu.key ssh.vincent.key ssh.houbeb.key ssh.hokkaido.key ssh.okinawa.key ];
+        };
+        programs.ssh.extraConfig = with import ../../assets/machines.nix; ''
+          Host kerkouane kerkouane.sbr.pm
+            Hostname kerkouane.sbr.pm
+            Port ${toString ssh.kerkouane.port}
+          Host kerkouane.vpn ${wireguard.ips.kerkouane}
+            Hostname ${wireguard.ips.kerkouane}
+            Port ${toString ssh.kerkouane.port}
+          Host carthage carthage.sbr.pm
+            Hostname carthage.sbr.pm
+            Port ${toString ssh.carthage.port}
+          Host carthage.vpn ${wireguard.ips.carthage}
+            Hostname ${wireguard.ips.carthage}
+            Port ${toString ssh.carthage.port}
+          Host hokkaido.vpn ${wireguard.ips.hokkaido}
+            Hostname ${wireguard.ips.hokkaido}
+          Host honshu.vpn ${wireguard.ips.honshu}
+            Hostname ${wireguard.ips.honshu}
+          Host okinawa.vpn ${wireguard.ips.okinawa}
+            Hostname ${wireguard.ips.okinawa}
+          Host wakasu.vpn ${wireguard.ips.wakasu}
+            Hostname ${wireguard.ips.wakasu}
+        '';
+      }
+    )
+  ]);
 }
systems/hokkaido.nix
@@ -16,6 +16,7 @@ in
   ];
 
   profiles.home = enableHome;
+  profiles.users.withMachines = enableHome;
 
   networking = {
     hostName = "hokkaido";
systems/wakasu.nix
@@ -18,6 +18,7 @@ in
   ];
 
   profiles.home = enableHome;
+  profiles.users.withMachines = enableHome;
 
   networking = {
     hostName = "wakasu";
@@ -38,6 +39,12 @@ in
     home.packages = with pkgs; [ htop ];
   };
 
+  # FIXME: ain't true
+  fileSystems."/" =
+    {
+      device = "/dev/disk/by-uuid/884a3d57-f652-49b2-9c8b-f6eebd5edbeb";
+      fsType = "ext4";
+    };
   # FIXME: move this away
   profiles.nix-config.enable = false;
   home-manager.useGlobalPkgs = true;