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

View File

@ -56,7 +56,7 @@
#}; #};
environment.systemPackages = [ environment.systemPackages = [
pkgs.nvtop-nvidia (pkgs.nvtopPackages.nvidia or pkgs.nvtop-nvidia)
] ++ lib.optionals config.hardware.nvidia.prime.offload.enable [ ] ++ lib.optionals config.hardware.nvidia.prime.offload.enable [
(pkgs.writeShellScriptBin "prime-run" '' (pkgs.writeShellScriptBin "prime-run" ''
export __NV_PRIME_RENDER_OFFLOAD=1 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 # assumes common-gpu-amd from nixos-hardware is also added
# TODO: should we move it from flake.nix to here? # TODO: should we move it from flake.nix to here?
@ -13,25 +13,53 @@
nixpkgs.config.vdpauSupport = true; nixpkgs.config.vdpauSupport = true;
nixpkgs.config.vaapiSupport = true; nixpkgs.config.vaapiSupport = true;
}
# nixos-hardware common-amd options # nixos-hardware common-amd options
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix # 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.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/ # 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 = [ "amdgpu" ]; # use gpu, adaptive sync and and hardware page flipping
#services.xserver.videoDrivers = [ "modesetting" ]; # integrated (non-accelerated) framebuffer, KMS (default in nixos-hardware) #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 systemd.tmpfiles.rules = let
hip = if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") rocmEnv = pkgs.symlinkJoin {
then pkgs.hip name = "rocm-combined";
else pkgs.rocmPackages.clr; paths = with pkgs.rocmPackages; [
in [ rocblas
"L+ /opt/rocm/hip - - - - ${hip}" hipblas
clr
];
};
in [ "L+ /opt/rocm - - - - ${rocmEnv}" ];
nixpkgs.overlays = [
(prev: final: {
blender = prev.blender-hip;
})
]; ];
environment.systemPackages = with pkgs; [ # enable opencl on polaris, (rx580)
nvtop-amd 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 #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? # TODO: remove? Move to where relevant?
nixpkgs.overlays = [ nixpkgs.overlays = [
/** / /** /

View File

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