diff --git a/.github/workflows/nodes.yml b/.github/workflows/nodes.yml index 40ada168..d1b565f1 100644 --- a/.github/workflows/nodes.yml +++ b/.github/workflows/nodes.yml @@ -3,6 +3,68 @@ env: CI_CONFIG: ./ci/nodes.nix CI_PLATFORM: gh-actions jobs: + chen: + name: nodes-chen + runs-on: ubuntu-latest + steps: + - id: checkout + name: git clone + uses: actions/checkout@v1 + with: + submodules: false + - id: nix-install + name: nix install + uses: arcnmx/ci/actions/nix/install@master + - id: ci-setup + name: nix setup + uses: arcnmx/ci/actions/nix/run@master + with: + attrs: ci.job.chen.run.bootstrap + quiet: false + - id: architectures + name: prepare for emulated builds + run: 'sudo $(which archbinfmt) + + ' + - id: ci-dirty + name: nix test dirty + uses: arcnmx/ci/actions/nix/run@master + with: + attrs: ci.job.chen.run.test + command: ci-build-dirty + quiet: false + stdout: ${{ runner.temp }}/ci.build.dirty + - id: ci-test + name: nix test build + uses: arcnmx/ci/actions/nix/run@master + with: + attrs: ci.job.chen.run.test + command: ci-build-realise + ignore-exit-code: true + quiet: false + stdin: ${{ runner.temp }}/ci.build.dirty + - env: + CI_EXIT_CODE: ${{ steps.ci-test.outputs.exit-code }} + id: ci-summary + name: nix test results + uses: arcnmx/ci/actions/nix/run@master + with: + attrs: ci.job.chen.run.test + command: ci-build-summarise + quiet: false + stdin: ${{ runner.temp }}/ci.build.dirty + stdout: ${{ runner.temp }}/ci.build.cache + - env: + CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} + id: ci-cache + if: always() + name: nix test cache + uses: arcnmx/ci/actions/nix/run@master + with: + attrs: ci.job.chen.run.test + command: ci-build-cache + quiet: false + stdin: ${{ runner.temp }}/ci.build.cache ci-check: name: nodes check runs-on: ubuntu-latest diff --git a/config/hosts/chen.nix b/config/hosts/chen.nix new file mode 100644 index 00000000..5db48fbf --- /dev/null +++ b/config/hosts/chen.nix @@ -0,0 +1,99 @@ +{ meta, config, pkgs, lib, ... }: + +with lib; + +{ + # Imports + + imports = with meta; [ + profiles.hardware.eeepc-1015pem + profiles.network + services.kattv2 + services.dnscrypt-proxy + ]; + + # Terraform + + deploy.tf = { + resources.chen = { + provider = "null"; + type = "resource"; + connection = { + port = head config.services.openssh.ports; + host = config.network.addresses.private.nixos.ipv4.address; + }; + }; + }; + + # File Systems and Swap + + fileSystems."/" = + { device = "/dev/disk/by-uuid/fa06ba90-ffc9-4ca6-b1cf-1205340a975e"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/BF39-2AA3"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/9c88235e-9705-4b80-a988-e95eda06124f"; } + ]; + + # Bootloader + + boot = { + initrd = { + availableKernelModules = [ "xhci_pci" "usb_storage" "sd_mod" "sdhci_acpi" ]; + }; + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + }; + + # Hardware + + services.logind.lidSwitchExternalPower = "ignore"; + + # Networking + + networking = { + hostId = "9f89b327"; + useDHCP = false; + wireless = { + enable = false; + userControlled.enable = false; + interfaces = singleton "wlp1s0"; + }; + interfaces.enp0s20u2c2.ipv4.addresses = singleton { + inherit (config.network.addresses.private.nixos.ipv4) address; + prefixLength = 24; + }; + defaultGateway = config.network.privateGateway; + }; + + network = { + addresses = { + private = { + enable = true; + nixos = { + ipv4.address = "192.168.1.34"; + }; + }; + }; + }; + + # Firewall + + network.firewall = { + public = { + interfaces = singleton "enp0s20u2c2"; + }; + }; + + # State + + system.stateVersion = "20.09"; +} diff --git a/config/hosts/goliath.nix b/config/hosts/goliath.nix index 5b947804..f1a91b7b 100644 --- a/config/hosts/goliath.nix +++ b/config/hosts/goliath.nix @@ -108,6 +108,7 @@ ".local/share/task" ".local/share/dino" ".local/share/weechat" + ".local/share/TelegramDesktop" ".local/share/Mumble" ".local/share/direnv" ".config/Mumble" diff --git a/config/hosts/yukari.nix b/config/hosts/yukari.nix index bbf4d0c7..11028442 100644 --- a/config/hosts/yukari.nix +++ b/config/hosts/yukari.nix @@ -4,9 +4,9 @@ profiles.network profiles.gui users.kat.guiFull - services.fusionpbx services.jellyfin services.kattv-ingest + services.kattv2-ingest services.postgres services.nfs services.nginx diff --git a/config/services/kattv2-ingest.nix b/config/services/kattv2-ingest.nix new file mode 100644 index 00000000..be3e5975 --- /dev/null +++ b/config/services/kattv2-ingest.nix @@ -0,0 +1,124 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + env = { + FREI0R_PATH = "${pkgs.frei0r}/lib/frei0r-1"; + GST_PLUGIN_SYSTEM_PATH_1_0 = with pkgs.gst_all_1; lib.makeSearchPath "lib/gstreamer-1.0" [ + gstreamer + gst-plugins-base + gst-plugins-good + gst-plugins-bad + gst-plugins-ugly + ]; + }; + queue_frame = { + element."queue" = { + leaky = "downstream"; + flush-on-eos = true; + max-size-buffers = 3; + }; + }; + queue_data = { + element.queue = { + leaky = "downstream"; + }; + }; + videoconvert_cpu = { + element.videoconvert = { + n-threads = 4; + dither = 0; + chroma-resampler = 0; + chroma-mode = 3; + }; + }; + videoconvert_gpu = [ + "glupload" + "glcolorconvert" + "gldownload" + ]; + encodeopts = { + speed-preset = "ultrafast"; + tune = "zerolatency"; + pass = "qual"; + #psy-tune = "film"; + #noise-reduction=0; + quantizer = 27; + bitrate = 8192; + rc-lookahead = 6; + }; + denoise = { + element.frei0r-filter-hqdn3d = { + spatial = 0.175; #0.325; + temporal = 0.06; #0.11; + }; + }; + encode_high = [ + { + element.x264enc = { + key-int-max = 150; + } // encodeopts; + } + { + caps."video/x-h264" = { + profile = "high"; + }; + } + "h264parse" + ]; + rtmpsink = [ + queue_data + "flvmux" + { + element.rtmp2sink = { + location = "rtmp://localhost:1935/stream/kattv2"; + }; + } + ]; + pipeline = [ + { + element.fdsrc = { + fd = 3; + }; + } + "matroskademux" + "jpegdec" + queue_frame + + videoconvert_cpu + denoise + + videoconvert_cpu + encode_high + + rtmpsink + ]; +in +{ + network.firewall = { + private.tcp.ports = singleton 1935; + public.tcp.ports = [ 4954 1935 ]; + }; + + systemd.sockets.kattv2 = { + wantedBy = [ "sockets.target" ]; + listenStreams = [ "0.0.0.0:4954" ]; + socketConfig = { + Accept = true; + Backlog = 0; + MaxConnections = 1; + }; + }; + + systemd.services."kattv2@" = { + environment = env; + script = "exec ${pkgs.gst_all_1.gstreamer.dev}/bin/gst-launch-1.0 -e --no-position ${pkgs.lib.gst.pipelineShellString pipeline}"; + after = [ "nginx.service" ]; + description = "RTMP stream of kat cam"; + serviceConfig = { + Restart = "on-failure"; + RestartSec = "10s"; + }; + }; +} diff --git a/config/services/kattv2.nix b/config/services/kattv2.nix new file mode 100644 index 00000000..f956ac1c --- /dev/null +++ b/config/services/kattv2.nix @@ -0,0 +1,62 @@ +{ meta, config, pkgs, lib, ... }: + +let + env = { + FREI0R_PATH = "${pkgs.frei0r}/lib/frei0r-1"; + GST_PLUGIN_SYSTEM_PATH_1_0 = with pkgs.gst_all_1; lib.makeSearchPath "lib/gstreamer-1.0" [ + gstreamer + gst-plugins-base + gst-plugins-good + gst-plugins-bad + gst-plugins-ugly + pkgs.gst-jpegtrunc + ]; + }; + cameracapture = { + element."v4l2src" = { + device = "/dev/videomew"; + saturation = 100; + brightness = 100; + extra-controls = "c,exposure_auto=3"; + }; + }; + v4l2src = [ + cameracapture + { + caps."image/jpeg" = { + width = 1280; + height = 720; + framerate = "30/1"; # "10/1" + }; + } + ]; + pipeline = v4l2src ++ [ + "jpegtrunc" + { element.matroskamux.streamable = true; } + { + element.tcpclientsink = { + host = meta.network.nodes.yukari.network.addresses.private.nixos.ipv4.address; + port = "4954"; + sync = false; + }; + } + ]; +in +{ + services.udev.extraRules = '' + KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", SUBSYSTEMS=="usb", ATTR{index}=="0", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="075d", SYMLINK+="videomew", TAG+="systemd" + ''; + + systemd.services.kattv = { + wantedBy = [ "dev-videomew.device" "multi-user.target" ]; + after = [ "dev-videomew.device" "nginx.service" ]; + description = "RTMP stream of kat cam"; + bindsTo = [ "dev-videomew.device" ]; + environment = env; + script = "exec ${pkgs.gst_all_1.gstreamer.dev}/bin/gst-launch-1.0 -e --no-position ${pkgs.lib.gst.pipelineShellString pipeline}"; + serviceConfig = { + Restart = "on-failure"; + RestartSec = "10s"; + }; + }; +} diff --git a/config/users/kat/dev/emacs.nix b/config/users/kat/dev/emacs.nix index 86a627ea..5b3923e0 100644 --- a/config/users/kat/dev/emacs.nix +++ b/config/users/kat/dev/emacs.nix @@ -15,7 +15,7 @@ let }; }; in -optionalAttrs (builtins.getEnv "CI_PLATFORM" == "impure") { +optionalAttrs (builtins.getEnv "CI_PLATFORM" == "impure" && "mew" != "mew") { home.packages = [ doom-emacs pkgs.sqlite ]; home.file.".emacs.d/init.el".text = '' diff --git a/config/users/kat/gui/packages.nix b/config/users/kat/gui/packages.nix index 4b090649..ad7d30be 100644 --- a/config/users/kat/gui/packages.nix +++ b/config/users/kat/gui/packages.nix @@ -12,6 +12,7 @@ thunderbird mumble-develop dino-omemo + tdesktop transmission-remote-gtk scrcpy lm_sensors diff --git a/nix/sources.json b/nix/sources.json index 6a9ee053..b83c8e67 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -17,10 +17,10 @@ "homepage": null, "owner": "arcnmx", "repo": "nixexprs", - "rev": "d5db6849309f4df2f94e53a4a4849f3a28c2b4d7", - "sha256": "0lrfbnrwwxfwzykmb6m0qghwrxhkjvj5xvkk4aq4rjw847h65x2a", + "rev": "c0db6a48e8832e8861c4e47b583266d63e67e5ea", + "sha256": "1k3kp6r61r0xz997n27zb6cslffwcm47fgi241608zklpjrdafhn", "type": "tarball", - "url": "https://github.com/arcnmx/nixexprs/archive/d5db6849309f4df2f94e53a4a4849f3a28c2b4d7.tar.gz", + "url": "https://github.com/arcnmx/nixexprs/archive/c0db6a48e8832e8861c4e47b583266d63e67e5ea.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "ci": { @@ -29,10 +29,10 @@ "homepage": "https://arcnmx.github.io/ci", "owner": "arcnmx", "repo": "ci", - "rev": "931dc1fd77ebf09dd8d5ee2a6b92762a823e129f", - "sha256": "1w59hdsyv1zi49dgi853bn90qwailzywmrrj54k3wm8lcn22prxk", + "rev": "215a89f353c2f1fe767d97a99c09a0e46a21edda", + "sha256": "12s2iyfmnr9sd31n8xyglqybn5s9808r7n4k8v7nkk7rgh594jz9", "type": "tarball", - "url": "https://github.com/arcnmx/ci/archive/931dc1fd77ebf09dd8d5ee2a6b92762a823e129f.tar.gz", + "url": "https://github.com/arcnmx/ci/archive/215a89f353c2f1fe767d97a99c09a0e46a21edda.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "emacs-overlay": { @@ -41,10 +41,10 @@ "homepage": "", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "aa581fc7bce89b3abc60124de8dcc3b7c7a9277c", - "sha256": "160v5hsswcvyai1hc6r0gs00z9gm30qgqlgy0sk1x8iwcqslx3wz", + "rev": "4ce4c7f01e4d8d481564457c881263cc0cf38805", + "sha256": "0csm5nhcnghdx5vbb0f470012z2z8a5n2zg3pkx0p1ikqpai34cf", "type": "tarball", - "url": "https://github.com/nix-community/emacs-overlay/archive/aa581fc7bce89b3abc60124de8dcc3b7c7a9277c.tar.gz", + "url": "https://github.com/nix-community/emacs-overlay/archive/4ce4c7f01e4d8d481564457c881263cc0cf38805.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "hexchen": { @@ -65,10 +65,10 @@ "homepage": "https://nix-community.github.io/home-manager/", "owner": "nix-community", "repo": "home-manager", - "rev": "309808afbc2a07e340067f66029a4202b4c4b959", - "sha256": "0gwk6xgfajw31v3q2hzzr34yizssc75r87jg4vyvx0amdk4isbdm", + "rev": "70c5b268e10025c70823767f4fb49e240b40151d", + "sha256": "09si7wq89qpyzfxgs1862s7lv8sl0ikwx7cy9vavf1hd5y6m13s4", "type": "tarball", - "url": "https://github.com/nix-community/home-manager/archive/309808afbc2a07e340067f66029a4202b4c4b959.tar.gz", + "url": "https://github.com/nix-community/home-manager/archive/70c5b268e10025c70823767f4fb49e240b40151d.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "impermanence": { @@ -77,10 +77,10 @@ "homepage": "", "owner": "nix-community", "repo": "impermanence", - "rev": "58558845bc68dcf2bb32caa80564f7fe3f6cbc61", - "sha256": "10z3g4knkvq838zbfq71pkfyl8cffrpavna448wf5mjscycp0gnv", + "rev": "ce77ed9bd069e57a7a688d360196e576ca63a842", + "sha256": "1snlcs99vfz3di3vxj1lxnjsl82aimcyv1irs029gzwrsxzpq9gj", "type": "tarball", - "url": "https://github.com/nix-community/impermanence/archive/58558845bc68dcf2bb32caa80564f7fe3f6cbc61.tar.gz", + "url": "https://github.com/nix-community/impermanence/archive/ce77ed9bd069e57a7a688d360196e576ca63a842.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "katexprs": { @@ -89,10 +89,10 @@ "homepage": null, "owner": "kittywitch", "repo": "nixexprs", - "rev": "33418f835c61697569feb9d8753134f7c4143d5a", - "sha256": "023wma4xv5pshjfdvv9r67nbzwryh0m38vprnnf7ikl1g29a53wi", + "rev": "65c3e43c7da5bd6d389a3edfc73b5295a815e8f8", + "sha256": "14qpsrlkxnsmm0ssz9k2qwp4h4fxa4wjxkc9mmmkxrai84b1n6mv", "type": "tarball", - "url": "https://github.com/kittywitch/nixexprs/archive/33418f835c61697569feb9d8753134f7c4143d5a.tar.gz", + "url": "https://github.com/kittywitch/nixexprs/archive/65c3e43c7da5bd6d389a3edfc73b5295a815e8f8.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { @@ -113,10 +113,10 @@ "homepage": "", "owner": "kirelagin", "repo": "nix-dns", - "rev": "d47378a4272ca826d770bb22242e5fbb814063b5", - "sha256": "19jb4xgi7v1hp5q2cs0v76n316imis1ijd6ag4v8ikgysmrnkliy", + "rev": "c7b9645da9c0ddce4f9de4ef27ec01bb8108039a", + "sha256": "1b95dh15zl0qaf9fvvvvqlambm3plndpy24wwlib0sy4d0zq6y0h", "type": "tarball", - "url": "https://github.com/kirelagin/nix-dns/archive/d47378a4272ca826d770bb22242e5fbb814063b5.tar.gz", + "url": "https://github.com/kirelagin/nix-dns/archive/c7b9645da9c0ddce4f9de4ef27ec01bb8108039a.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nix-doom-emacs": { @@ -147,10 +147,10 @@ "homepage": "", "owner": "nixos", "repo": "nixpkgs", - "rev": "2cf9db0e3d45b9d00f16f2836cb1297bcadc475e", - "sha256": "0sij1a5hlbigwcgx10dkw6mdbjva40wzz4scn0wchv7yyi9ph48l", + "rev": "b67e752c29f18a0ca5534a07661366d6a2c2e649", + "sha256": "1n47f7r8cm9pcsz7vl4nxjfvs0fgzvcmjda5h0inz3yx9vghp5xm", "type": "tarball", - "url": "https://github.com/nixos/nixpkgs/archive/2cf9db0e3d45b9d00f16f2836cb1297bcadc475e.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/b67e752c29f18a0ca5534a07661366d6a2c2e649.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nur": { @@ -159,10 +159,10 @@ "homepage": "https://nur.nix-community.org/", "owner": "nix-community", "repo": "NUR", - "rev": "06aecedb3f99c7252e6054d22f30558ab3873657", - "sha256": "072n6axsz17plkkpb0m43xhsr47xcdsghn98n7n55dpmya2h9j5j", + "rev": "041951902d612ce0e0c5a217df529fb05e555ca2", + "sha256": "0vmd0zh8jh5r9csphs60mpjv8afa2bjv0z1sy5qnavnwdns7icd6", "type": "tarball", - "url": "https://github.com/nix-community/NUR/archive/06aecedb3f99c7252e6054d22f30558ab3873657.tar.gz", + "url": "https://github.com/nix-community/NUR/archive/041951902d612ce0e0c5a217df529fb05e555ca2.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "tf-nix": { diff --git a/overlays/exprs b/overlays/exprs index fc6a3439..65c3e43c 160000 --- a/overlays/exprs +++ b/overlays/exprs @@ -1 +1 @@ -Subproject commit fc6a343976f4afa61850484ac2ace2202f7b9576 +Subproject commit 65c3e43c7da5bd6d389a3edfc73b5295a815e8f8