This commit is contained in:
Peder Bergebakken Sundt 2023-03-19 04:23:38 +01:00
parent 9216212d12
commit 18488deb72
16 changed files with 102 additions and 76 deletions

8
.envrc
View File

@ -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
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

View File

@ -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)

View File

@ -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

110
flake.nix
View File

@ -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
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
'')
];
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 ]);
};
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
];
homeConfigurations = forAllSystems (system: let
mkHome = modules: home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
inherit modules;
};
remote = nixpkgs.legacyPackages.${system}.mkShell {
packages = with nixpkgs.legacyPackages.${system}; [
self.packages.${system}.remote-exec
yq
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
];
};
});
};

View File

@ -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}"

View File

@ -76,6 +76,8 @@
flat-remix-icon-theme
feh
zotero
firefox
];

View File

@ -1,12 +1,14 @@
{ lib
, fetchFromGitHub
, buildPythonApplication
# inputs
# runtime
, click
, toml
, pydantic
, watchdog
# testing
# check
, pytestCheckHook
, rsync
}:

View File

@ -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"

View File

@ -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;
};
};

View File

@ -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

View File

@ -27,6 +27,8 @@
strace
killall
pciutils
htop
glances

View File

@ -3,7 +3,7 @@
#imports = [ <home-manager/nixos> ];
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!
}

View File

@ -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'';
};

View File

@ -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)

View File

@ -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 = {

View File

@ -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";