From 2885b83f7011bd3dab40b036fe743338152c91bd Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt <pbsds@hotmail.com> Date: Wed, 9 Apr 2025 13:14:23 +0200 Subject: [PATCH] lkjdsalkjdsalkj --- .envrc | 26 ++++++++++++++----- base.nix | 4 +-- hardware/gpu/cuda.nix | 2 +- lib.nix | 13 +++++----- profiles/http/default.nix | 10 ++++--- profiles/http/docs/home-manager.nix | 2 +- profiles/http/docs/nixpkgs.nix | 2 +- .../home/profiles/bashrc.d/zeditor-remote.sh | 4 ++- users/pbsds/home/profiles/shell.nix | 9 ++++++- users/pbsds/home/profiles/ssh.nix | 1 + 10 files changed, 49 insertions(+), 24 deletions(-) diff --git a/.envrc b/.envrc index 39a6c78..fd60930 100644 --- a/.envrc +++ b/.envrc @@ -19,7 +19,6 @@ elif command -v find >/dev/null; then fi if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then tmp=$(mktemp -p .direnv/tmp -d) - trap 'rm -rf "$tmp" >&/dev/null' ERR EXIT RETURN if ! git diff --exit-code --quiet HEAD -- flake.lock >&/dev/null; then cp flake.lock "$tmp"/dirty-flake.lock git reset -- flake.lock @@ -28,18 +27,31 @@ if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then fi git pull --rebase --autostash if grep -q "^=======" flake.lock; then - # TODO: can this happen anymore? + # Can this happen anymore? Yes, if i forgot to push git reset -- flake.lock - rm flake.lock # restore? + rm flake.lock # git restore? git checkout -- flake.lock elif [[ -s "$tmp"/clean-flake.lock ]] && ! diff -q "$tmp"/clean-flake.lock flake.lock >&/dev/null; then cp "$tmp"/flake-dirty.lock flake.lock fi + direnv allow # :3 + # nix flake update - nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json \ - | jq .[] -r \ - | grep -v '^nixpkgs-expensive$' \ - | nix flake update # --output-lock-file "$tmp"/new-flake.lock + declare -a update_args=() + readarray -td $'\n' update_args < <( + nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json \ + | jq .[] -r \ + | grep -v '^nixpkgs-expensive$' + ) + # update_args+=(--output-lock-file "$tmp"/new-flake.lock) + if command -v pueue >/dev/null && pueue status >&/dev/null; then + nix flake update "${update_args[@]}" + else + echo >&2 "+ pueue add nix flake update ..." + pueue add --escape --immediate nix flake update "${update_args[@]}" + fi + unset update_args + printf "%s\n" "$now" > .direnv/pull-date fi diff --git a/base.nix b/base.nix index d15a1c3..0cb0758 100644 --- a/base.nix +++ b/base.nix @@ -54,7 +54,7 @@ smartmontools testdisk usbutils - ] ++ lib.optionals (builtins.elem config.nixpkgs.system [ "x86_64-linux" "aarch64_linux"]) [ + ] ++ lib.optionals (builtins.elem pkgs.stdenv.hostPlatform [ "x86_64-linux" "aarch64_linux"]) [ cage weston ]; @@ -119,7 +119,7 @@ security.sudo.execWheelOnly = true; services.thermald.enable = lib.all (x: x) [ - (config.nixpkgs.system == "x86_64-linux") + (pkgs.stdenv.hostPlatform.system == "x86_64-linux") (!config.boot.isContainer or false) ]; diff --git a/hardware/gpu/cuda.nix b/hardware/gpu/cuda.nix index e29dd94..d451959 100644 --- a/hardware/gpu/cuda.nix +++ b/hardware/gpu/cuda.nix @@ -42,7 +42,7 @@ lib.mkMerge [ programs.nix-required-mounts.enable = true; programs.nix-required-mounts.presets.nvidia-gpu.enable = true; # adding "cuda", "opengl" and "nvidia-gpu" ^ overrides the implicit defaults - nix.settings.system-features = lib.mkIf (config.nixpkgs.system == "x86_64-linux") ["kvm" "nixos-test"]; + nix.settings.system-features = lib.mkIf (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ["kvm" "nixos-test"]; }) { diff --git a/lib.nix b/lib.nix index 77aea63..a3e265c 100644 --- a/lib.nix +++ b/lib.nix @@ -17,17 +17,18 @@ let nixosSystem: let cfg = nixosSystem.config; - inherit (nixosSystem.pkgs) lib; + inherit (nixosSystem) pkgs; + inherit (pkgs) lib; in { - # inherit cfg.nixpkgs.system; # TODO: cross systems system = - if cfg.nixpkgs.hostPlatform.system == cfg.nixpkgs.buildPlatform.system then - cfg.nixpkgs.system + if pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system then + pkgs.stdenv.hostPlatform.system else { - hostPlatform = cfg.nixpkgs.hostPlatform.system; - buildPlatform = cfg.nixpkgs.buildPlatform.system; + # inherit (pkgs.stdenv) hostPlatform buildPlatform; + hostPlatform = pkgs.stdenv.hostPlatform.system; + buildPlatform = pkgs.stdenv.buildPlatform.system; }; inherit (cfg.boot.binfmt) emulatedSystems; inherit (cfg.networking) hostName fqdn search; diff --git a/profiles/http/default.nix b/profiles/http/default.nix index 39c5767..0eb4d6b 100644 --- a/profiles/http/default.nix +++ b/profiles/http/default.nix @@ -10,10 +10,11 @@ in options.pbsds.nginx.allSubdomains = lib.mkOption { visible = false; internal = true; readOnly = true; default = lib.pipe config.services.nginx.virtualHosts [ - #(lib.mapAttrsToList (domain: vhost: [ domain ] ++ vhost.serverAliases)) - (lib.mapAttrsToList (domain: vhost: [ domain ])) - lib.flatten - (builtins.filter (domain: domain != "" && domain != "_")) + # #(lib.mapAttrsToList (domain: vhost: [ domain ] ++ vhost.serverAliases)) + # (lib.mapAttrsToList (domain: vhost: [ domain ])) + # lib.flatten + lib.attrNames + (lib.filter (domain: domain != "" && domain != "_")) (lib.sort (x: y: x<y)) ]; }; @@ -78,6 +79,7 @@ in # nginx return 444 for all nonexistent virtualhosts services.nginx.virtualHosts."_" = { + default = true; addSSL = true; sslCertificate = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.cert.pem"; sslCertificateKey = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.key.pem"; diff --git a/profiles/http/docs/home-manager.nix b/profiles/http/docs/home-manager.nix index ca0166a..867e177 100644 --- a/profiles/http/docs/home-manager.nix +++ b/profiles/http/docs/home-manager.nix @@ -3,7 +3,7 @@ services.docs-to-host.docs = [ { dirname = "home-manager-manual"; - path = "${inputs.home-manager.packages.${config.nixpkgs.system}.docs-html}/share/doc/home-manager"; + path = "${inputs.home-manager.packages.${pkgs.stdenv.hostPlatform.system}.docs-html}/share/doc/home-manager"; basename= "index.xhtml"; desc = "Home-Manager - a user environment configurator"; } diff --git a/profiles/http/docs/nixpkgs.nix b/profiles/http/docs/nixpkgs.nix index aeac44d..a58c22c 100644 --- a/profiles/http/docs/nixpkgs.nix +++ b/profiles/http/docs/nixpkgs.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, inputs, system, ... }: let # https://stackoverflow.com/a/60232211 - system = config.nixpkgs.system; + system = pkgs.stdenv.hostPlatform.system; mk-nixpkgs-manual = input: input.legacyPackages.${system}.nixpkgs-manual or diff --git a/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh b/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh index a2f5df1..18018ef 100644 --- a/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh +++ b/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh @@ -30,7 +30,9 @@ zeditor-remote() { # ask tailscale if command -v tailscale >/dev/null; then - tailscale status --json | jq .Peer[].HostName -r + # tailscale status --json | jq .Peer[].HostName -r + # tailscale status --json | jq '.Peer[].DNSName | rtrimstr(".")' -r + tailscale status --json | jq '.MagicDNSSuffix as $suffix | .Peer[].DNSName | rtrimstr(".") | rtrimstr("." + $suffix)' -r fi # search .ssh/known_hosts, strip DNS search domains to deduplicate diff --git a/users/pbsds/home/profiles/shell.nix b/users/pbsds/home/profiles/shell.nix index 01afa88..e0c3915 100644 --- a/users/pbsds/home/profiles/shell.nix +++ b/users/pbsds/home/profiles/shell.nix @@ -23,6 +23,13 @@ in # Warn if closing shell with running jobs. "checkjobs" ]; + # programs.bash.historySize = 10000; # in ram + # programs.bash.historyFileSize = 100000; # on file + programs.bash.historyControl = [ + "erasedups" + "ignoreboth" + ]; + programs.bash.historyIgnore = [ "ls" "file" "cat" "type" "exit" ]; programs.bash.initExtra = '' # tldr if command -v tldr >/dev/null; then @@ -177,7 +184,7 @@ in #fq # jq for binaries xh # "friendly fast curl" htmlq # html css queries - xan # a jq for csv, zsv + (pkgs.xan or null) # a jq for csv, zsv # xee # xml xpath queries just # justfile gum diff --git a/users/pbsds/home/profiles/ssh.nix b/users/pbsds/home/profiles/ssh.nix index fd4698a..91f1a69 100644 --- a/users/pbsds/home/profiles/ssh.nix +++ b/users/pbsds/home/profiles/ssh.nix @@ -54,6 +54,7 @@ "sopp.pbsds.net".host = "sopp.tail9aac63.ts.net"; "noximilien.pbsds.net".host = "noximilien.tail9aac63.ts.net"; "rocm.pbsds.net".proxyJump = "login.pvv.ntnu.no"; + "furiphoneflx1.pbsds.net".user = "furios"; # nixos org #"aarch64.nixos.community" = {};