This commit is contained in:
Peder Bergebakken Sundt 2024-07-04 02:16:29 +02:00
parent b6c1bdd2a0
commit 4a5acfcea4
5 changed files with 64 additions and 29 deletions

View File

@ -33,6 +33,7 @@
# https://github.com/NixOS/nixos-hardware
nixos-hardware.url = "github:NixOS/nixos-hardware";
nixos-hardware-2311.url = "github:NixOS/nixos-hardware/ae5c8dcc4d0182d07d75df2dc97112de822cb9d6"; # pre https://github.com/NixOS/nixos-hardware/pull/977
# https://github.com/tfc/nspawn-nixos
nixos-nspawn.url = "github:tfc/nspawn-nixos";
@ -49,9 +50,10 @@
# https://github.com/Mic92/sops-nix
sops-nix-edge.url = "github:Mic92/sops-nix";
sops-nix-edge.inputs.nixpkgs.follows = "nixpkgs-edge";
sops-nix-edge.inputs.nixpkgs-stable.follows = "nixpkgs-2311";
sops-nix-edge.inputs.nixpkgs-stable.follows = "nixpkgs-2405";
sops-nix-2405.url = "github:Mic92/sops-nix";
sops-nix-2405.inputs.nixpkgs.follows = "nixpkgs-2405";
sops-nix-2405.inputs.nixpkgs-stable.follows = "nixpkgs-2405";
sops-nix-2311.url = "github:Mic92/sops-nix";
sops-nix-2311.inputs.nixpkgs.follows = "nixpkgs-2311";
sops-nix-2311.inputs.nixpkgs-stable.follows = "nixpkgs-2311";
@ -100,6 +102,7 @@
outputs = {
self,
nixos-hardware,
nixos-hardware-2311,
nixos-nspawn,
nixos-generators-2311,
...
@ -168,14 +171,15 @@
imports = let ifExists = p: if builtins.pathExists p then p else {}; in [
./base.nix
(ifExists "${self}/hosts/${hostname}")
"${self}/hosts/${hostname}" # (ifExists "${self}/hosts/${hostname}")
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModule
#inputs.nix-index-database.nixosModules.nix-index
#inputs.nix-index-database.nixosModules.nix-index # TODO: fix?
] ++ modules ++ extra-modules;
#++ inputs.flake-programs-sqlite.nixosModules.programs-sqlite; # TODO: make work
sops.defaultSopsFile = lib.mkIf (builtins.pathExists ./secrets/${hostname}.yaml) ./secrets/${hostname}.yaml;
sops.defaultSopsFile = ./secrets/default.yaml;
#sops.defaultSopsFile = lib.mkIf (builtins.pathExists ./secrets/${hostname}.yaml) ./secrets/${hostname}.yaml;
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
sops.age.keyFile = "/var/lib/sops-nix/key.txt";
sops.age.generateKey = true;
@ -257,13 +261,14 @@
mkHosts = mk: let
ls = imports: { inherit imports; };
hw = nixos-hardware.nixosModules;
hw_ = nixos-hardware-2311.nixosModules;
#vf = nixos-vf2.nixosModules;
amd = ls [ hw.common-pc hw.common-pc-ssd hw.common-cpu-amd ];
intel = ls [ hw.common-pc hw.common-pc-ssd hw.common-cpu-intel ./hardware/gpu/intel.nix ];
intel-novga = ls [ hw.common-pc hw.common-pc-ssd hw.common-cpu-intel-cpu-only ];
cuda = ls [ ./hardware/gpu/cuda.nix hw.common-gpu-nvidia-nonprime ];
cuda-prime = ls [ ./hardware/gpu/cuda.nix hw.common-gpu-nvidia ];
rocm = ls [ ./hardware/gpu/rocm.nix hw.common-gpu-amd ];
rocm = ls [ ./hardware/gpu/rocm.nix hw_.common-gpu-amd ];
nspawn = ls [ "${nixos-nspawn}/nspawn-image.nix" { boot.isContainer = true; } ];
hidpi = hw.common-hidpi;
p1005 = ./hardware/printer/hp-laserjet-p1005.nix;

View File

@ -56,7 +56,7 @@
#};
environment.systemPackages = [
pkgs.nvtop-nvidia
(pkgs.nvtopPackages.nvidia or pkgs.nvtop-nvidia)
] ++ lib.optionals config.hardware.nvidia.prime.offload.enable [
(pkgs.writeShellScriptBin "prime-run" ''
export __NV_PRIME_RENDER_OFFLOAD=1

View File

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, options, ... }: lib.mkMerge [
{
# assumes common-gpu-amd from nixos-hardware is also added
# TODO: should we move it from flake.nix to here?
@ -13,25 +13,53 @@
nixpkgs.config.vdpauSupport = true;
nixpkgs.config.vaapiSupport = true;
# nixos-hardware common-amd options
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
}
# nixos-hardware common-amd options
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
(lib.mkIf (options ? hardware.amdgpu.opencl.enable) {
hardware.amdgpu.opencl.enable = lib.mkDefault true;
})
(lib.mkIf (!options ? hardware.amdgpu.opencl.enable) {
hardware.amdgpu.opencl = lib.mkDefault true;
hardware.amdgpu.amdvlk = lib.mkDefault false;
})
(lib.mkIf (options ? hardware.amdgpu.amdvlk.enable) {
#hardware.amdgpu.amdvlk.enable = lib.mkDefault true;
#hardware.amdgpu.amdvlk.support32Bit.enable = lib.mkDefault true;
})
{
# 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 (default in nixos-hardware)
# https://nixos.wiki/wiki/AMD_GPU#HIP
# https://wiki.nixos.org/wiki/AMD_GPU#HIP
systemd.tmpfiles.rules = let
hip = if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11")
then pkgs.hip
else pkgs.rocmPackages.clr;
in [
"L+ /opt/rocm/hip - - - - ${hip}"
rocmEnv = pkgs.symlinkJoin {
name = "rocm-combined";
paths = with pkgs.rocmPackages; [
rocblas
hipblas
clr
];
};
in [ "L+ /opt/rocm - - - - ${rocmEnv}" ];
nixpkgs.overlays = [
(prev: final: {
blender = prev.blender-hip;
})
];
environment.systemPackages = with pkgs; [
nvtop-amd
# enable opencl on polaris, (rx580)
environment.variables.ROC_ENABLE_PRE_VEGA = "1";
environment.systemPackages = [
(pkgs.nvtopPackages.amd or pkgs.nvtop-amd)
pkgs.lact
];
# lact - amdgpu GUI tool
systemd.packages = [ pkgs.lact ];
systemd.services.lactd.enable = true;
systemd.services.lactd.wantedBy = [ "multi-user.target" ]; # add this if you want the unit to auto start at boot time
}
]

View File

@ -103,6 +103,8 @@
#networking.wireguard.interfaces."wg0".ips = [ "172.22.48.3/24" ]; # fyrkat
sops.secrets.flexget.sopsFile = ../../secrets/${config.networking.hostName}.yaml;
# TODO: remove? Move to where relevant?
nixpkgs.overlays = [
/** /

View File

@ -6,15 +6,15 @@
services.nginx.virtualHosts.${mkDomain "cinny"} = {
forceSSL = true; # addSSL = true;
enableACME = true; #useACMEHost = acmeDomain;
# TODO: the override causes a rebuild which fails on low-RAM systems
root = pkgs.unstable.cinny.override {
conf = {
defaultHomeserver = 0;
homeserverList = [
"pvv.ntnu.no"
"matrix.org"
"dodsorf.as"
];
};
#conf = {
# defaultHomeserver = 0;
# homeserverList = [
# "pvv.ntnu.no"
# "matrix.org"
# ];
#};
};
};