From 18488deb721e4aacc0e657db08100d59fd025b38 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 19 Mar 2023 04:23:38 +0100 Subject: [PATCH] stuff --- .envrc | 10 +- .remoteenv | 2 +- README.md | 3 + flake.nix | 122 ++++++++++++------------- hardware/rocm.nix | 8 +- hosts/nord/default.nix | 2 + pkgs/remote-exec.nix | 6 +- profiles/desktop/steam.nix | 2 + profiles/domeneshop-dyndns/default.nix | 2 +- profiles/remote-builders/default.nix | 4 +- profiles/shell/base.nix | 2 + users/default.nix | 2 +- users/pbsds/home/default.nix | 1 + users/pbsds/home/files/lxterminal.conf | 2 +- users/pbsds/home/profiles/bat.nix | 5 +- users/pbsds/home/profiles/ssh.nix | 5 +- 16 files changed, 102 insertions(+), 76 deletions(-) diff --git a/.envrc b/.envrc index 0ce331b..aa69d57 100644 --- a/.envrc +++ b/.envrc @@ -10,15 +10,21 @@ if ! test -s .direnv/pull-date || test "$now" != "$(cat .direnv/pull-date)"; the fi if command -v nixos-rebuild >/dev/null; then - use flake .#nomos-rebuild + use flake .#nixos-rebuild-nom elif ! command -v nixos-rebuild >/dev/null; then use flake .#non-nixos fi if test -s .remote.toml; then - use flake .#remote + if ! command -v remote-init >/dev/null; then + use flake .#remote + fi echo echo "Current remote: $(remote-host)" tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)"' -r echo fi + +if rg 'TODO' -q ; then + echo "There are $(rg 'TODO' | wc -l ) 'TODO'" +fi diff --git a/.remoteenv b/.remoteenv index c2fbc98..94f895e 100644 --- a/.remoteenv +++ b/.remoteenv @@ -1,3 +1,3 @@ #!/usr/bin/env bash -eval "$(nix print-dev-env .#nomos-rebuild)" +eval "$(nix print-dev-env .#nixos-rebuild-nom)" echo Entered $(hostname --fqdn) diff --git a/README.md b/README.md index 284ae5e..6c24dd1 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ * [ ] add a hidpi profile? https://wiki.archlinux.org/title/HiDPI * [ ] rocm * [ ] xclip +* [ ] https://git.m-labs.hk/M-Labs/wfvm +* [ ] https://github.com/kholia/OSX-KVM +* [ ] mlflow / wandb * [ ] xforwarding over ssh * [ ] autogenerate ssh keys * [ ] switch to systemd networkd diff --git a/flake.nix b/flake.nix index 7d7aa6a..5e5a16b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,23 +1,28 @@ { description = "pbsds' system/home flake"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; - inputs.unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; - inputs.nur.url = "github:nix-community/NUR"; - inputs.home-manager.url = "github:nix-community/home-manager"; #/release-22.11"; - inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs"; - inputs.nixos-hardware.url = "github:NixOS/nixos-hardware"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; + unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + nur.url = "github:nix-community/NUR"; + home-manager.url = "github:nix-community/home-manager"; #/release-22.11"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nixos-hardware.url = "github:NixOS/nixos-hardware"; - #TODO: - #sops-nix.url = "github:Mic92/sops-nix"; - #sops-nix.inputs.nixpkgs.follows = "nixpkgs"; - #matrix-next.url = "github:dali99/nixos-matrix-modules"; # see https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/flake.nix + #TODO: + #sops-nix.url = "github:Mic92/sops-nix"; + #sops-nix.inputs.nixpkgs.follows = "nixpkgs"; + #matrix-next.url = "github:dali99/nixos-matrix-modules"; # see https://git.pvv.ntnu.no/Drift/pvv-nixos-config/src/main/flake.nix - inputs.pbsds-papers.url = "git+ssh://git@github.com/pbsds/papers.git"; - inputs.pbsds-papers.flake = false; + # TODO: somehow make these private repos optional (a lazy fetch would be nice) + pbsds-papers.url = "git+ssh://git@github.com/pbsds/papers.git"; + pbsds-papers.flake = false; - # temp - inputs.pr-polaris14.url = "github:pbsds/nixpkgs/polaris-14"; + # temporary stuff i want to use + # TODO: can i fetch a subset of files if these? ^ + pr-polaris14.url = "github:pbsds/nixpkgs/polaris-14"; + pr-remote-exec.url = "github:pbsds/nixpkgs/remote-exec-init"; + }; outputs = { self, @@ -35,7 +40,7 @@ "aarch64-linux" #"riscv64-linux" ]; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); + forAllSystems = f: nixlib.genAttrs systems (system: f system); overlays = nixlib.mapAttrsToList (name: val: val) self.overlays; # TODO: move unstable and nur here? @@ -43,11 +48,12 @@ disabledModules = [ "services/misc/polaris.nix" ]; imports = [ "${inputs.pr-polaris14}/nixos/modules/services/misc/polaris.nix" ]; nixpkgs.overlays = [(final: prev: { # TODO: nixpkgs.config.packageOverrides ? + remote-exec = prev.python3Packages.callPackage "${inputs.pr-remote-exec}/pkgs/tools/misc/remote-exec" { }; polaris = prev.callPackage "${inputs.pr-polaris14}/pkgs/servers/polaris" { }; polaris-web = prev.callPackage "${inputs.pr-polaris14}/pkgs/servers/polaris/web.nix" { }; })]; }; - mkConfig = hostname: system: modules: nixpkgs.lib.nixosSystem { + mkConfig = hostname: system: modules: nixlib.nixosSystem { inherit system; specialArgs = { inherit inputs; }; modules = modules ++ [ ./base.nix "${self}/hosts/${hostname}" tmpConfig ({ @@ -78,57 +84,51 @@ inherit inputs; overlays.remote-exec = (final: prev: { - remote-exec = prev.python3Packages.callPackage ./pkgs/remote-exec.nix {}; + remote-exec = prev.python3Packages.callPackage ( inputs.pr-remote-exec + "/pkgs/tools/misc/remote-exec" ) {}; }); packages = forAllSystems(system: - let pkgs = import nixpkgs { inherit system overlays; }; - in { inherit (pkgs) remote-exec; } - ); - - nixosConfigurations.noximilien = mkConfig "noximilien" "x86_64-linux" (with nixos-hardware.nixosModules; [ common-pc common-pc-ssd common-cpu-intel ]); - nixosConfigurations.bolle = mkConfig "bolle" "x86_64-linux" (with nixos-hardware.nixosModules; [ common-pc common-pc-ssd common-cpu-intel ]); - #nixosConfigurations.nord = mkConfig "nord" "x86_64-linux" (with nixos-hardware.nixosModules; [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-gpu-amd ]); - nixosConfigurations.nord = mkConfig "nord" "x86_64-linux" (with nixos-hardware.nixosModules; [ common-pc common-pc-ssd common-cpu-intel common-gpu-amd ]); - - homeConfigurations = forAllSystems (system: { - pbsds = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; - modules = [ ./users/pbsds/home ]; - }; - pbsds-gnome = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; - modules = [ ./users/pbsds/home/gnome.nix ]; - }; + let pkgs = nixpkgs.legacyPackages.${system}; in { + inherit (self.overlays.remote-exec null pkgs) remote-exec; }); - devShells = forAllSystems (system: { # TODO: apply my overlays? - #default = nixpkgs.legacyPackages.${system}.mkShell { - # packages = with nixpkgs.legacyPackages.${system}; [ - # ]; - #}; - nomos-rebuild = nixpkgs.legacyPackages.${system}.mkShell { - packages = with nixpkgs.legacyPackages.${system}; [ - (writeScriptBin "nixos-rebuild" '' - exec ${nixos-rebuild}/bin/nixos-rebuild "$@" |& ${nix-output-monitor}/bin/nom - '') - ]; - }; - non-nixos = nixpkgs.legacyPackages.${system}.mkShell { - packages = with nixpkgs.legacyPackages.${system}; [ - (writeScriptBin "nixos-rebuild" '' - exec ${nixos-rebuild}/bin/nixos-rebuild "$@" |& ${nix-output-monitor}/bin/nom - '') - nix-output-monitor - home-manager - ]; - }; - remote = nixpkgs.legacyPackages.${system}.mkShell { - packages = with nixpkgs.legacyPackages.${system}; [ - self.packages.${system}.remote-exec - yq - ]; + nixosConfigurations = let nm = nixos-hardware.nixosModules; in { + # TODO: move nixos-hardware imports to the nixos configs? + noximilien = mkConfig "noximilien" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]); + bolle = mkConfig "bolle" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]); + nord = mkConfig "nord" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-gpu-amd ]); + }; + + homeConfigurations = forAllSystems (system: let + mkHome = modules: home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + inherit modules; }; + in { + pbsds = mkHome [ ./users/pbsds/home ]; + pbsds-gnome = mkHome [ ./users/pbsds/home/gnome.nix ]; + }); + + devShells = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + remote-exec = pkgs.remote-exec or (self.overlays.remote-exec pkgs pkgs).remote-exec; + nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" '' + exec ${pkgs.nixos-rebuild}/bin/nixos-rebuild "$@" |& ${pkgs.nix-output-monitor}/bin/nom + ''; + mkShell = packages: pkgs.mkShell { inherit packages; }; + in { + nixos-rebuild-nom = mkShell [ + nixos-rebuild-nom + ]; + non-nixos = mkShell [ + nixos-rebuild-nom + pkgs.home-manager + pkgs.nix-output-monitor + ]; + remote = mkShell [ + remote-exec + pkgs.yq + ]; }); }; diff --git a/hardware/rocm.nix b/hardware/rocm.nix index afe190a..d5e523b 100644 --- a/hardware/rocm.nix +++ b/hardware/rocm.nix @@ -1,7 +1,13 @@ { pkgs, ... }: { - services.xserver.videoDrivers = [ "amdgpu" ]; # for some reason nixos-hardware uses "modesetting" # assumes common-gpu-amd from nixos-hardware is also added + # TODO: should we move it from flake.nix to here? + + # https://libreddit.noximilien.pbsds.net/r/archlinux/comments/nih9c9/amdgpu_vs_modesetting_in_current_510_kernels_xorg/ + + services.xserver.videoDrivers = [ "amdgpu" ]; # use gpu, adaptive sync and and hardware page flipping + #services.xserver.videoDrivers = [ "modesetting" ]; # integrated (non-accelerated) framebuffer, KMS + nixpkgs.config.rocmSupport = true; systemd.tmpfiles.rules = [ "L+ /opt/rocm/hip - - - - ${pkgs.hip}" diff --git a/hosts/nord/default.nix b/hosts/nord/default.nix index 1793e2c..14cd5be 100644 --- a/hosts/nord/default.nix +++ b/hosts/nord/default.nix @@ -76,6 +76,8 @@ flat-remix-icon-theme feh + zotero + firefox ]; diff --git a/pkgs/remote-exec.nix b/pkgs/remote-exec.nix index 552bc03..cab76f0 100644 --- a/pkgs/remote-exec.nix +++ b/pkgs/remote-exec.nix @@ -1,12 +1,14 @@ { lib , fetchFromGitHub , buildPythonApplication -# inputs + +# runtime , click , toml , pydantic , watchdog -# testing + +# check , pytestCheckHook , rsync }: diff --git a/profiles/desktop/steam.nix b/profiles/desktop/steam.nix index 144da09..9e54cfd 100644 --- a/profiles/desktop/steam.nix +++ b/profiles/desktop/steam.nix @@ -4,6 +4,8 @@ programs.steam.remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play programs.steam.dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + # TODO: gamemode? + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam" "steam-original" diff --git a/profiles/domeneshop-dyndns/default.nix b/profiles/domeneshop-dyndns/default.nix index 84545c8..7dd329a 100644 --- a/profiles/domeneshop-dyndns/default.nix +++ b/profiles/domeneshop-dyndns/default.nix @@ -7,7 +7,7 @@ in options = with lib; { services.domeneshop-updater.target = mkOption { - type = types.str; + type = types.str; #TODO list of string #default = config.networking.fqdn; }; }; diff --git a/profiles/remote-builders/default.nix b/profiles/remote-builders/default.nix index f00effe..0a778bd 100644 --- a/profiles/remote-builders/default.nix +++ b/profiles/remote-builders/default.nix @@ -16,7 +16,7 @@ let sshUser = "pbsds"; maxJobs = 12; # 12 cores #maxJobs = 1; # at least for big-parallel - speedFactor = 2; + speedFactor = 3; supportedFeatures = [ "kvm" "big-parallel" "nixos-test" ]; #mandatoryFeatures = [ ]; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILeOB/57N1fQPVorIUlkkJZaQduBo+4+km2Qbj4ebd/k"; @@ -52,7 +52,7 @@ let proxy.host = "isvegg.pvv.ntnu.no"; proxy.publicKey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGurF7rdnrDP/VgIK2Tx38of+bX/QGCGL+alrWnZ1Ca5llGneMulUt1RB9xZzNLHiaWIE+HOP0i4spEaeZhilfU="; } - /**/ + /** / { systems = [ "x86_64-linux" "wasm32-wasi" "wasm64-wasi" "x86_64-windows" "aarch64-linux" "riscv64-linux" ]; hostName = "nord.pbsds.net"; # TODO: port 24 diff --git a/profiles/shell/base.nix b/profiles/shell/base.nix index 08e4aa4..67f71ba 100644 --- a/profiles/shell/base.nix +++ b/profiles/shell/base.nix @@ -27,6 +27,8 @@ strace killall + + pciutils htop glances diff --git a/users/default.nix b/users/default.nix index ee83f7b..2cb58e5 100644 --- a/users/default.nix +++ b/users/default.nix @@ -3,7 +3,7 @@ #imports = [ ]; imports = [ inputs.home-manager.nixosModule ]; home-manager.useGlobalPkgs = true; # go brrr - #home-manager.useUserPackages = true # needed if VM, will also go a bit more brrr + #home-manager.useUserPackages = true # needed if VM, somewhat brrr, installs user packages to /etc instead of ~/.nix-profile # When adding a new user accounts: Don't forget to set a password with ‘passwd’! } diff --git a/users/pbsds/home/default.nix b/users/pbsds/home/default.nix index 2424990..568967e 100644 --- a/users/pbsds/home/default.nix +++ b/users/pbsds/home/default.nix @@ -116,6 +116,7 @@ manix-fzf = ''manix "" 2>/dev/null | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview="manix '{}'" | xargs manix''; # TODO: move to /run/user/... + # TODO: add --nom once released - https://github.com/Mic92/nixpkgs-review/pull/303 nixpkgs-review = ''mkdir -p /dev/shm/nixpkgs-review && ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review && nixpkgs-review''; }; diff --git a/users/pbsds/home/files/lxterminal.conf b/users/pbsds/home/files/lxterminal.conf index 22bb0e9..9625b19 100644 --- a/users/pbsds/home/files/lxterminal.conf +++ b/users/pbsds/home/files/lxterminal.conf @@ -1,6 +1,6 @@ [general] fontname=Monospace 14 -selchars=-A-Za-z0-9,./?%&#:_ +selchars=-A-Za-z0-9,./?%&#:_+ scrollback=5000 bgcolor=rgb(0,0,0) fgcolor=rgb(211,215,207) diff --git a/users/pbsds/home/profiles/bat.nix b/users/pbsds/home/profiles/bat.nix index 0cd221e..7c14ee8 100644 --- a/users/pbsds/home/profiles/bat.nix +++ b/users/pbsds/home/profiles/bat.nix @@ -2,12 +2,13 @@ { home.packages = with pkgs; [ bat - bat-extras.batman + #bat-extras.batman ]; # bat - TODO: condition these on programs.bat.enable ? home.shellAliases.cat = "bat --style=plain --paging=never"; - home.shellAliases.man = "batman"; + #home.shellAliases.man = "batman"; + home.shellAliases.man = "PAGER=${pkgs.most}/bin/most man"; # TODO: implement programs.bat.enableAliases programs.bat = { diff --git a/users/pbsds/home/profiles/ssh.nix b/users/pbsds/home/profiles/ssh.nix index 357e059..880375e 100644 --- a/users/pbsds/home/profiles/ssh.nix +++ b/users/pbsds/home/profiles/ssh.nix @@ -25,17 +25,18 @@ "gogs.*".forwardX11 = false; "git.*".forwardX11 = false; "*.pbsds.net".forwardX11 = true; + "*.pbsds.net".forwardX11Trusted = true; "*.ntnu.no".user = "pederbs"; "*.pvv.org".user = "pederbs"; "*.hpc.ntnu.no".proxyJump = "isvegg.pvv.ntnu.no"; "*.idi.ntnu.no".proxyJump = "isvegg.pvv.ntnu.no"; # me - "roxm.pbsds.net".proxyJump = "isvegg.pvv.ntnu.no"; - "noximilien.pbsds.net" = {}; "bolle.pbsds.net".proxyJump = "isvegg.pvv.ntnu.no"; "knut.pbsds.net".port = 23; "nord.pbsds.net".port = 24; + "noximilien.pbsds.net" = {}; + "rocm.pbsds.net".proxyJump = "isvegg.pvv.ntnu.no"; # ntnu "stud.ntnu.no".hostname = "login.stud.ntnu.no";