From 9bf71ca13a836429a3a9b810337a64312c77857e Mon Sep 17 00:00:00 2001 From: chayleaf Date: Fri, 4 Aug 2023 08:30:16 +0700 Subject: [PATCH] nix: 2.16->2.15; home/fish/atuin: remove up key binding nix-plugins built for a newer nix versions than pkgs.nix makes using pkgs.nix impossible, and overriding pkgs.nix globally breaks some derivations, so I have to do per-app overrides (couldn't find a way to revert it for a single app for some reason). This reverts a nix-plugins update to 2.16 so I can build it for 2.15 and escape the "symbol not found" hell. also override nixVersions.unstable to be 2.15 as well finally, use custom code for atuin integration because I hate the way it normally hijacks my up key --- flake.nix | 2 +- home/common/fish.nix | 31 ++++++++++++++++++++++++- home/common/general.nix | 1 + home/hosts/nixmsi.nix | 15 +++++-------- pkgs/default.nix | 32 ++++++++++++++++++++------ system/hosts/nixserver/default.nix | 2 -- system/hosts/nixserver/home.nix | 36 +++++++++++++++++++++++------- system/hosts/nixserver/matrix.nix | 2 +- 8 files changed, 92 insertions(+), 29 deletions(-) diff --git a/flake.nix b/flake.nix index 2439a86..4d387b3 100644 --- a/flake.nix +++ b/flake.nix @@ -266,7 +266,7 @@ packages = lib.genAttrs [ "x86_64-linux" "aarch64-linux" - ] (system: let self = overlay self (import nixpkgs { inherit system; }); in self ); + ] (system: let self = overlay ((mkPkgs { inherit system; }) // self) (import nixpkgs { inherit system; }); in self); nixosImages.router = let pkgs = mkPkgs { system = "aarch64-linux"; }; in { emmcImage = pkgs.callPackage ./system/hardware/bpi-r3/image.nix { inherit (nixosConfigurations.router-emmc) config; diff --git a/home/common/fish.nix b/home/common/fish.nix index f83fec0..40ee7cc 100644 --- a/home/common/fish.nix +++ b/home/common/fish.nix @@ -1,4 +1,6 @@ -{ pkgs, ... }: +{ pkgs +, config +, ... }: { programs.fish = @@ -19,6 +21,33 @@ source /etc/fish/config.fish ''; interactiveShellInit = '' + # ${config.programs.atuin.package}/bin/atuin init fish | source + set -gx ATUIN_SESSION (atuin uuid) + function _atuin_preexec --on-event fish_preexec + if not test -n "$fish_private_mode" + set -gx ATUIN_HISTORY_ID (atuin history start -- "$argv[1]") + end + end + function _atuin_postexec --on-event fish_postexec + set s $status + if test -n "$ATUIN_HISTORY_ID" + RUST_LOG=error atuin history end --exit $s -- $ATUIN_HISTORY_ID &>/dev/null & + disown + end + end + function _atuin_search + set h (RUST_LOG=error atuin search $argv -i -- (commandline -b) 3>&1 1>&2 2>&3) + commandline -f repaint + if test -n "$h" + commandline -r $h + end + end + + bind \cr _atuin_search + if bind -M insert > /dev/null 2>&1 + bind -M insert \cr _atuin_search + end + # ${pkgs.any-nix-shell}/bin/any-nix-shell fish | source function nix-shell diff --git a/home/common/general.nix b/home/common/general.nix index 63c596d..7896b0f 100644 --- a/home/common/general.nix +++ b/home/common/general.nix @@ -29,6 +29,7 @@ programs = { atuin = { enable = true; + enableFishIntegration = false; settings = { update_check = false; }; diff --git a/home/hosts/nixmsi.nix b/home/hosts/nixmsi.nix index 77f4e25..3debab1 100644 --- a/home/hosts/nixmsi.nix +++ b/home/hosts/nixmsi.nix @@ -63,7 +63,8 @@ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS = "-C link-arg=--ld-path=${pkgs.mold}/bin/mold"; }; home.packages = with pkgs; [ - mold + gimp krita blender-hip + kdenlive glaxnimate mediainfo ghidra cutter2 openrgb piper steam-run steam @@ -81,16 +82,12 @@ winetricks # protontricks # proton-caller # bottles - virtmanager - gimp krita blender-hip - tdesktop - clang_latest rustc rustfmt cargo clippy - kdenlive - mediainfo - glaxnimate + virtmanager looking-glass-client + clang_latest mold + rustc rustfmt cargo clippy lalrpop - looking-glass-client tio + tdesktop ]; xdg.configFile."looking-glass/client.ini".text = '' [app] diff --git a/pkgs/default.nix b/pkgs/default.nix index 40a1b18..80ea878 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -9,17 +9,38 @@ let sources = import ./_sources/generated.nix { inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools; }; + nixForNixPlugins = pkgs.nixVersions.nix_2_15; in { inherit (nix-gaming) faf-client osu-lazer-bin; - nixForNixPlugins = pkgs.nixVersions.nix_2_16; + inherit nixForNixPlugins; + nix-plugins = pkgs.nix-plugins.overrideAttrs (old: { + src = old.src.override { + rev = "8b9d06ef5b1b4f53cc99fcfde72bae75c7a7aa9c"; + hash = "sha256-7Lo+YxpiRz0+ZLFDvYMJWWK2j0CyPDRoP1wAc+OaPJY="; + }; + }); + nix = nixForNixPlugins; + nixVersions = pkgs.nixVersions.extend (self: super: { + stable = nixForNixPlugins; + unstable = nixForNixPlugins; + }); + /* Various patches to change Nix version of existing packages so they don't error out because of nix-plugins in nix.conf + hydra_unstable = pkgs.hydra_unstable.override { nix = nixForNixPlugins; }; + harmonia = pkgs.harmonia.override { nix = nixForNixPlugins; }; + nix-init = pkgs.nix-init.override { nix = nixForNixPlugins; }; + nix-serve = pkgs.nix-serve.override { nix = nixForNixPlugins; }; + nix-serve-ng = pkgs.nix-serve-ng.override { nix = nixForNixPlugins; }; + nurl = pkgs.nurl.override { nixVersions = builtins.mapAttrs (k: v: nixForNixPlugins) pkgs.nixVersions; }; + */ + clang-tools_latest = pkgs.clang-tools_16; clang_latest = pkgs.clang_16; - home-daemon = callPackage ./home-daemon { }; /*ghidra = pkgs.ghidra.overrideAttrs (old: { patches = old.patches ++ [ ./ghidra-stdcall.patch ]; });*/ + home-daemon = callPackage ./home-daemon { }; # pin version looking-glass-client = pkgs.looking-glass-client.overrideAttrs (old: { version = "B6"; @@ -43,13 +64,10 @@ in ''; }; rofi-steam-game-list = callPackage ./rofi-steam-game-list { }; - searxng = pkgs.searxng.overridePythonAttrs (old: { + searxng = pkgs'.python3.pkgs.toPythonModule (pkgs.searxng.overrideAttrs (old: { inherit (sources.searxng) src; version = "unstable-" + sources.searxng.date; - propagatedBuildInputs = old.propagatedBuildInputs ++ (with pkgs'.python3.pkgs; [ - pytomlpp - ]); - }); + })); # system76-scheduler = callPackage ./system76-scheduler.nix { }; techmino = callPackage ./techmino { }; diff --git a/system/hosts/nixserver/default.nix b/system/hosts/nixserver/default.nix index e80449f..9ab233d 100644 --- a/system/hosts/nixserver/default.nix +++ b/system/hosts/nixserver/default.nix @@ -133,8 +133,6 @@ in { enable_http2 = true; # See https://www.python-httpx.org/http2/ }; }; - # workaround for a bug, will probably get fixed upstream some day - services.uwsgi.instance.vassals.searx.pythonPackages = lib.mkForce (self: [ pkgs.searxng self.pytomlpp ]); services.nginx.virtualHosts."search.${cfg.domainName}" = let inherit (config.services.searx) settings; in { quic = true; diff --git a/system/hosts/nixserver/home.nix b/system/hosts/nixserver/home.nix index 38682f8..03d3cee 100644 --- a/system/hosts/nixserver/home.nix +++ b/system/hosts/nixserver/home.nix @@ -67,6 +67,9 @@ in { ${lib.optionalString (cfg.lanCidrV4 != "0.0.0.0/0") "allow ${cfg.lanCidrV4};"} ${lib.optionalString (cfg.lanCidrV6 != "::/0") "allow ${cfg.lanCidrV6};"} deny all; + proxy_read_timeout 300; + proxy_connect_timeout 300; + proxy_send_timeout 300; ''; locations."/".proxyPass = "http://${lib.quoteListenAddr config.services.hydra.listenHost}:${toString config.services.hydra.port}/"; locations."/static/".root = "${config.services.hydra.package}/libexec/hydra/root/"; @@ -75,13 +78,16 @@ in { services.nix-serve = { enable = true; - package = pkgs.nix-serve-ng.override { - nix = config.nix.package; - }; + package = pkgs.nix-serve-ng; bindAddress = "127.0.0.1"; secretKeyFile = "/secrets/cache-priv-key.pem"; }; - nix.settings.allowed-users = [ "nix-serve" "hydra" "hydra-www" ]; + /*services.harmonia = { + enable = true; + signKeyPath = "/secrets/cache-priv-key.pem"; + settings.bind = "[::1]:5000"; + };*/ + nix.settings.allowed-users = [ "nix-serve" "harmonia" "hydra" "hydra-www" ]; # only hydra has access to this file anyway nix.settings.extra-builtins-file = "/etc/nixos/private/extra-builtins.nix"; impermanence.directories = [ @@ -98,16 +104,30 @@ in { services.nginx.virtualHosts."binarycache.${cfg.domainName}" = { quic = true; enableACME = true; - addSSL = true; + forceSSL = true; basicAuthFile = "/secrets/home_password"; locations."/".proxyPass = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}"; + extraConfig = '' + proxy_read_timeout 300; + proxy_connect_timeout 300; + proxy_send_timeout 300; + ''; + # TODO: fix + # https://github.com/nix-community/harmonia/issues/120 + /*locations."/".proxyPass = "http://${config.services.harmonia.settings.bind or "[::1]:5000"}"; + locations."/".extraConfig = '' + proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + '';*/ + # zstd on; + # zstd_types application/x-nix-archive; }; services.hydra = { enable = true; - package = pkgs.hydra_unstable.override { - nix = config.nix.package; - }; hydraURL = "home.${cfg.domainName}/hydra"; listenHost = "127.0.0.1"; minimumDiskFree = 30; diff --git a/system/hosts/nixserver/matrix.nix b/system/hosts/nixserver/matrix.nix index e7c6410..3ebc060 100644 --- a/system/hosts/nixserver/matrix.nix +++ b/system/hosts/nixserver/matrix.nix @@ -26,7 +26,7 @@ in { imports = [ ./maubot.nix ]; networking.firewall.allowedTCPPorts = [ 8008 8448 ]; - systemd.services.matrix-synapse.serviceConfig.TimeoutStartSec = 180; + systemd.services.matrix-synapse.serviceConfig.TimeoutStartSec = 900; services.nginx.virtualHosts."${cfg.domainName}" = { locations."= /.well-known/matrix/server".extraConfig = matrixServerConfigResponse;