]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move ssh to its own module
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 3 Apr 2019 08:21:20 +0000 (10:21 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 3 Apr 2019 08:28:10 +0000 (10:28 +0200)
nixops/eldiron.nix
nixops/modules/ssh/default.nix [new file with mode: 0644]
nixops/modules/ssh/ldap_authorized_keys.sh [moved from nixops/ldap_authorized_keys.sh with 100% similarity]

index 752ef0a1b1802358d90fa08bb6ab0a3f1b1f5755..9d32bb3196d9b2630bf7505685794675dda0adae 100644 (file)
@@ -6,7 +6,6 @@
   };
 
   eldiron = { config, pkgs, mylibs, myconfig, ... }:
-    with mylibs;
   {
     _module.args = {
       pkgsNext = import <nixpkgsNext> {};
@@ -25,6 +24,7 @@
     };
 
     imports = [
+      ./modules/ssh
       ./modules/certificates.nix
       ./modules/gitolite
       ./modules/databases
       MaxLevelStore="warning"
       MaxRetentionSec="1year"
       '';
-    networking = {
-      firewall = {
-        enable = true;
-        allowedTCPPorts = [ 22 ];
-      };
-    };
+    networking.firewall.enable = true;
 
     deployment = {
       targetEnv = "hetzner";
       pkgs.vim
     ];
 
-    services.openssh.extraConfig = ''
-      AuthorizedKeysCommand     /etc/ssh/ldap_authorized_keys
-      AuthorizedKeysCommandUser nobody
-      '';
-
-    environment.etc."ssh/ldap_authorized_keys" = let
-      ldap_authorized_keys =
-        wrap {
-          name = "ldap_authorized_keys";
-          file = ./ldap_authorized_keys.sh;
-          vars = {
-            LDAP_PASS = myconfig.env.sshd.ldap.password;
-            GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
-            ECHO = "${pkgs.coreutils}/bin/echo";
-          };
-          paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
-        };
-    in {
-      enable = true;
-      mode = "0755";
-      user = "root";
-      source = ldap_authorized_keys;
-    };
-
     services.cron = {
       enable = true;
       systemCronJobs = [
diff --git a/nixops/modules/ssh/default.nix b/nixops/modules/ssh/default.nix
new file mode 100644 (file)
index 0000000..b28f6ca
--- /dev/null
@@ -0,0 +1,30 @@
+{ lib, pkgs, config, mylibs, myconfig, ... }:
+{
+  config = {
+    networking.firewall.allowedTCPPorts = [ 22 ];
+
+    services.openssh.extraConfig = ''
+      AuthorizedKeysCommand     /etc/ssh/ldap_authorized_keys
+      AuthorizedKeysCommandUser nobody
+      '';
+
+    environment.etc."ssh/ldap_authorized_keys" = let
+      ldap_authorized_keys =
+        mylibs.wrap {
+          name = "ldap_authorized_keys";
+          file = ./ldap_authorized_keys.sh;
+          vars = {
+            LDAP_PASS = myconfig.env.sshd.ldap.password;
+            GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell";
+            ECHO = "${pkgs.coreutils}/bin/echo";
+          };
+          paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ];
+        };
+    in {
+      enable = true;
+      mode = "0755";
+      user = "root";
+      source = ldap_authorized_keys;
+    };
+  };
+}