liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

configuration.nix (1589B)


      1 { config, pkgs, lib, ... } :
      2 let
      3   inherit (pkgs.liminix.networking) interface address route;
      4   inherit (pkgs.liminix.services) oneshot longrun bundle target output;
      5 in rec {
      6   services.lan4 =
      7     let iface = interface { type = "hardware"; device = "eth1";};
      8     in address iface { family = "inet4"; address ="192.168.19.1"; prefixLength = 24;};
      9 
     10   imports = [
     11     ../../modules/ppp
     12     ../../modules/dnsmasq
     13   ];
     14 
     15   services.pppoe =
     16     config.system.service.pppoe {
     17       interface = interface { type = "hardware"; device = "eth0"; };
     18       ppp-options = [
     19         "debug" "+ipv6" "noauth"
     20         "name" "db123@a.1"
     21         "password" "NotReallyTheSecret"
     22       ];
     23     };
     24 
     25   services.defaultroute4 = route {
     26     name = "defaultroute";
     27     via = "$(output ${services.pppoe} address)";
     28     target = "default";
     29     dependencies = [ services.pppoe ];
     30   };
     31 
     32   services.packet_forwarding =
     33     let
     34       iface = services.pppoe;
     35       filename = "/proc/sys/net/ipv4/conf/$(output ${iface} ifname)/forwarding";
     36     in oneshot {
     37       name = "let-the-ip-flow";
     38       up = "echo 1 > ${filename}";
     39       down = "echo 0 > ${filename}";
     40       dependencies = [iface];
     41     };
     42 
     43   services.dns =
     44     config.system.service.dnsmasq.build {
     45       interface = services.lan4;
     46       ranges = ["192.168.19.10,192.168.19.253"];
     47       domain = "fake.liminix.org";
     48     };
     49 
     50   services.default = target {
     51     name = "default";
     52     contents = with services; [
     53       config.hardware.networkInterfaces.lo
     54       defaultroute4
     55       packet_forwarding
     56       dns
     57     ];
     58   };
     59   defaultProfile.packages = [ pkgs.hello ] ;
     60 }