lkjdsalkjdsalkj

This commit is contained in:
Peder Bergebakken Sundt 2025-04-09 13:14:23 +02:00
parent 7acf91d4b4
commit 2885b83f70
10 changed files with 49 additions and 24 deletions

26
.envrc

@ -19,7 +19,6 @@ elif command -v find >/dev/null; then
fi fi
if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then
tmp=$(mktemp -p .direnv/tmp -d) 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 if ! git diff --exit-code --quiet HEAD -- flake.lock >&/dev/null; then
cp flake.lock "$tmp"/dirty-flake.lock cp flake.lock "$tmp"/dirty-flake.lock
git reset -- flake.lock git reset -- flake.lock
@ -28,18 +27,31 @@ if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then
fi fi
git pull --rebase --autostash git pull --rebase --autostash
if grep -q "^=======" flake.lock; then 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 git reset -- flake.lock
rm flake.lock # restore? rm flake.lock # git restore?
git checkout -- flake.lock git checkout -- flake.lock
elif [[ -s "$tmp"/clean-flake.lock ]] && ! diff -q "$tmp"/clean-flake.lock flake.lock >&/dev/null; then elif [[ -s "$tmp"/clean-flake.lock ]] && ! diff -q "$tmp"/clean-flake.lock flake.lock >&/dev/null; then
cp "$tmp"/flake-dirty.lock flake.lock cp "$tmp"/flake-dirty.lock flake.lock
fi fi
direnv allow # :3
# nix flake update # nix flake update
nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json \ declare -a update_args=()
| jq .[] -r \ readarray -td $'\n' update_args < <(
| grep -v '^nixpkgs-expensive$' \ nix eval --file flake.nix --apply 'x: builtins.attrNames x.inputs' --json \
| nix flake update # --output-lock-file "$tmp"/new-flake.lock | 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 printf "%s\n" "$now" > .direnv/pull-date
fi fi

@ -54,7 +54,7 @@
smartmontools smartmontools
testdisk testdisk
usbutils 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 cage
weston weston
]; ];
@ -119,7 +119,7 @@
security.sudo.execWheelOnly = true; security.sudo.execWheelOnly = true;
services.thermald.enable = lib.all (x: x) [ 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) (!config.boot.isContainer or false)
]; ];

@ -42,7 +42,7 @@ lib.mkMerge [
programs.nix-required-mounts.enable = true; programs.nix-required-mounts.enable = true;
programs.nix-required-mounts.presets.nvidia-gpu.enable = true; programs.nix-required-mounts.presets.nvidia-gpu.enable = true;
# adding "cuda", "opengl" and "nvidia-gpu" ^ overrides the implicit defaults # 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"];
}) })
{ {

13
lib.nix

@ -17,17 +17,18 @@ let
nixosSystem: nixosSystem:
let let
cfg = nixosSystem.config; cfg = nixosSystem.config;
inherit (nixosSystem.pkgs) lib; inherit (nixosSystem) pkgs;
inherit (pkgs) lib;
in in
{ {
# inherit cfg.nixpkgs.system; # TODO: cross systems
system = system =
if cfg.nixpkgs.hostPlatform.system == cfg.nixpkgs.buildPlatform.system then if pkgs.stdenv.hostPlatform.system == pkgs.stdenv.buildPlatform.system then
cfg.nixpkgs.system pkgs.stdenv.hostPlatform.system
else else
{ {
hostPlatform = cfg.nixpkgs.hostPlatform.system; # inherit (pkgs.stdenv) hostPlatform buildPlatform;
buildPlatform = cfg.nixpkgs.buildPlatform.system; hostPlatform = pkgs.stdenv.hostPlatform.system;
buildPlatform = pkgs.stdenv.buildPlatform.system;
}; };
inherit (cfg.boot.binfmt) emulatedSystems; inherit (cfg.boot.binfmt) emulatedSystems;
inherit (cfg.networking) hostName fqdn search; inherit (cfg.networking) hostName fqdn search;

@ -10,10 +10,11 @@ in
options.pbsds.nginx.allSubdomains = lib.mkOption { options.pbsds.nginx.allSubdomains = lib.mkOption {
visible = false; internal = true; readOnly = true; visible = false; internal = true; readOnly = true;
default = lib.pipe config.services.nginx.virtualHosts [ default = lib.pipe config.services.nginx.virtualHosts [
#(lib.mapAttrsToList (domain: vhost: [ domain ] ++ vhost.serverAliases)) # #(lib.mapAttrsToList (domain: vhost: [ domain ] ++ vhost.serverAliases))
(lib.mapAttrsToList (domain: vhost: [ domain ])) # (lib.mapAttrsToList (domain: vhost: [ domain ]))
lib.flatten # lib.flatten
(builtins.filter (domain: domain != "" && domain != "_")) lib.attrNames
(lib.filter (domain: domain != "" && domain != "_"))
(lib.sort (x: y: x<y)) (lib.sort (x: y: x<y))
]; ];
}; };
@ -78,6 +79,7 @@ in
# nginx return 444 for all nonexistent virtualhosts # nginx return 444 for all nonexistent virtualhosts
services.nginx.virtualHosts."_" = { services.nginx.virtualHosts."_" = {
default = true;
addSSL = true; addSSL = true;
sslCertificate = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.cert.pem"; sslCertificate = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.cert.pem";
sslCertificateKey = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.key.pem"; sslCertificateKey = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.key.pem";

@ -3,7 +3,7 @@
services.docs-to-host.docs = [ services.docs-to-host.docs = [
{ {
dirname = "home-manager-manual"; 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"; basename= "index.xhtml";
desc = "Home-Manager - a user environment configurator"; desc = "Home-Manager - a user environment configurator";
} }

@ -1,7 +1,7 @@
{ config, pkgs, lib, inputs, system, ... }: { config, pkgs, lib, inputs, system, ... }:
let let
# https://stackoverflow.com/a/60232211 # https://stackoverflow.com/a/60232211
system = config.nixpkgs.system; system = pkgs.stdenv.hostPlatform.system;
mk-nixpkgs-manual = input: mk-nixpkgs-manual = input:
input.legacyPackages.${system}.nixpkgs-manual or input.legacyPackages.${system}.nixpkgs-manual or

@ -30,7 +30,9 @@ zeditor-remote() {
# ask tailscale # ask tailscale
if command -v tailscale >/dev/null; then 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 fi
# search .ssh/known_hosts, strip DNS search domains to deduplicate # search .ssh/known_hosts, strip DNS search domains to deduplicate

@ -23,6 +23,13 @@ in
# Warn if closing shell with running jobs. # Warn if closing shell with running jobs.
"checkjobs" "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 = '' programs.bash.initExtra = ''
# tldr # tldr
if command -v tldr >/dev/null; then if command -v tldr >/dev/null; then
@ -177,7 +184,7 @@ in
#fq # jq for binaries #fq # jq for binaries
xh # "friendly fast curl" xh # "friendly fast curl"
htmlq # html css queries htmlq # html css queries
xan # a jq for csv, zsv (pkgs.xan or null) # a jq for csv, zsv
# xee # xml xpath queries # xee # xml xpath queries
just # justfile just # justfile
gum gum

@ -54,6 +54,7 @@
"sopp.pbsds.net".host = "sopp.tail9aac63.ts.net"; "sopp.pbsds.net".host = "sopp.tail9aac63.ts.net";
"noximilien.pbsds.net".host = "noximilien.tail9aac63.ts.net"; "noximilien.pbsds.net".host = "noximilien.tail9aac63.ts.net";
"rocm.pbsds.net".proxyJump = "login.pvv.ntnu.no"; "rocm.pbsds.net".proxyJump = "login.pvv.ntnu.no";
"furiphoneflx1.pbsds.net".user = "furios";
# nixos org # nixos org
#"aarch64.nixos.community" = {}; #"aarch64.nixos.community" = {};