From 4cc421ec43a4e2a909c58d341070a0ce4b3d8a9b Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sat, 19 Oct 2024 04:05:19 +0200 Subject: [PATCH] things --- hardware/gpu/cuda.nix | 2 ++ hosts/bjarte/configuration.nix | 4 +-- profiles/known-hosts.nix | 2 ++ profiles/mounts/freon-nfs.nix | 3 ++ profiles/mounts/meconium-nfs.nix | 3 ++ profiles/mounts/reidun-nfs.nix | 3 ++ profiles/oci/distrobox.nix | 21 +++++++++++-- users/pbsds/home/default.nix | 5 ---- users/pbsds/home/profiles/desktop/default.nix | 1 + users/pbsds/home/profiles/git.nix | 3 +- users/pbsds/home/profiles/shell.nix | 30 +++++++++++++++++++ 11 files changed, 67 insertions(+), 10 deletions(-) diff --git a/hardware/gpu/cuda.nix b/hardware/gpu/cuda.nix index 5c59db2..3fcbdb2 100644 --- a/hardware/gpu/cuda.nix +++ b/hardware/gpu/cuda.nix @@ -33,8 +33,10 @@ hardware.nvidia.modesetting.enable = lib.mkDefault true; # needed for most wayland compositors hardware.nvidia.nvidiaSettings = lib.mkDefault true; + # https://discourse.nixos.org/t/nvidia-docker-container-runtime-doesnt-detect-my-gpu/51336/2?u=pbsds virtualisation.docker.enableNvidia = lib.mkDefault true; # deprecated virtualisation.podman.enableNvidia = lib.mkDefault true; # deprecated + # this works, but you have to use `--device nvidia.com/gpu=all` rather than --gpus hardware.nvidia-container-toolkit.enable = lib.mkDefault true; services.ollama.acceleration = lib.mkDefault "cuda"; diff --git a/hosts/bjarte/configuration.nix b/hosts/bjarte/configuration.nix index 187449b..0641d3e 100644 --- a/hosts/bjarte/configuration.nix +++ b/hosts/bjarte/configuration.nix @@ -10,9 +10,9 @@ ./hardware-configuration.nix ../../profiles/sshd.nix #../../profiles/no-suspend.nix - #../../profiles/oci/podman.nix + ../../profiles/oci/podman.nix #../../profiles/oci/docker.nix - #../../profiles/oci/distrobox.nix + ../../profiles/oci/distrobox.nix ../../users/pbsds ../../users/pbsds/syncthing.nix diff --git a/profiles/known-hosts.nix b/profiles/known-hosts.nix index a0a7cf9..16ed673 100644 --- a/profiles/known-hosts.nix +++ b/profiles/known-hosts.nix @@ -1,5 +1,7 @@ { config, lib, pkgs, ... }: +# TODO: should max-builds be enforced on thisHost as well? + let inherit (builtins) map diff --git a/profiles/mounts/freon-nfs.nix b/profiles/mounts/freon-nfs.nix index 5e79c29..b9a3205 100644 --- a/profiles/mounts/freon-nfs.nix +++ b/profiles/mounts/freon-nfs.nix @@ -1,4 +1,7 @@ { config, pkgs, lib, ... }: + +# TODO: use tailscale if enabled + { # TODO: wireguard #boot.kernelParams = [ "nfs.nfs4_disable_idmapping=0" "nfsd.nfs4_disable_idmapping=0" ]; diff --git a/profiles/mounts/meconium-nfs.nix b/profiles/mounts/meconium-nfs.nix index b423053..ef79865 100644 --- a/profiles/mounts/meconium-nfs.nix +++ b/profiles/mounts/meconium-nfs.nix @@ -1,4 +1,7 @@ { config, pkgs, lib, ... }: + +# TODO: use tailscale if enabled + { # TODO: wireguard #boot.kernelParams = [ "nfs.nfs4_disable_idmapping=0" "nfsd.nfs4_disable_idmapping=0" ]; diff --git a/profiles/mounts/reidun-nfs.nix b/profiles/mounts/reidun-nfs.nix index cdf3590..bab7cec 100644 --- a/profiles/mounts/reidun-nfs.nix +++ b/profiles/mounts/reidun-nfs.nix @@ -1,4 +1,7 @@ { config, pkgs, lib, ... }: + +# TODO: use tailscale if enabled + { # TODO: wireguard #boot.kernelParams = [ "nfs.nfs4_disable_idmapping=0" "nfsd.nfs4_disable_idmapping=0" ]; diff --git a/profiles/oci/distrobox.nix b/profiles/oci/distrobox.nix index a35fe0d..3f22b1c 100644 --- a/profiles/oci/distrobox.nix +++ b/profiles/oci/distrobox.nix @@ -1,5 +1,19 @@ { pkgs, config, ... }: +/* + +# via https://distrobox.it/compatibility/#containers-distros +use --nvidia for cuda support + +distrobox create --name alpine --init --yes --image docker.io/libary/alpine:latest +distrobox create --name arch --init --yes --image docker.io/libary/archlinux:latest +distrobox create --name debian --init --yes --image docker.io/libary/debian:testing +distrobox create --name fedora --init --yes --image quay.io/fedora/fedora:rawhide +distrobox create --name gentoo --init --yes --image docker.io/gentoo/stage3:latest +#distrobox create --name ubuntu --init --yes --image quay.io/toolbx/ubuntu-toolbox:latest + +*/ + { assertions = [ @@ -12,11 +26,14 @@ environment.systemPackages = [ pkgs.distrobox ]; + # ++ lib.optionals (!config.virtualisation.docker.enable && !config.virtualisation.podman.enable) [ + # pkgs.lilipod + #]; # update periodically systemd.user = { timers."distrobox-update" = { - enable = true; + enable = config.system.autoUpgrade.enable; wantedBy = ["timers.target"]; timerConfig = { OnBootSec = "1h"; @@ -26,7 +43,7 @@ }; services."distrobox-update" = { - enable = true; + enable = config.system.autoUpgrade.enable; script = '' ${pkgs.distrobox}/bin/distrobox upgrade --all ''; diff --git a/users/pbsds/home/default.nix b/users/pbsds/home/default.nix index bb94b72..c1ba2ce 100644 --- a/users/pbsds/home/default.nix +++ b/users/pbsds/home/default.nix @@ -142,11 +142,6 @@ manix-fzf = ''manix "" 2>/dev/null | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview="manix '{}'" | xargs manix''; - # TODO: move to /run/user/... - /* nixpkgs-review = ''mkdir -p /dev/shm/nixpkgs-review && ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review && nixpkgs-review''; */ - /* nixpkgs-review = ''cd ~/repos/nixpkgs/master/; nixpkgs-review --systems "$(gum choose --no-limit --ordered x86_64-linux aarch64-linux aarch64-darwin x86_64-darwin i686-linux riscv64-linux x86_64-freebsd aarch64-freebsd i686-freebsd riscv64-freebsd | xargs)"''; */ - mnixpkgs-review = ''nixpkgs-review --systems "$(gum choose --no-limit --ordered {linux,darwin,freebsd}-{x86_64,aarch64,i686,riscv64} | sed -E 's/^([^-]*)-([^-]*)$/\2-\1/' | xargs)"''; - killall = "killall -v"; bin = "python -c 'import sys; sys.stdout.write(sys.stdin.read().strip())' | curl -is -X POST https://i.kuklef.se/upload -F content=@- -F expiration=10d | grep '^location:' | cut -d' ' -f2-"; diff --git a/users/pbsds/home/profiles/desktop/default.nix b/users/pbsds/home/profiles/desktop/default.nix index 433f8ec..794e848 100644 --- a/users/pbsds/home/profiles/desktop/default.nix +++ b/users/pbsds/home/profiles/desktop/default.nix @@ -38,6 +38,7 @@ emote normcap # doesn't work on wayland + gcolor3 icon-library gitg diff --git a/users/pbsds/home/profiles/git.nix b/users/pbsds/home/profiles/git.nix index b7b93b4..f8da481 100644 --- a/users/pbsds/home/profiles/git.nix +++ b/users/pbsds/home/profiles/git.nix @@ -41,8 +41,9 @@ ".remote.toml" ".remoteenv" "result" - "results" "result-*" + "results" + "results-*" "__pycache__" "*.pyc" ]; diff --git a/users/pbsds/home/profiles/shell.nix b/users/pbsds/home/profiles/shell.nix index 757846e..d08ff39 100644 --- a/users/pbsds/home/profiles/shell.nix +++ b/users/pbsds/home/profiles/shell.nix @@ -48,6 +48,28 @@ fi done } + + _choose_nix_systems() { + # x86_64-linux aarch64-linux aarch64-darwin x86_64-darwin i686-linux riscv64-linux x86_64-freebsd aarch64-freebsd i686-freebsd riscv64-freebsd + gum choose --no-limit --ordered --height 15 {linux,darwin,freebsd}-{x86_64,aarch64,i686,riscv64} \ + | sed -E 's/^([^-]*)-([^-]*)$/\2-\1/' + } + + mnix-build() { + # TODO: somehow store the out-links + _choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" . '"$(printf " %q" "$@")" | xargs nix-build --keep-going --no-out-link + } + mnom-build() { + # TODO: somehow store the out-links + _choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" . '"$(printf " %q" "$@")" | xargs nom-build --keep-going --no-out-link + } + mnixpkgs-review() { + # TODO: use /run/user/... + # mkdir -p /dev/shm/nixpkgs-review + # ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review + nixpkgs-review --systems "$(_choose_nix_systems | xargs)" "$@" + } + ''; imports = [ ../modules/jump.nix ]; @@ -103,6 +125,14 @@ #home.shellAliases.mv = "mv -i"; #home.shellAliases.cp = "cp -i"; + home.shellAliases.inom-build = "nom-build --system i686-linux -j0"; + home.shellAliases.inix-build = "nix-build --system i686-linux -j0"; + home.shellAliases.rnom-build = "nom-build --system riscv64-linux -j0"; + home.shellAliases.rnix-build = "nix-build --system riscv64-linux -j0"; + home.shellAliases.fnom-build = "nom-build --system x86_64-freebsd -j0"; + home.shellAliases.fnix-build = "nix-build --system x86_64-freebsd -j0"; + home.shellAliases.anom-build = "nom-build --system aarch64-linux -j0"; + home.shellAliases.anix-build = "nix-build --system aarch64-linux -j0"; home.shellAliases.dnom-build = "nom-build --system x86_64-darwin -j0"; home.shellAliases.dnix-build = "nix-build --system x86_64-darwin -j0"; home.shellAliases.danom-build = "nom-build --system aarch64-darwin -j0";