diff --git a/nixosModules/clanCore/default.nix b/nixosModules/clanCore/default.nix index e48a50d4b..e5912c74c 100644 --- a/nixosModules/clanCore/default.nix +++ b/nixosModules/clanCore/default.nix @@ -1,10 +1,9 @@ -{ lib, config, ... }: { imports = [ ./backups.nix + ./defaults.nix ./facts ./inventory - ./manual.nix ./meta/interface.nix ./metadata.nix ./networking.nix @@ -12,7 +11,6 @@ ./nix-settings.nix ./options.nix ./outputs.nix - ./packages.nix ./schema.nix ./sops.nix ./vars @@ -22,14 +20,4 @@ ./zfs.nix ]; - # Use systemd during boot as well except: - # - systems with raids as this currently require manual configuration: https://github.com/NixOS/nixpkgs/issues/210210 - # - for containers we currently rely on the `stage-2` init script that sets up our /etc - boot.initrd.systemd.enable = lib.mkDefault (!config.boot.swraid.enable && !config.boot.isContainer); - - # Work around for https://github.com/NixOS/nixpkgs/issues/124215 - documentation.info.enable = lib.mkDefault false; - - # Don't install the /lib/ld-linux.so.2 stub. This saves one instance of nixpkgs. - environment.ldso32 = null; } diff --git a/nixosModules/clanCore/defaults.nix b/nixosModules/clanCore/defaults.nix new file mode 100644 index 000000000..97781d729 --- /dev/null +++ b/nixosModules/clanCore/defaults.nix @@ -0,0 +1,42 @@ +{ + lib, + config, + pkgs, + ... +}: +{ + options.clan.core.setDefaults = (lib.mkEnableOption "Clan defaults") // { + default = true; + example = false; + }; + + config = lib.mkIf config.clan.core.setDefaults { + # Use systemd during boot as well except: + # - systems with raids as this currently require manual configuration: https://github.com/NixOS/nixpkgs/issues/210210 + # - for containers we currently rely on the `stage-2` init script that sets up our /etc + boot.initrd.systemd.enable = lib.mkDefault (!config.boot.swraid.enable && !config.boot.isContainer); + + # This disables the HTML manual and `nixos-help` command but leaves + # `man configuration.nix` + documentation.doc.enable = lib.mkDefault false; + + # Work around for https://github.com/NixOS/nixpkgs/issues/124215 + documentation.info.enable = lib.mkDefault false; + + # Don't install the /lib/ld-linux.so.2 stub. This saves one instance of nixpkgs. + environment.ldso32 = null; + + environment.systemPackages = [ + # essential debugging tools for networked services + pkgs.dnsutils + pkgs.tcpdump + pkgs.curl + pkgs.jq + pkgs.htop + + pkgs.nixos-facter # for `clan machines update-hardware-config --backend nixos-facter` + + pkgs.gitMinimal + ]; + }; +} diff --git a/nixosModules/clanCore/manual.nix b/nixosModules/clanCore/manual.nix deleted file mode 100644 index e5b4f9a2e..000000000 --- a/nixosModules/clanCore/manual.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs, ... }: -{ - documentation.nixos.enable = pkgs.lib.mkDefault false; -} diff --git a/nixosModules/clanCore/networking.nix b/nixosModules/clanCore/networking.nix index f58ee4a85..28a995497 100644 --- a/nixosModules/clanCore/networking.nix +++ b/nixosModules/clanCore/networking.nix @@ -91,7 +91,7 @@ ] ) ]; - config = { + config = lib.mkIf config.clan.core.setDefaults { # conflicts with systemd-resolved networking.useHostResolvConf = false; diff --git a/nixosModules/clanCore/nix-settings.nix b/nixosModules/clanCore/nix-settings.nix index 64aeaeef1..2fc906ad3 100644 --- a/nixosModules/clanCore/nix-settings.nix +++ b/nixosModules/clanCore/nix-settings.nix @@ -1,7 +1,7 @@ -{ lib, ... }: +{ lib, config, ... }: # Taken from: # https://github.com/nix-community/srvos/blob/main/nixos/common/nix.nix -{ +lib.mkIf config.clan.core.setDefaults { # Fallback quickly if substituters are not available. nix.settings.connect-timeout = 5; diff --git a/nixosModules/clanCore/packages.nix b/nixosModules/clanCore/packages.nix deleted file mode 100644 index b896f41c4..000000000 --- a/nixosModules/clanCore/packages.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - pkgs, - ... -}: -{ - environment.systemPackages = [ - # essential debugging tools for networked services - pkgs.dnsutils - pkgs.tcpdump - pkgs.curl - pkgs.jq - pkgs.htop - - pkgs.nixos-facter # for `clan machines update-hardware-config --backend nixos-facter` - - pkgs.gitMinimal - ]; -}