diff options
| -rw-r--r-- | lib/default.nix | 26 | ||||
| -rw-r--r-- | lib/haskell.nix | 7 | ||||
| -rw-r--r-- | lib/types.nix | 19 | ||||
| -rw-r--r-- | tv/1systems/xu/config.nix | 1 | ||||
| -rw-r--r-- | tv/2configs/autotether.nix | 19 | ||||
| -rw-r--r-- | tv/2configs/retiolum.nix | 10 | ||||
| -rw-r--r-- | tv/3modules/ejabberd/default.nix | 2 | ||||
| -rw-r--r-- | tv/3modules/x0vncserver.nix | 2 | ||||
| -rw-r--r-- | tv/5pkgs/simple/alacritty-tv.nix | 3 | 
9 files changed, 81 insertions, 8 deletions
diff --git a/lib/default.nix b/lib/default.nix index 149b97a..280f042 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -39,6 +39,8 @@ let      ne = x: y: x != y;      mod = x: y: x - y * (x / y); +    on = b: u: x: y: b (u x) (u y); +      genid = lib.genid_uint32; # TODO remove      genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2;      genid_uint32 = import ./genid.nix { inherit lib; }; @@ -185,6 +187,30 @@ let      in        filter (x: x != []) ([acc.chunk] ++ acc.chunks); +    # Filter adjacent duplicate elements. +    uniq = uniqBy eq; + +    # Filter adjacent duplicate elements determined via the given function. +    uniqBy = cmp: let +      f = a: s: +        if length s == 0 then +          [] +        else let +          b = head s; +        in +          if cmp a b then +            f b (tail s) +          else +            [b] ++ f b (tail s); +    in +      s: +        if length s == 0 then +          [] +        else let +          b = head s; +        in +          [b] ++ f b (tail s); +      warnOldVersion = oldName: newName:        if compareVersions oldName newName != -1 then          trace "Upstream `${oldName}' gets overridden by `${newName}'." newName diff --git a/lib/haskell.nix b/lib/haskell.nix index 4f0ee05..f87cfa7 100644 --- a/lib/haskell.nix +++ b/lib/haskell.nix @@ -39,7 +39,12 @@ rec {          in          if parse == null then            (pkgs.writeText name s).overrideAttrs (old: { -            dependencies = old.dependencies or [] ++ dependencies; +            dependencies = +              lib.uniq +                (lib.sort (lib.on lib.lessThan (lib.getAttr "name")) +                  (filter +                    (lib.ne null) +                    (old.dependencies or [] ++ dependencies)));            })          else diff --git a/lib/types.nix b/lib/types.nix index 67a0c6f..32b4541 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -18,9 +18,6 @@ rec {          type = label;          default = config._module.args.name;        }; -      cores = mkOption { -        type = uint; -      };        nets = mkOption {          type = attrsOf net;          default = {}; @@ -149,6 +146,14 @@ rec {              }.${config._module.args.name} or {                default = "${ip4.config.addr}/32";              }); +            prefixLength = mkOption ({ +              type = uint; +            } // { +              retiolum.default = 16; +              wiregrill.default = 16; +            }.${config._module.args.name} or { +              default = 32; +            });            };          }));          default = null; @@ -168,6 +173,14 @@ rec {              }.${config._module.args.name} or {                default = "${ip6.config.addr}/128";              }); +            prefixLength = mkOption ({ +              type = uint; +            } // { +              retiolum.default = 32; +              wiregrill.default = 32; +            }.${config._module.args.name} or { +              default = 128; +            });            };          }));          default = null; diff --git a/tv/1systems/xu/config.nix b/tv/1systems/xu/config.nix index 6ca62ac..b83d01f 100644 --- a/tv/1systems/xu/config.nix +++ b/tv/1systems/xu/config.nix @@ -4,6 +4,7 @@ with import ./lib;    imports = [      <stockholm/tv> +    ../../2configs/autotether.nix      <stockholm/tv/2configs/hw/x220.nix>      <stockholm/tv/2configs/exim-retiolum.nix>      <stockholm/tv/2configs/gitconfig.nix> diff --git a/tv/2configs/autotether.nix b/tv/2configs/autotether.nix new file mode 100644 index 0000000..43b5575 --- /dev/null +++ b/tv/2configs/autotether.nix @@ -0,0 +1,19 @@ +{ config, pkgs, ... }: let +  cfg.serial = "17e064850405"; +in { +  systemd.services.usb_tether.serviceConfig = { +    SyslogIdentifier = "usb_tether"; +    ExecStartPre = "${pkgs.android-tools}/bin/adb -s ${cfg.serial} wait-for-device"; +    ExecStart = "${pkgs.android-tools}/bin/adb -s ${cfg.serial} shell svc usb setFunctions rndis"; +  }; +  services.udev.extraRules = /* sh */ '' +    ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb*", NAME="android" + +    ACTION=="add", SUBSYSTEM=="usb", ATTR{serial}=="${cfg.serial}", \ +    TAG+="systemd", ENV{SYSTEMD_WANTS}="usb_tether.service" +  ''; +  systemd.network.networks.android = { +    matchConfig.Name = "android"; +    DHCP = "yes"; +  }; +} diff --git a/tv/2configs/retiolum.nix b/tv/2configs/retiolum.nix index de77de3..1b176e0 100644 --- a/tv/2configs/retiolum.nix +++ b/tv/2configs/retiolum.nix @@ -11,6 +11,16 @@ with import ./lib;        LocalDiscovery = yes      '';      tincPackage = pkgs.tinc_pre; +    tincUp = lib.mkIf config.systemd.network.enable ""; +  }; +  systemd.network.networks.retiolum = { +    matchConfig.Name = "retiolum"; +    address = let +      inherit (config.krebs.build.host.nets.retiolum) ip4 ip6; +    in [ +      "${ip4.addr}/${toString ip4.prefixLength}" +      "${ip6.addr}/${toString ip6.prefixLength}" +    ];    };    tv.iptables.input-internet-accept-tcp = singleton "tinc";    tv.iptables.input-internet-accept-udp = singleton "tinc"; diff --git a/tv/3modules/ejabberd/default.nix b/tv/3modules/ejabberd/default.nix index e3a41a5..71a1a59 100644 --- a/tv/3modules/ejabberd/default.nix +++ b/tv/3modules/ejabberd/default.nix @@ -127,7 +127,7 @@ in {        })      ]; -    krebs.systemd.services.ejabberd = {}; +    krebs.systemd.services.ejabberd.restartIfCredentialsChange = true;      systemd.services.ejabberd = {        wantedBy = [ "multi-user.target" ]; diff --git a/tv/3modules/x0vncserver.nix b/tv/3modules/x0vncserver.nix index f19bfeb..eb9b1ae 100644 --- a/tv/3modules/x0vncserver.nix +++ b/tv/3modules/x0vncserver.nix @@ -26,7 +26,7 @@ in {      };    };    config = mkIf cfg.enable { -    krebs.systemd.services.x0vncserver = {}; +    krebs.systemd.services.x0vncserver.restartIfCredentialsChange = true;      systemd.services.x0vncserver = {        after = [ "graphical.target" ];        requires = [ "graphical.target" ]; diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index 466ff27..d80c46c 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -70,8 +70,7 @@ pkgs.symlinkJoin {        # Install stored configuration if it has changed.        # This allows for both declarative updates and runtime modifications.        ${pkgs.coreutils}/bin/mkdir -p "$HOME" -      ref=$(${pkgs.coreutils}/bin/cat "$HOME"/ref) -      if test "$ref" != ${config-file}; then +      if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then          echo ${config-file} > "$HOME"/ref          ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml        fi  | 
