diff --git a/hosts/apollo/configuration.nix b/hosts/apollo/configuration.nix index d31ae89b..db4c939c 100644 --- a/hosts/apollo/configuration.nix +++ b/hosts/apollo/configuration.nix @@ -11,6 +11,7 @@ imports = [ ./hardware-configuration.nix ../../system + ./syncthing.nix ]; networking = { @@ -19,6 +20,7 @@ networking = { m-0 = { laptop.enable = true; + standalone.enable = true; }; home-manager.users."${me.user}" = (import ./home.nix); diff --git a/hosts/apollo/syncthing.nix b/hosts/apollo/syncthing.nix new file mode 100644 index 00000000..6d4ab08e --- /dev/null +++ b/hosts/apollo/syncthing.nix @@ -0,0 +1,18 @@ +{config, lib, ...}: +with lib; +let + me = config.m-0.private.me; +in { + +boot.kernel.sysctl = { "fs.inotify.max_user_watches" = 204800; }; +services = mkIf config.m-0.standalone.enable { + syncthing = { + dataDir = "/home/${me.user}/.config/syncthing"; + enable = true; + group = "users"; + user = me.user; + openDefaultPorts = true; + }; +}; + +} diff --git a/system/default.nix b/system/default.nix index 5ac0c364..cc55de6b 100644 --- a/system/default.nix +++ b/system/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, config, lib, ... }: { # channel = 18.03 @@ -7,56 +7,25 @@ ../common/secret ../common/private-options.nix ./modules/laptop.nix - ./modules/server.nix - ./admin.nix - ./syncthing.nix + ./modules/server + ./modules/standalone ./modules/cdarknet ./modules/loginctl-linger.nix ]; + i18n = { defaultLocale = "en_US.UTF-8"; }; time.timeZone = "Europe/Berlin"; - # So that boot does not fill up with old kernels - boot.loader.grub.configurationLimit = 5; - - users = { - defaultUserShell = pkgs.zsh; - mutableUsers = false; - }; - - security.sudo.extraConfig = " - Defaults timestamp_type=global, timestamp_timeout=15 - "; - networking = { firewall.allowPing = true; useDHCP = false; }; - services = { - sshd.enable = true; - }; - - environment = { - # Put these into an extra file so the essential packages can also be included on non selfadminstrated systems from home-manager - systemPackages = let essentials = import ../common/essentials.nix; - in (essentials.core pkgs) ++ (essentials.extra pkgs); - sessionVariables = { - TERMINFO = "/run/current-system/sw/share/terminfo"; - }; - }; - - programs = { - mtr.enable = true; - zsh = { - enable = true; - enableAutosuggestions = true; - enableCompletion = true; - syntaxHighlighting.enable = true; - }; + users = { + mutableUsers = false; }; } diff --git a/system/modules/server.nix b/system/modules/server/default.nix similarity index 100% rename from system/modules/server.nix rename to system/modules/server/default.nix diff --git a/system/modules/init_ssh.nix b/system/modules/server/init_ssh.nix similarity index 100% rename from system/modules/init_ssh.nix rename to system/modules/server/init_ssh.nix diff --git a/system/admin.nix b/system/modules/standalone/admin.nix similarity index 83% rename from system/admin.nix rename to system/modules/standalone/admin.nix index 9735c4e1..106ee24f 100644 --- a/system/admin.nix +++ b/system/modules/standalone/admin.nix @@ -1,8 +1,9 @@ -{config, ...}: +{config, lib, ...}: +with lib; let me = config.m-0.private.me; in { - users.users = { + users.users = mkIf config.m-0.standalone.enable { "${me.user}" = { linger = true; description = me.name; diff --git a/system/modules/standalone/default.nix b/system/modules/standalone/default.nix new file mode 100644 index 00000000..add6bec4 --- /dev/null +++ b/system/modules/standalone/default.nix @@ -0,0 +1,49 @@ +{ pkgs, config, lib, ... }: +with lib; +{ + +imports = [ ./admin.nix ]; + +options.m-0.standalone.enable = mkOption { + type = types.bool; + default = false; +}; + +config = mkIf config.m-0.standalone.enable { + # So that boot does not fill up with old kernels + boot.loader.grub.configurationLimit = 5; + + users = { + defaultUserShell = pkgs.zsh; + mutableUsers = false; + }; + + security.sudo.extraConfig = " + Defaults timestamp_type=global, timestamp_timeout=15 + "; + + services = { + sshd.enable = true; + }; + + environment = { + # Put these into an extra file so the essential packages can also be included on non selfadminstrated systems from home-manager + systemPackages = let essentials = import ../../../common/essentials.nix; + in (essentials.core pkgs) ++ (essentials.extra pkgs); + sessionVariables = { + TERMINFO = "/run/current-system/sw/share/terminfo"; + }; + }; + + programs = { + mtr.enable = true; + zsh = { + enable = true; + enableAutosuggestions = true; + enableCompletion = true; + syntaxHighlighting.enable = true; + }; + }; +}; + +} diff --git a/system/syncthing.nix b/system/syncthing.nix deleted file mode 100644 index 7a1b0b62..00000000 --- a/system/syncthing.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - boot.kernel.sysctl = { "fs.inotify.max_user_watches" = 204800; }; - services = { - syncthing = { - dataDir = "/home/maralorn/.config/syncthing"; - enable = true; - group = "users"; - user = "maralorn"; - openDefaultPorts = true; - }; - }; -}