diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2024-08-01 10:48:06 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2024-08-01 10:48:06 +0200 |
| commit | 0f06a86b1eaa99ff21cdce8c5f1c54b688cbbcf6 (patch) | |
| tree | 41691fef5468c5efbc32c12cbacd55e97b23b0de /modules | |
| parent | 48f8d3c11d9117f10e6ca5b76a08b91cef5c861b (diff) | |
| download | nixos-0f06a86b1eaa99ff21cdce8c5f1c54b688cbbcf6.tar nixos-0f06a86b1eaa99ff21cdce8c5f1c54b688cbbcf6.tar.gz nixos-0f06a86b1eaa99ff21cdce8c5f1c54b688cbbcf6.tar.bz2 nixos-0f06a86b1eaa99ff21cdce8c5f1c54b688cbbcf6.tar.xz nixos-0f06a86b1eaa99ff21cdce8c5f1c54b688cbbcf6.zip | |
...
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ibus.nix | 79 | ||||
| -rw-r--r-- | modules/network-interfaces-systemd.nix | 6 | ||||
| -rw-r--r-- | modules/yggdrasil-wg/default.nix | 32 |
3 files changed, 14 insertions, 103 deletions
diff --git a/modules/ibus.nix b/modules/ibus.nix deleted file mode 100644 index bb9b3765..00000000 --- a/modules/ibus.nix +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 1 | { config, pkgs, lib, ... }: | ||
| 2 | |||
| 3 | with lib; | ||
| 4 | |||
| 5 | let | ||
| 6 | cfg = config.i18n.inputMethod.ibus; | ||
| 7 | ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; }; | ||
| 8 | ibusEngine = types.package // { | ||
| 9 | name = "ibus-engine"; | ||
| 10 | check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x); | ||
| 11 | }; | ||
| 12 | in | ||
| 13 | { | ||
| 14 | disabledModules = [ "i18n/input-method/ibus.nix" ]; | ||
| 15 | |||
| 16 | imports = [ | ||
| 17 | (mkRenamedOptionModule [ "programs" "ibus" "plugins" ] [ "i18n" "inputMethod" "ibus" "engines" ]) | ||
| 18 | ]; | ||
| 19 | |||
| 20 | options = { | ||
| 21 | i18n.inputMethod.ibus = { | ||
| 22 | engines = mkOption { | ||
| 23 | type = with types; listOf ibusEngine; | ||
| 24 | default = []; | ||
| 25 | example = literalExpression "with pkgs.ibus-engines; [ mozc hangul ]"; | ||
| 26 | description = | ||
| 27 | let | ||
| 28 | enginesDrv = filterAttrs (const isDerivation) pkgs.ibus-engines; | ||
| 29 | engines = concatStringsSep ", " | ||
| 30 | (map (name: "<literal>${name}</literal>") (attrNames enginesDrv)); | ||
| 31 | in | ||
| 32 | "Enabled IBus engines. Available engines are: ${engines}."; | ||
| 33 | }; | ||
| 34 | panel = mkOption { | ||
| 35 | type = with types; nullOr path; | ||
| 36 | default = null; | ||
| 37 | example = literalExpression ''"''${pkgs.plasma5Packages.plasma-desktop}/lib/libexec/kimpanel-ibus-panel"''; | ||
| 38 | description = "Replace the IBus panel with another panel."; | ||
| 39 | }; | ||
| 40 | }; | ||
| 41 | }; | ||
| 42 | |||
| 43 | config = mkIf (config.i18n.inputMethod.enabled == "ibus") { | ||
| 44 | i18n.inputMethod.package = ibusPackage; | ||
| 45 | |||
| 46 | # Without dconf enabled it is impossible to use IBus | ||
| 47 | programs.dconf.enable = true; | ||
| 48 | |||
| 49 | programs.dconf.packages = [ ibusPackage ]; | ||
| 50 | |||
| 51 | environment.variables = { | ||
| 52 | GTK_IM_MODULE = "ibus"; | ||
| 53 | QT_IM_MODULE = "ibus"; | ||
| 54 | XMODIFIERS = "@im=ibus"; | ||
| 55 | }; | ||
| 56 | |||
| 57 | xdg.portal.extraPortals = mkIf config.xdg.portal.enable [ | ||
| 58 | ibusPackage | ||
| 59 | ]; | ||
| 60 | |||
| 61 | systemd.user.services.ibus = { | ||
| 62 | description = "Intelligent Input Bus"; | ||
| 63 | documentation = ["man:ibus-daemon(1)"]; | ||
| 64 | after = ["graphical-session-pre.target"]; | ||
| 65 | wantedBy = ["graphical-session.target"]; | ||
| 66 | |||
| 67 | serviceConfig = { | ||
| 68 | Type = "dbus"; | ||
| 69 | BusName = "org.freedesktop.IBus"; | ||
| 70 | ExecStart = "${ibusPackage}/bin/ibus-daemon --xim ${optionalString (cfg.panel != null) "--panel ${cfg.panel}"}"; | ||
| 71 | ExecReload = "${ibusPackage}/bin/ibus restart"; | ||
| 72 | ExecStop = "${ibusPackage}/bin/ibus exit"; | ||
| 73 | }; | ||
| 74 | }; | ||
| 75 | }; | ||
| 76 | |||
| 77 | # uses attributes of the linked package | ||
| 78 | meta.buildDocsInSandbox = false; | ||
| 79 | } | ||
diff --git a/modules/network-interfaces-systemd.nix b/modules/network-interfaces-systemd.nix index a3a49f5e..f62c6b86 100644 --- a/modules/network-interfaces-systemd.nix +++ b/modules/network-interfaces-systemd.nix | |||
| @@ -60,10 +60,8 @@ in | |||
| 60 | ++ optional (cfg.defaultGateway6 != null && (cfg.defaultGateway6.address or "") != "") cfg.defaultGateway6.address; | 60 | ++ optional (cfg.defaultGateway6 != null && (cfg.defaultGateway6.address or "") != "") cfg.defaultGateway6.address; |
| 61 | in optionalAttrs (gateway != [ ]) { | 61 | in optionalAttrs (gateway != [ ]) { |
| 62 | routes = override (map (gateway: { | 62 | routes = override (map (gateway: { |
| 63 | routeConfig = { | 63 | Gateway = gateway; |
| 64 | Gateway = gateway; | 64 | GatewayOnLink = false; |
| 65 | GatewayOnLink = false; | ||
| 66 | }; | ||
| 67 | }) gateway); | 65 | }) gateway); |
| 68 | } // optionalAttrs (domains != [ ]) { | 66 | } // optionalAttrs (domains != [ ]) { |
| 69 | domains = override domains; | 67 | domains = override domains; |
diff --git a/modules/yggdrasil-wg/default.nix b/modules/yggdrasil-wg/default.nix index 8525cea0..8b190651 100644 --- a/modules/yggdrasil-wg/default.nix +++ b/modules/yggdrasil-wg/default.nix | |||
| @@ -135,7 +135,7 @@ let | |||
| 135 | PrivateKeyFile = "/run/credentials/systemd-networkd.service/yggdrasil-wg-${family}.priv"; | 135 | PrivateKeyFile = "/run/credentials/systemd-networkd.service/yggdrasil-wg-${family}.priv"; |
| 136 | ListenPort = listenPort.${family}; | 136 | ListenPort = listenPort.${family}; |
| 137 | }; | 137 | }; |
| 138 | wireguardPeers = map (opts@{to, from, ...}: { wireguardPeerConfig = linkToPeer family opts; }) hostLinks.${family}; | 138 | wireguardPeers = map (opts@{to, from, ...}: linkToPeer family opts) hostLinks.${family}; |
| 139 | }; | 139 | }; |
| 140 | familyToLoadCred = family: "yggdrasil-wg-${family}.priv:${config.sops.secrets."yggdrasil-wg-${family}.priv".path}"; | 140 | familyToLoadCred = family: "yggdrasil-wg-${family}.priv:${config.sops.secrets."yggdrasil-wg-${family}.priv".path}"; |
| 141 | familyToYggdrasilNetwork = family: nameValuePair "yggdrasil-wg-${family}" { | 141 | familyToYggdrasilNetwork = family: nameValuePair "yggdrasil-wg-${family}" { |
| @@ -145,9 +145,7 @@ let | |||
| 145 | }; | 145 | }; |
| 146 | address = [wgHostIPs.${family}.${hostName}]; | 146 | address = [wgHostIPs.${family}.${hostName}]; |
| 147 | routes = [ | 147 | routes = [ |
| 148 | { routeConfig = { | 148 | { Destination = "${wgSubnet.${family}}::/${toString wgSubnetLength}"; |
| 149 | Destination = "${wgSubnet.${family}}::/${toString wgSubnetLength}"; | ||
| 150 | }; | ||
| 151 | } | 149 | } |
| 152 | ]; | 150 | ]; |
| 153 | linkConfig = { | 151 | linkConfig = { |
| @@ -203,25 +201,19 @@ in { | |||
| 203 | dns = ["2a03:4000:52:ada:1:1::"]; | 201 | dns = ["2a03:4000:52:ada:1:1::"]; |
| 204 | domains = ["yggdrasil"]; | 202 | domains = ["yggdrasil"]; |
| 205 | routes = [ | 203 | routes = [ |
| 206 | { routeConfig = { | 204 | { Destination = "${batSubnet}::/${toString batSubnetLength}"; |
| 207 | Destination = "${batSubnet}::/${toString batSubnetLength}"; | 205 | GatewayOnLink = true; |
| 208 | GatewayOnLink = true; | ||
| 209 | }; | ||
| 210 | } | 206 | } |
| 211 | { routeConfig = { | 207 | { Destination = "${batSubnet}::/${toString batSubnetLength}"; |
| 212 | Destination = "${batSubnet}::/${toString batSubnetLength}"; | 208 | GatewayOnLink = true; |
| 213 | GatewayOnLink = true; | 209 | Table = "yggdrasil"; |
| 214 | Table = "yggdrasil"; | ||
| 215 | }; | ||
| 216 | } | 210 | } |
| 217 | { routeConfig = { | 211 | { Destination = batHostIPs.${hostName}; |
| 218 | Destination = batHostIPs.${hostName}; | 212 | GatewayOnLink = true; |
| 219 | GatewayOnLink = true; | 213 | Table = "yggdrasil"; |
| 220 | Table = "yggdrasil"; | ||
| 221 | }; | ||
| 222 | } | 214 | } |
| 223 | ] ++ (concatMap (router: map (rAddr: { routeConfig = { Destination = "::/0"; Gateway = stripSubnet rAddr; GatewayOnLink = true; Table = "yggdrasil"; }; }) batHostIPs.${router}) (filter (router: router != hostName) routers)); | 215 | ] ++ (concatMap (router: map (rAddr: { Destination = "::/0"; Gateway = stripSubnet rAddr; GatewayOnLink = true; Table = "yggdrasil"; }) batHostIPs.${router}) (filter (router: router != hostName) routers)); |
| 224 | routingPolicyRules = map (addr: { routingPolicyRuleConfig = { Table = "yggdrasil"; From = addr; Priority = 1; }; }) batHostIPs.${hostName}; | 216 | routingPolicyRules = map (addr: { Table = "yggdrasil"; From = addr; Priority = 1; }) batHostIPs.${hostName}; |
| 225 | linkConfig = { | 217 | linkConfig = { |
| 226 | MACAddress = "${batHostMACs.${hostName}}"; | 218 | MACAddress = "${batHostMACs.${hostName}}"; |
| 227 | RequiredForOnline = false; | 219 | RequiredForOnline = false; |
