From 291d2e0c606975d12a53cc394c08ac1b6673492a Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sat, 29 Nov 2025 06:30:15 +0100 Subject: [PATCH] fix --- flake.nix | 33 ++++++--- hosts/default.nix | 2 +- hosts/nixos/hasselknippe/configuration.nix | 52 +++++++++---- justfile | 81 ++++++++++++++------- profiles/oci/docker.nix | 12 +++ users/pbsds/default.nix | 2 +- users/pbsds/home/profiles/comfy/default.nix | 2 +- 7 files changed, 128 insertions(+), 56 deletions(-) diff --git a/flake.nix b/flake.nix index 588b39c..506d641 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ # https://github.com/nixos/nixpkgs nixpkgs-test.url = "github:NixOS/nixpkgs/refs/pull/379645/merge"; # for testing nixpkgs-edge.url = "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz"; # len("edge") == 4 + # nixpkgs-2511.url = "https://nixos.org/channels/nixos-25.11/nixexprs.tar.xz"; nixpkgs-2505.url = "https://nixos.org/channels/nixos-25.05/nixexprs.tar.xz"; nixpkgs-2411.url = "https://nixos.org/channels/nixos-24.11/nixexprs.tar.xz"; # for old docs nixpkgs-2405.url = "https://nixos.org/channels/nixos-24.05/nixexprs.tar.xz"; # for old docs @@ -25,6 +26,8 @@ # https://github.com/nix-community/home-manager home-manager-edge.url = "github:nix-community/home-manager/master"; home-manager-edge.inputs.nixpkgs.follows = "nixpkgs-edge"; + # home-manager-2511.url = "github:nix-community/home-manager/release-25.11"; + # home-manager-2511.inputs.nixpkgs.follows = "nixpkgs-2511"; home-manager-2505.url = "github:nix-community/home-manager/release-25.05"; home-manager-2505.inputs.nixpkgs.follows = "nixpkgs-2505"; home-manager-2411.url = "github:nix-community/home-manager/release-24.11"; @@ -77,6 +80,8 @@ # https://github.com/Mic92/sops-nix sops-nix-edge.url = "github:Mic92/sops-nix"; sops-nix-edge.inputs.nixpkgs.follows = "nixpkgs-edge"; + # sops-nix-2511.url = "github:Mic92/sops-nix"; + # sops-nix-2511.inputs.nixpkgs.follows = "nixpkgs-2511"; sops-nix-2505.url = "github:Mic92/sops-nix"; sops-nix-2505.inputs.nixpkgs.follows = "nixpkgs-2505"; sops-nix-2411.url = "github:Mic92/sops-nix"; @@ -139,9 +144,16 @@ home-manager = inputs'.home-manager-edge; sops-nix = inputs'.sops-nix-edge; }; + input-views.inputs-2511 = input-views.inputs-edge; + # input-views.inputs-2511 = inputs' // { + # nixpkgs = inputs'.nixpkgs-2511; + # unstable = inputs'.nixpkgs-edge; + # home-manager = inputs'.home-manager-2511; + # sops-nix = inputs'.sops-nix-2511; + # }; input-views.inputs-2505 = inputs' // { nixpkgs = inputs'.nixpkgs-2505; - unstable = inputs'.nixpkgs-edge; + unstable = inputs'.nixpkgs-2511; home-manager = inputs'.home-manager-2505; sops-nix = inputs'.sops-nix-2505; }; @@ -255,11 +267,12 @@ }]; extraSpecialArgs = { inherit inputs; }; }; + forEach = xs: f: map f xs; pipe = builtins.foldl' (x: f: f x); attrsToList = a: builtins.attrValues (builtins.mapAttrs (name: value: { inherit name value; }) a); in - pipe ["edge" "2505" "2411"] [ - (map (release: { + pipe ( + forEach ["edge" "2505" "2411"] (release: { # TODO: static - fhs # TODO: pvv - nfs home # TODO: nix-portable - heid @@ -270,24 +283,20 @@ "pbsds-comfy-${release}" = mkHome "pbsds" "/home/pbsds" "x86_64-linux" input-views."inputs-${release}" [ ./users/pbsds/home/profiles/comfy ]; "pbsds-desktop-${release}" = mkHome "pbsds" "/home/pbsds" "x86_64-linux" input-views."inputs-${release}" [ ./users/pbsds/home/profiles/desktop ]; "pbsds-desktop-gnome-${release}" = mkHome "pbsds" "/home/pbsds" "x86_64-linux" input-views."inputs-${release}" [ ./users/pbsds/home/profiles/desktop/gnome ]; - })) - (map attrsToList) - builtins.concatLists - builtins.listToAttrs - ] - // pipe (builtins.attrNames self.nixosConfigurations) [ - (map (machine: { + }) + ++ forEach (builtins.attrNames self.nixosConfigurations) (machine: { "pbsds@${machine}" = rec { config = self.nixosConfigurations.${machine}.config.home-manager.users.pbsds; inherit (config.home) activationPackage; }; - })) + }) + ) [ (map attrsToList) builtins.concatLists builtins.listToAttrs ] // { - "pederbs@pvv" = mkHome "pederbs" "/home/pvv/d/pederbs" "x86_64-linux" input-views.inputs-2505 [ ./users/pbsds/home/profiles/minimal ]; + "pederbs@login.pvv.ntnu.no" = mkHome "pederbs" "/home/pvv/d/pederbs" "x86_64-linux" input-views.inputs-2505 [ ./users/pbsds/home/profiles/minimal ]; }; # TODO: use this to pull changes to repo diff --git a/hosts/default.nix b/hosts/default.nix index 3ed1c6d..b768c69 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -94,7 +94,7 @@ let bolle = mk "pbsds.net" "x86_64-linux" input-views.inputs-edge "25.05" [ ts2 au tse ]; eple = mk "pbsds.net" "x86_64-linux" input-views.inputs-2505 "25.05" [ ts1 au tse dns64 ]; garp = mk "pbsds.net" "x86_64-linux" input-views.inputs-2505 "25.05" [ ts1 au ]; - # hasselknippe= mk "pbsds.net" "aarch64-linux" input-views.inputs-2405 "24.05" [ ts1 hw.pine64-pinebook-pro ]; + # hasselknippe= mk "pbsds.net" "aarch64-linux" input-views.inputs-2505 "24.05" [ ts1 ]; # alsaug gomperud smattkuken skrytebiffen skalkesnerken kelfrid balleby bingus skjrlaltatjlstad # bergjlot snortheimsmoen ditlefsen skrukkerud podebusk zmaragd makrell alfnes blix urke pytte uddu imdorf rosenqvist diff --git a/hosts/nixos/hasselknippe/configuration.nix b/hosts/nixos/hasselknippe/configuration.nix index d289881..e185737 100644 --- a/hosts/nixos/hasselknippe/configuration.nix +++ b/hosts/nixos/hasselknippe/configuration.nix @@ -1,27 +1,44 @@ -{ config, pkgs, lib, ... }: +{ inputs, config, pkgs, lib, ... }: +/* + +https://wiki.pine64.org/wiki/Pinebook_Pro +https://wiki.pine64.org/wiki/Pinebook_Pro_Software_Releases +https://wiki.nixos.org/wiki/NixOS_on_ARM/PINE64_Pinebook_Pro +https://github.com/NixOS/nixos-hardware/blob/master/pine64/pinebook-pro/README.md + +# tow-boot +https://tow-boot.org/devices/pine64-pinebookPro.html +https://github.com/Tow-Boot/Tow-Boot/releases + +# nixos aarch64 sd-images +https://wiki.nixos.org/wiki/NixOS_on_ARM/Installation#SD_card_images_(SBCs_and_similar_platforms) + +https://wiki.nixos.org/wiki/NixOS_on_ARM +https://wiki.nixos.org/wiki/NixOS_on_ARM/Initial_Configuration + +*/ { # Bootloader #boot.loader.systemd-boot.enable = true; #boot.loader.efi.canTouchEfiVariables = true; - services.xserver.displayManager.autoLogin.enable = true; - services.xserver.displayManager.autoLogin.user = "pbsds"; - # tmp: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 - systemd.services."getty@tty1".enable = false; - systemd.services."autovt@tty1".enable = false; - imports = [ #./hardware-configuration.nix - ../../../profiles/auto-upgrade.nix - ../../../profiles/upgrade-diff.nix - #../../../profiles/sshd - #../../../profiles/no-suspend.nix + inputs.nixos-hardware.nixosModules.pine64-pinebook-pro + + # ../../../profiles/nix-ld.nix + ../../../profiles/sshd + # ../../../profiles/earlyoom.nix + # ../../../profiles/no-suspend.nix + # ../../../profiles/oci/podman.nix + # ../../../profiles/oci/docker.nix ../../../users/pbsds #../../../profiles/mounts/freon-nfs.nix #../../../profiles/mounts/reidun-nfs.nix #../../../profiles/mounts/meconium-nfs.nix + #../../../profiles/mounts/fridge-nfs.nix ../../../profiles/shell.nix @@ -29,11 +46,16 @@ ../../../profiles/desktop/gnome # configures gdm ../../../profiles/desktop/sound/pipewire.nix - #../../../profiles/desktop/steam.nix - #../../../profiles/desktop/lutris.nix - #../../../profiles/desktop/flatpak.nix + # ../../../profiles/desktop/steam.nix + # ../../../profiles/desktop/retroarch.nix + # ../../../profiles/desktop/flatpak.nix + # ../../../profiles/desktop/waydroid.nix - /* ../../../profiles/known-hosts */ + ../../../profiles/known-hosts + ]; + + environment.systemPackages = [ + pkgs.pinebookpro-keyboard-updater ]; networking.firewall.allowedTCPPorts = [ 57621 ]; # spotify local discovery diff --git a/justfile b/justfile index 57d4444..fa6c42e 100644 --- a/justfile +++ b/justfile @@ -57,27 +57,41 @@ pull-dconf: -gum confirm "git checkout --path?" --default=no \ && git checkout --patch ./users/pbsds/home/profiles/desktop/gnome/ -# todo: support system-manager -# todo: support home-manager? -build hostname="" *_: - nixos-rebuild-ng build --accept-flake-config --show-trace --flake .#"{{hostname}}" "${@:2}" +# todo: support system-manager? +# todo: support nix-darwin? +# todo: support nixbsd? +# todo: support nixng? +build $hostname="" *_: + #!/usr/bin/env -S bash -euo pipefail + if [[ "${hostname::1}" = "-" ]]; then + echo >&2 "WARNING(just): 'hostname' starts with '-', moving it to nix args..." + set -- "" "$@"; hostname="" + fi + set -x; nixos-rebuild-ng build --accept-flake-config --show-trace --flake .#"$hostname" "${@:2}" build-vm hostname=`just _a_host` *_: - nixos-rebuild-ng build-vm --accept-flake-config --show-trace --flake .#"{{hostname}}" "${@:2}" + #!/usr/bin/env -S bash -euo pipefail + if [[ "${hostname::1}" = "-" ]]; then + echo >&2 "WARNING(just): 'hostname' starts with '-', moving it to nix args..." + set -- "" "$@"; hostname="" + fi + set -x; nixos-rebuild-ng build-vm --accept-flake-config --show-trace --flake .#"$hostname" "${@:2}" build-vm-and-run $hostname=`just _a_host` *_: - @# TODO: setup ports? - @# TODO: attach serial instead of gui? - @# TODO: headless and ssh? - @just build-vm "$hostname" "${@:2}" - ./result/bin/run-"$hostname"-vm + #!/usr/bin/env -S bash -euo pipefail + [[ -n "$hostname" ]] + # TODO: setup ports? + # TODO: attach serial instead of gui? + # TODO: headless and ssh? + just build-vm "$hostname" "${@:2}" + set -x; ./result/bin/run-"$hostname"-vm # compares new closure against /run/current-system build-diff $hostname="" *_: #!/usr/bin/env -S bash -euo pipefail current_system="/run/current-system" new_system="$(just build "$hostname" "${@:2}")" - echo; set -x + echo >&2; set -x # nvd diff "$current_system" "$new_system" # python based, slow dix "$current_system" "$new_system" # rust based, fast, nixos-unstable only @@ -89,27 +103,42 @@ build-closure-size $hostname="" *_: nix path-info --recursive --size --closure-size "$new_system" | sort -nk3 | numfmt --field=2,3 --to iec test *_: - sudo nixos-rebuild-ng test --accept-flake-config --show-trace --flake . "$@" + #!/usr/bin/env -S bash -euo pipefail + if [[ $# -gt 0 && "${1:-}" = "" ]]; then + echo >&2 "WARNING(just): first arg is empty, popping it off..."; shift + elif [[ $# -gt 0 && "${1::1}" != "-" ]]; then + echo >&2 "WARNING(just): first arg does not start with "-", is it a hostname?" + fi + set -x; sudo nixos-rebuild-ng test --accept-flake-config --show-trace --flake . "$@" switch *_: - sudo nixos-rebuild-ng switch --accept-flake-config --show-trace --flake . "$@" + #!/usr/bin/env -S bash -euo pipefail + if [[ $# -gt 0 && "${1:-}" = "" ]]; then + echo >&2 "WARNING(just): first arg is empty, popping it off..."; shift + elif [[ $# -gt 0 && "${1::1}" != "-" ]]; then + echo >&2 "WARNING(just): first arg does not start with "-", is it a hostname?" + fi + set -x; sudo nixos-rebuild-ng switch --accept-flake-config --show-trace --flake . "$@" boot *_: #!/usr/bin/env -S bash -euo pipefail - if [[ $# -ge 1 ]]; then - if [[ "${1:-}" = "" ]]; then - echo >&2 "WARNING: first arg was empty, popping it off..." - shift - elif [[ "${1::1}" != "-" ]]; then - echo >&2 "WARNING: first arg did not start with a "-", is it a hostname?" - fi + if [[ $# -gt 0 && "${1:-}" = "" ]]; then + echo >&2 "WARNING(just): first arg is empty, popping it off..."; shift + elif [[ $# -gt 0 && "${1::1}" != "-" ]]; then + echo >&2 "WARNING(just): first arg does not start with "-", is it a hostname?" + fi + set -x; sudo nixos-rebuild-ng boot --accept-flake-config --show-trace --flake . "$@" + +boot-and-reboot *_: + #!/usr/bin/env -S bash -euo pipefail + if [[ $# -gt 0 && "${1:-}" = "" ]]; then + echo >&2 "WARNING(just): first arg is empty, popping it off..."; shift + elif [[ $# -gt 0 && "${1::1}" != "-" ]]; then + echo >&2 "WARNING(just): first arg does not start with "-", is it a hostname?" fi set -x sudo nixos-rebuild-ng boot --accept-flake-config --show-trace --flake . "$@" - -boot-and-reboot *_: - sudo nixos-rebuild-ng boot --accept-flake-config --show-trace --flake . "$@" - sudo reboot + sudo reboot # TODO: can i somehow ensure that the sudo hasn't timed out by this time? # TODO: nixos-rebuild-ng push $hostname=`just _a_host` cmd=`gum choose test switch boot --header "Select mode..."`: @@ -140,7 +169,7 @@ home-why-depends $attrpath: .#nixosConfigurations."${hostname}".config.home-manager.users."${username}".home.activationPackage \ .#nixosConfigurations."${hostname}".pkgs."$attrpath" -home-eval attrpath="home.activationPackage" *_: +home-eval $attrpath="home.activationPackage" *_: #!/usr/bin/env -S bash -euo pipefail hostname="$(hostname)" username="$(whoami)" @@ -164,7 +193,7 @@ home-build-diff *_: home-build #!/usr/bin/env -S bash -euo pipefail current_home="${XDG_STATE_HOME:-"$HOME/.local/state"}/home-manager/gcroots/current-home" new_home="$(just home-build --print-out-paths "${@:1}")" - set -x + echo >&2; set -x # nvd diff "$current_home" "$new_home" # python based, slow dix "$current_home" "$new_home" # rust based, fast, nixos-unstable only diff --git a/profiles/oci/docker.nix b/profiles/oci/docker.nix index 0962258..c433a2b 100644 --- a/profiles/oci/docker.nix +++ b/profiles/oci/docker.nix @@ -1,4 +1,16 @@ { lib, pkgs, ... }: +/* +how to prune? + +docker ps -aq | xargs --no-run-if-empty docker stop ; \ +docker system prune -af ; \ +docker image prune -af ; \ +docker volume prune -af ; \ +docker system prune -af --volumes ; \ +docker system df + +*/ + { virtualisation.docker.enable = true; virtualisation.oci-containers.backend = lib.mkDefault "docker"; diff --git a/users/pbsds/default.nix b/users/pbsds/default.nix index d1c8c29..aa7028f 100644 --- a/users/pbsds/default.nix +++ b/users/pbsds/default.nix @@ -33,7 +33,7 @@ # ./home/profiles/headless # ./home/profiles/comfy # ./home/profiles/desktop (gnome) - home-manager.users.pbsds = lib.mkMerge [ + home-manager.users.pbsds.imports = [ ( if config.services.xserver.desktopManager.gnome.enable then ./home/profiles/desktop/gnome diff --git a/users/pbsds/home/profiles/comfy/default.nix b/users/pbsds/home/profiles/comfy/default.nix index a2ba411..7f2c045 100644 --- a/users/pbsds/home/profiles/comfy/default.nix +++ b/users/pbsds/home/profiles/comfy/default.nix @@ -86,7 +86,7 @@ ]; xdg.configFile."ptpython/config.py" = { - source = ./files/ptpython-config.py; + source = ../../files/ptpython-config.py; force = true; };