This commit is contained in:
chayleaf 2023-04-11 00:58:02 +07:00
parent f6483d21e9
commit f296a8c337
16 changed files with 330 additions and 264 deletions

73
home/common/firefox.nix Normal file
View file

@ -0,0 +1,73 @@
{ config, pkgs, ... }:
/*let firefoxWithCcache = ({ useSccache, firefox-unwrapped }:
(firefox-unwrapped.override {
buildMozillaMach = (x: (pkgs.buildMozillaMach (x // {
extraConfigureFlags = x.extraConfigureFlags ++ [
(if useSccache then "--with-ccache=sccache" else "--with-ccache")
];
})));
}).overrideAttrs (prev: if useSccache then {
nativeBuildInputs = prev.nativeBuildInputs ++ [ pkgs.sccache ];
SCCACHE_DIR = "/var/cache/sccache";
SCCACHE_MAX_FRAME_LENGTH = "104857600";
RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
} else {
nativeBuildInputs = prev.nativeBuildInputs ++ [ pkgs.ccache ];
CCACHE_CPP2 = "yes";
CCACHE_COMPRESS = "1";
CCACHE_UMASK = "007";
CCACHE_DIR = "/var/cache/ccache";
})
); in*/
{
imports = [
./gui.nix
];
programs.firefox = {
enable = true;
package =
let
# TODO: remove this override soon (it's already upstreamed)
librewolf-unwrapped = pkgs.librewolf-unwrapped.overrideAttrs (prev: {
MOZ_REQUIRE_SIGNING = "";
});
in pkgs.wrapFirefox librewolf-unwrapped {
inherit (librewolf-unwrapped) extraPrefsFiles extraPoliciesFiles;
wmClass = "LibreWolf";
libName = "librewolf";
# TODO: keepass in extraNativeMessagingHosts?
};
profiles = {
chayleaf = {
extensions = with config.nur.repos.rycee.firefox-addons; [
cookies-txt
don-t-fuck-with-paste
greasemonkey
i-dont-care-about-cookies
keepassxc-browser
libredirect
localcdn
noscript
privacy-pass
protondb-for-steam
return-youtube-dislikes
rust-search-extension
search-by-image
sponsorblock
steam-database
ublock-origin
unpaywall
vimium-c
youtube-shorts-block
] ++ (with pkgs.firefox-addons; [
fastforward
middle-mouse-button-scroll
yomichan
youtube-nonstop
]);
};
};
};
}

View file

@ -1,116 +0,0 @@
{ config, pkgs, lib, ... }:
let firefoxWithCcache = ({ useSccache, firefox-unwrapped }:
(firefox-unwrapped.override {
buildMozillaMach = (x: (pkgs.buildMozillaMach (x // {
extraConfigureFlags = x.extraConfigureFlags ++ [
(if useSccache then "--with-ccache=sccache" else "--with-ccache")
];
})));
}).overrideAttrs (prev: if useSccache then {
nativeBuildInputs = prev.nativeBuildInputs ++ [ pkgs.sccache ];
SCCACHE_DIR = "/var/cache/sccache";
SCCACHE_MAX_FRAME_LENGTH = "104857600";
RUSTC_WRAPPER = "${pkgs.sccache}/bin/sccache";
} else {
nativeBuildInputs = prev.nativeBuildInputs ++ [ pkgs.ccache ];
CCACHE_CPP2 = "yes";
CCACHE_COMPRESS = "1";
CCACHE_UMASK = "007";
CCACHE_DIR = "/var/cache/ccache";
})
); in {
imports = [
../gui.nix
];
programs.firefox = {
enable = true;
package =
let librewolf-unwrapped = firefoxWithCcache {
useSccache = true;
firefox-unwrapped = pkgs.librewolf-unwrapped.overrideAttrs (prev: {
MOZ_REQUIRE_SIGNING = "";
});
};
in pkgs.wrapFirefox librewolf-unwrapped {
inherit (librewolf-unwrapped) extraPrefsFiles extraPoliciesFiles;
wmClass = "LibreWolf";
libName = "librewolf";
# TODO: keepass in extraNativeMessagingHosts?
};
profiles = {
chayleaf = {
extensions =
with config.nur.repos.rycee.firefox-addons;
let sources = (import ../../_sources/generated.nix {
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
});
# addons.mozilla.org's version is horribly outdated for whatever reason
# I guess the extension normally autoupdates by itself?
# this is an unsigned build
yomichan = pkgs.stdenvNoCC.mkDerivation {
inherit (sources.yomichan) pname version src;
preferLocalBuild = true;
allowSubstitutes = true;
buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst"
install -v -m644 "$src" "$dst/alex.testing@foosoft.net.xpi"
'';
meta = with lib; {
homepage = "https://foosoft.net/projects/yomichan";
description = "Yomichan turns your browser into a tool for building Japanese language literacy by helping you to decipher texts which would be otherwise too difficult tackle. It features a robust dictionary with EPWING and flashcard creation support.";
license = licenses.gpl3;
platforms = platforms.all;
};
};
fastforward = pkgs.stdenvNoCC.mkDerivation {
inherit (sources.fastforward) pname version src;
preferLocalBuild = true;
allowSubstitutes = true;
buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst"
install -v -m644 "$src" "$dst/addon@fastforward.team"
'';
meta = with lib; {
homepage = "https://fastforward.team";
description = "Don't waste time with compliance. Use FastForward to skip annoying URL \"shorteners\"";
license = licenses.unlicense;
platforms = platforms.all;
};
};
in with (import ./generated.nix {
inherit lib stdenv fetchurl buildFirefoxXpiAddon;
});
[
# from rycee's repo
youtube-shorts-block
vimium-c
search-by-image
unpaywall
ublock-origin
steam-database
sponsorblock
rust-search-extension
return-youtube-dislikes
protondb-for-steam
libredirect
privacy-pass
noscript
localcdn
keepassxc-browser
i-dont-care-about-cookies
greasemonkey
don-t-fuck-with-paste
cookies-txt
fastforward
# my packages
yomichan
youtube-nonstop
middle-mouse-button-scroll
];
};
};
};
}

View file

@ -20,11 +20,11 @@
# SDL 3 # SDL 3
SDL_AUDIO_DRIVER = "pipewire,pulseaudio,dsound"; SDL_AUDIO_DRIVER = "pipewire,pulseaudio,dsound";
ALSOFT_CONF = "${config.xdg.configHome}/.config/alsoft.conf"; ALSOFT_CONF = "${config.xdg.configHome}/.config/alsoft.conf";
# TODO: set to sdl3 compat when SDL3 releases # TODO: set to sdl3 compat when SDL3 releases?
# this is for steam games, I set the launch options to: # this is for steam games, I set the launch options to:
# `SDL_DYNAMIC_API=$SDL2_DYNAMIC_API %command%` # `SDL_DYNAMIC_API=$SDL2_DYNAMIC_API %command%`
# Steam itself doesn't work with SDL_DYNAMIC_API set, so it's # Steam itself doesn't work with SDL2_DYNAMIC_API set, so it's
# a bad idea to set SDL_DYNAMIC_API globally # a bad idea to set SDL2_DYNAMIC_API globally
SDL2_DYNAMIC_API = "${pkgs.SDL2}/lib/libSDL2.so"; SDL2_DYNAMIC_API = "${pkgs.SDL2}/lib/libSDL2.so";
}; };
programs.nnn.extraPackages = with pkgs; [ programs.nnn.extraPackages = with pkgs; [
@ -181,42 +181,11 @@
# webp support # webp support
ffmpeg_5 = pkgs.ffmpeg_5-full; ffmpeg_5 = pkgs.ffmpeg_5-full;
}) { }) {
scripts = scripts = with pkgs.mpvScripts; [
let subserv = (port: secondary:
(pkgs.stdenv.mkDerivation {
pname = "subserv-mpv-plugin";
version = "0.1";
src = pkgs.fetchFromGitHub {
owner = "kaervin";
repo = "subserv-mpv-plugin";
rev = "08e312f02f3d3608d61944247d39148c34215f75";
sha256 = "sha256-CXyp+AAgyocAEbhuMMPVDlAiocozPe8tm/dIUofCRL8=";
};
buildInputs = with pkgs; [ mpv-unwrapped ];
installFlags = [ "SCRIPTS_DIR=$(out)/share/mpv/scripts" ];
stripDebugList = [ "share/mpv/scripts" ];
passthru.scriptName = "subserv.so";
patchPhase = ''
sed -i 's%<client.h>%<mpv/client.h>%' subserv.c
sed -i 's%printf("Hello%// printf("Hello%' subserv.c
sed -i 's%printf("Got event%// printf("Got event%' subserv.c
sed -i 's/PORT 8080/PORT ${builtins.toString port}/' subserv.c
'' + (if secondary then ''
sed -i 's/sub-text/secondary-sub-text/g' subserv.c
'' else "");
buildPhase = ''
gcc -o subserv.so subserv.c -shared -fPIC
'';
installPhase = ''
mkdir -p $out/share/mpv/scripts
cp subserv.so $out/share/mpv/scripts
'';
}));
in with pkgs.mpvScripts; [
thumbnail thumbnail
mpris mpris
(subserv 1337 false) (subserv.override { port = 1337; secondary = false; })
(subserv 1338 true) (subserv.override { port = 1338; secondary = true; })
]; ];
}; };
}; };

View file

@ -39,7 +39,13 @@
]; ];
overlays = [ overlays = [
(self: super: import ./pkgs { (self: super: import ./pkgs {
# can't use callPackage here, idk why
pkgs = super; pkgs = super;
lib = super.lib;
nur = import nur {
pkgs = super;
nurpkgs = super;
};
}) })
nix-gaming.overlays.default nix-gaming.overlays.default
]; ];

View file

@ -1,8 +1,8 @@
{ config, pkgs, lib, pkgs-wayland, ... }: { pkgs, lib, ... }:
{ {
imports = [ imports = [
../common/general.nix ../common/general.nix
../common/firefox ../common/firefox.nix
../common/i3-sway.nix ../common/i3-sway.nix
../common/nvim.nix ../common/nvim.nix
../common/helix.nix ../common/helix.nix
@ -37,18 +37,8 @@
"steamcmd" "steamcmd"
"osu-lazer-bin" "osu-lazer-bin"
]; ];
home.sessionVariables = let sources = (import ../_sources/generated.nix { home.sessionVariables = {
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools; STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${pkgs.proton-ge}";
});
proton-ge = pkgs.stdenvNoCC.mkDerivation {
inherit (sources.proton-ge) pname version src;
nativeBuildInputs = [];
installPhase = ''
mkdir -p $out
tar -C $out --strip=1 -x -f $src
'';
}; in {
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${proton-ge}";
CARGO_PROFILE_DEV_INCREMENTAL = "true"; CARGO_PROFILE_DEV_INCREMENTAL = "true";
RUSTC_LINKER = "${pkgs.clang_latest}/bin/clang"; RUSTC_LINKER = "${pkgs.clang_latest}/bin/clang";
RUSTFLAGS = "-C link-arg=--ld-path=${pkgs.mold}/bin/mold"; RUSTFLAGS = "-C link-arg=--ld-path=${pkgs.mold}/bin/mold";
@ -57,9 +47,7 @@
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
mold mold
(ghidra.overrideAttrs (old: { ghidra cutter
patches = old.patches ++ [ ../common/ghidra-stdcall.patch ];
})) cutter
openrgb piper openrgb piper
steam-run steam steam-run steam
((osu-lazer-bin.override { ((osu-lazer-bin.override {
@ -104,19 +92,7 @@
mediainfo mediainfo
glaxnimate glaxnimate
lalrpop lalrpop
# waiting until the PR gets merged looking-glass-client
(looking-glass-client.overrideAttrs (old: {
version = "B6";
src = fetchFromGitHub {
owner = "gnif";
repo = "LookingGlass";
rev = "B6";
sha256 = "sha256-6vYbNmNJBCoU23nVculac24tHqH7F4AZVftIjL93WJU=";
fetchSubmodules = true;
};
buildInputs = old.buildInputs ++ (with pkgs; [ pipewire libsamplerate ]);
cmakeFlags = old.cmakeFlags ++ [ "-DENABLE_PULSEAUDIO=no" ];
}))
]; ];
xdg.configFile."looking-glass/client.ini".text = '' xdg.configFile."looking-glass/client.ini".text = ''
[app] [app]

View file

@ -1,8 +1,43 @@
{ pkgs, ... }: let inherit (pkgs) callPackage; in { { pkgs
, lib
, nur
, ... }:
let
inherit (pkgs) callPackage;
sources = import ../_sources/generated.nix {
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
};
in
{
clang-tools_latest = pkgs.clang-tools_15; clang-tools_latest = pkgs.clang-tools_15;
clang_latest = pkgs.clang_15; clang_latest = pkgs.clang_15;
home-daemon = callPackage ./home-daemon { }; home-daemon = callPackage ./home-daemon { };
ghidra = pkgs.ghidra.overrideAttrs (old: {
patches = old.patches ++ [ ./ghidra-stdcall.patch ];
});
lalrpop = callPackage ./lalrpop { }; lalrpop = callPackage ./lalrpop { };
# pin version
looking-glass-client = pkgs.looking-glass-client.overrideAttrs (old: {
version = "B6";
src = pkgs.fetchFromGitHub {
owner = "gnif";
repo = "LookingGlass";
rev = "B6";
sha256 = "sha256-6vYbNmNJBCoU23nVculac24tHqH7F4AZVftIjL93WJU=";
fetchSubmodules = true;
};
});
proton-ge = pkgs.stdenvNoCC.mkDerivation {
inherit (sources.proton-ge) pname version src;
installPhase = ''
mkdir -p $out
tar -C $out --strip=1 -x -f $src
'';
};
rofi-steam-game-list = callPackage ./rofi-steam-game-list { }; rofi-steam-game-list = callPackage ./rofi-steam-game-list { };
techmino = callPackage ./techmino { }; techmino = callPackage ./techmino { };
firefox-addons = lib.recurseIntoAttrs (callPackage ./firefox-addons { inherit nur sources; });
mpvScripts = pkgs.mpvScripts // (callPackage ./mpv-scripts { });
} }

View file

@ -0,0 +1,48 @@
{ pkgs
, lib
, stdenv
, fetchurl
, nur
, sources
, ... }:
let
buildExtension = { pname, version, src, id, meta ? { } }: pkgs.stdenvNoCC.mkDerivation {
inherit pname version src meta;
preferLocalBuild = true;
allowSubstitutes = true;
buildCommand = ''
dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
mkdir -p "$dst"
install -v -m644 "$src" "$dst/"'${id}'
'';
};
in
(import ./generated.nix {
inherit lib stdenv fetchurl;
inherit (nur.repos.rycee.firefox-addons) buildFirefoxXpiAddon;
}) // {
# addons.mozilla.org's version is horribly outdated for whatever reason
# I guess the extension normally autoupdates by itself?
# this is an unsigned build
yomichan = buildExtension {
inherit (sources.yomichan) pname version src;
id = "alex.testing@foosoft.net.xpi";
meta = with lib; {
homepage = "https://foosoft.net/projects/yomichan";
description = "Yomichan turns your browser into a tool for building Japanese language literacy by helping you to decipher texts which would be otherwise too difficult tackle. It features a robust dictionary with EPWING and flashcard creation support";
license = licenses.gpl3;
platforms = platforms.all;
};
};
fastforward = buildExtension {
inherit (sources.fastforward) pname version src;
id = "addon@fastforward.team";
meta = with lib; {
homepage = "https://fastforward.team";
description = "Don't waste time with compliance. Use FastForward to skip annoying URL \"shorteners\"";
license = licenses.unlicense;
platforms = platforms.all;
};
};
}

View file

@ -0,0 +1,6 @@
{ callPackage
, ... }:
{
subserv = callPackage ./subserv.nix { };
}

View file

@ -0,0 +1,36 @@
{ stdenv
, fetchFromGitHub
, mpv-unwrapped
, port ? 1337
, secondary ? false
, ... }:
stdenv.mkDerivation {
pname = "subserv-mpv-plugin";
version = "0.1";
src = fetchFromGitHub {
owner = "kaervin";
repo = "subserv-mpv-plugin";
rev = "08e312f02f3d3608d61944247d39148c34215f75";
sha256 = "sha256-CXyp+AAgyocAEbhuMMPVDlAiocozPe8tm/dIUofCRL8=";
};
buildInputs = [ mpv-unwrapped ];
installFlags = [ "SCRIPTS_DIR=$(out)/share/mpv/scripts" ];
stripDebugList = [ "share/mpv/scripts" ];
passthru.scriptName = "subserv.so";
patchPhase = ''
sed -i 's%<client.h>%<mpv/client.h>%' subserv.c
sed -i 's%printf("Hello%// printf("Hello%' subserv.c
sed -i 's%printf("Got event%// printf("Got event%' subserv.c
sed -i 's/PORT 8080/PORT ${builtins.toString port}/' subserv.c
'' + (if secondary then ''
sed -i 's/sub-text/secondary-sub-text/g' subserv.c
'' else "");
buildPhase = ''
gcc -o subserv.so subserv.c -shared -fPIC
'';
installPhase = ''
mkdir -p $out/share/mpv/scripts
cp subserv.so $out/share/mpv/scripts
'';
}

View file

@ -1,16 +1,18 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ let
cfg = config.vfio;
in {
options.vfio = with lib; mkOption { options.vfio = with lib; mkOption {
type = types.submodule { type = types.submodule {
options = { options = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable AMD GPU passthrough config (no intel/nvidia support since I can't test it)"; description = "Enable GPU passthrough config (probably no intel/nvidia support since I can't test it)";
}; };
libvirtdGroup = mkOption { libvirtdGroup = mkOption {
type = with types; listOf str; type = with types; listOf str;
default = ["user"]; default = [ ];
description = "Users to add to libvirtd group"; description = "Users to add to libvirtd group";
}; };
intelCpu = mkOption { intelCpu = mkOption {
@ -18,6 +20,11 @@
default = false; default = false;
description = "Whether the CPU is Intel (untested)"; description = "Whether the CPU is Intel (untested)";
}; };
nvidiaGpu = mkOption {
type = types.bool;
default = false;
description = "Whether the GPU is Nvidia (disables AMD-specific workarounds)";
};
passGpuAtBoot = mkOption { passGpuAtBoot = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -50,28 +57,43 @@
}; };
}; };
}); });
default = []; default = if builtins.length cfg.libvirtdGroup == 1 then [
{ owner = builtins.head cfg.libvirtdGroup; }
] else [ ];
example = [ { size = 32; owner = "user"; } ]; example = [ { size = 32; owner = "user"; } ];
description = "IVSHMEM/kvmfr config (multiple devices can be created: /dev/kvmfr0, /dev/kvmfr1, and so on)"; description = "IVSHMEM/kvmfr config (multiple devices can be created: /dev/kvmfr0, /dev/kvmfr1, and so on)";
}; };
}; };
}; };
default = {};
description = "Looking glass config"; description = "Looking glass config";
}; };
}; };
}; };
default = {};
description = "VFIO settings"; description = "VFIO settings";
}; };
config = lib.mkIf config.vfio.enable config = lib.mkIf config.vfio.enable
(let (let
cfg = config.vfio;
gpuIDs = lib.concatStringsSep "," cfg.pciIDs; gpuIDs = lib.concatStringsSep "," cfg.pciIDs;
enableIvshmem = config.vfio.lookingGlass.enable && (builtins.length config.vfio.lookingGlass.ivshmem) > 0; enableIvshmem = config.vfio.lookingGlass.enable && (builtins.length config.vfio.lookingGlass.ivshmem) > 0;
in { in {
# add a custom kernel param for early loading vfio drivers
# because if we change boot.initrd options in a specialization, two initrds will be built
# and we don't want to build two initrds
specialisation.vfio.configuration = lib.mkIf (!cfg.passGpuAtBoot) { specialisation.vfio.configuration = lib.mkIf (!cfg.passGpuAtBoot) {
boot.kernelParams = [ "early_load_vfio" ]; boot.kernelParams = [ "early_load_vfio" ];
# I can't enable early KMS with VFIO, so this will have to do
# (amdgpu resets the font upon being loaded)
systemd.services."systemd-vconsole-setup2" = lib.mkIf (!cfg.nvidiaGpu) {
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.systemd}/lib/systemd/systemd-vconsole-setup";
};
wantedBy = [ "graphical.target" ];
wants = [ "multi-user.target" ];
after = [ "multi-user.target" ];
};
}; };
boot = { boot = {
initrd.postDeviceCommands = lib.mkIf (!cfg.passGpuAtBoot) '' initrd.postDeviceCommands = lib.mkIf (!cfg.passGpuAtBoot) ''
@ -86,6 +108,9 @@
modprobe vfio modprobe vfio
modprobe vfio_iommu_type1 modprobe vfio_iommu_type1
modprobe vfio_pci modprobe vfio_pci
${if cfg.nvidiaGpu then "" else ''
else
modprobe amdgpu''}
fi fi
''; '';
initrd.kernelModules = [ initrd.kernelModules = [
@ -103,12 +128,12 @@
extraModulePackages = extraModulePackages =
with config.boot.kernelPackages; with config.boot.kernelPackages;
lib.mkIf enableIvshmem [ kvmfr ]; lib.mkIf enableIvshmem [ kvmfr ];
extraModprobeConfig = let ivshmemConfig = if enableIvshmem then '' extraModprobeConfig = ''
options kvmfr static_size_mb=${lib.concatStringsSep "," (map (x: toString x.size) cfg.lookingGlass.ivshmem)}
'' else ""; in ''
options vfio-pci ids=${gpuIDs} disable_idle_d3=1 options vfio-pci ids=${gpuIDs} disable_idle_d3=1
options kvm ignore_msrs=1 options kvm ignore_msrs=1
${ivshmemConfig} ${if enableIvshmem then ''
options kvmfr static_size_mb=${lib.concatStringsSep "," (map (x: toString x.size) cfg.lookingGlass.ivshmem)}''
else ""}
''; '';
kernelParams = [ kernelParams = [
(if cfg.intelCpu then "intel_iommu=on" else "amd_iommu=on") (if cfg.intelCpu then "intel_iommu=on" else "amd_iommu=on")
@ -119,7 +144,7 @@
] ++ (if enableIvshmem then [ "kvmfr" ] else []); ] ++ (if enableIvshmem then [ "kvmfr" ] else []);
}; };
services.udev.extraRules = lib.mkIf enableIvshmem services.udev.extraRules = lib.mkIf enableIvshmem
(lib.concatStringsSep (builtins.concatStringsSep
"\n" "\n"
(lib.imap0 (lib.imap0
(i: ivshmem: '' (i: ivshmem: ''
@ -127,7 +152,7 @@
'') '')
cfg.lookingGlass.ivshmem)); cfg.lookingGlass.ivshmem));
# disable early KMS so GPU can be properly unbound # disable early KMS so GPU can be properly unbound
hardware.amdgpu.loadInInitrd = false; hardware.amdgpu.loadInInitrd = lib.mkIf (!cfg.nvidiaGpu) false;
hardware.opengl.enable = true; hardware.opengl.enable = true;
# needed for virt-manager # needed for virt-manager
programs.dconf.enable = true; programs.dconf.enable = true;

View file

@ -35,6 +35,7 @@
generateRegistryFromInputs = true; generateRegistryFromInputs = true;
linkInputs = true; linkInputs = true;
}; };
nixpkgs.overlays = [(self: super: import ./pkgs { pkgs = super; })];
} }
]; ];
hosts = { hosts = {

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, nixpkgs, ... }: { lib, pkgs, ... }:
let let
efiPart = "/dev/disk/by-uuid/D77D-8CE0"; efiPart = "/dev/disk/by-uuid/D77D-8CE0";
@ -13,6 +13,7 @@ in {
system.stateVersion = "22.11"; system.stateVersion = "22.11";
### SECTION 1: HARDWARE/BOOT PARAMETERS ### ### SECTION 1: HARDWARE/BOOT PARAMETERS ###
boot = { boot = {
initrd = { initrd = {
availableKernelModules = [ "nvme" "xhci_pci" ]; availableKernelModules = [ "nvme" "xhci_pci" ];
@ -66,6 +67,8 @@ in {
}; };
kernelPackages = lib.mkDefault pkgs.linuxPackages_zen; kernelPackages = lib.mkDefault pkgs.linuxPackages_zen;
}; };
# for testing different zen kernel versions:
# specialisation = let # specialisation = let
# zenKernels = pkgs.callPackage "${nixpkgs}/pkgs/os-specific/linux/kernel/zen-kernels.nix"; # zenKernels = pkgs.callPackage "${nixpkgs}/pkgs/os-specific/linux/kernel/zen-kernels.nix";
# zenKernel = (version: sha256: (zenKernels { # zenKernel = (version: sha256: (zenKernels {
@ -87,28 +90,28 @@ in {
# in { # in {
# zen619.configuration.boot.kernelPackages = pkgs.linuxPackagesFor (zenKernel "6.1.9" "0fsmcjsawxr32fxhpp6sgwfwwj8kqymy0rc6vh4qli42fqmwdjgv"); # zen619.configuration.boot.kernelPackages = pkgs.linuxPackagesFor (zenKernel "6.1.9" "0fsmcjsawxr32fxhpp6sgwfwwj8kqymy0rc6vh4qli42fqmwdjgv");
# }; # };
nixpkgs.config.allowUnfreePredicate = pkg: (lib.getName pkg) == "steam-original"; nixpkgs.config.allowUnfreePredicate = pkg: (lib.getName pkg) == "steam-original";
console.font = "${pkgs.terminus_font}/share/consolefonts/ter-v32n.psf.gz";
hardware = { hardware = {
steam-hardware.enable = true; steam-hardware.enable = true;
enableRedistributableFirmware = true; enableRedistributableFirmware = true;
opengl.driSupport32Bit = true; opengl.driSupport32Bit = true;
# sway WLR_RENDERER=vulkan # needed for sway WLR_RENDERER=vulkan
opengl.extraPackages = with pkgs; [ vulkan-validation-layers ]; opengl.extraPackages = with pkgs; [ vulkan-validation-layers ];
}; };
services.tlp.settings = { services.tlp.settings = {
USB_DENYLIST = "0bda:8156";
USB_EXCLUDE_PHONE = 1; USB_EXCLUDE_PHONE = 1;
START_CHARGE_THRESH_BAT0 = 75; START_CHARGE_THRESH_BAT0 = 75;
STOP_CHARGE_THRESH_BAT0 = 80; STOP_CHARGE_THRESH_BAT0 = 80;
# fix for my realtek usb ethernet adapter
USB_DENYLIST = "0bda:8156";
}; };
# see common/vfio.nix # see common/vfio.nix
vfio.enable = true; vfio.enable = true;
vfio.pciIDs = [ "1002:73df" "1002:ab28" ]; vfio.pciIDs = [ "1002:73df" "1002:ab28" ];
vfio.libvirtdGroup = [ "user" ]; vfio.libvirtdGroup = [ "user" ];
vfio.lookingGlass.ivshmem = [{ owner = "user"; }];
fileSystems = let fileSystems = let
device = cryptroot; device = cryptroot;
@ -130,6 +133,7 @@ in {
options = [ discard "subvol=@swap" "noatime" ]; }; options = [ discard "subvol=@swap" "noatime" ]; };
"/home" = { inherit device fsType; "/home" = { inherit device fsType;
options = [ discard compress "subvol=@home" ]; }; options = [ discard compress "subvol=@home" ]; };
# why am I even bothering with creating this subvolume every time if I don't use snapshots anyway?
"/.snapshots" = "/.snapshots" =
{ inherit device fsType; { inherit device fsType;
options = [ discard compress "subvol=@snapshots" ]; }; options = [ discard compress "subvol=@snapshots" ]; };
@ -181,23 +185,75 @@ in {
swapDevices = [ { device = "/swap/swapfile"; } ]; swapDevices = [ { device = "/swap/swapfile"; } ];
services.ratbagd.enable = true; # dedupe
services.beesd = {
# i have a lot of ram :tonystark:
filesystems.cryptroot = {
spec = "UUID=${cryptrootUuid}";
hashTableSizeMB = 128;
extraOptions = [ "--loadavg-target" "8.0" ];
};
filesystems.dataroot = {
spec = "UUID=${datarootUuid}";
hashTableSizeMB = 256;
extraOptions = [ "--loadavg-target" "8.0" ];
};
};
### SECTION 2: SYSTEM CONFIG/ENVIRONMENT ### ### SECTION 2: SYSTEM CONFIG/ENVIRONMENT ###
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8"; i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
i18n.supportedLocales = lib.mkDefault [ "en_US.UTF-8/UTF-8" ]; i18n.supportedLocales = lib.mkDefault [
"C.UTF-8/UTF-8"
"en_US.UTF-8/UTF-8"
"en_DK.UTF-8/UTF-8"
];
# ISO-8601
i18n.extraLocaleSettings.LC_TIME = "en_DK.UTF-8";
console.font = "${pkgs.terminus_font}/share/consolefonts/ter-v32n.psf.gz";
networking.useDHCP = true; networking.useDHCP = true;
# networking.firewall.enable = false; # networking.firewall.enable = false;
# KDE connect: 1714-1764 # KDE connect: 1714-1764
networking.firewall.allowedTCPPorts = [ 27015 25565 7777 ] ++ (builtins.genList (x: 1714 + x) (1764 - 1714 + 1)); networking.firewall.allowedTCPPorts = [
networking.firewall.allowedUDPPorts = (builtins.genList (x: 1714 + x) (1764 - 1714 + 1)); 27015
25565
7777
]
# kde connect
++ (lib.range 1714 1764);
networking.firewall.allowedUDPPorts = lib.range 1714 1764;
# networking.hostName = "nixmsi"; # networking.hostName = "nixmsi";
networking.wireless.iwd.enable = true; networking.wireless.iwd.enable = true;
#networking.networkmanager.enable = true; #networking.networkmanager.enable = true;
services.ratbagd.enable = true;
services.mullvad-vpn.enable = true; services.mullvad-vpn.enable = true;
services.mullvad-vpn.package = pkgs.mullvad-vpn; services.mullvad-vpn.package = pkgs.mullvad-vpn;
# System76 scheduler (not actually a scheduler, just a renice daemon) for improved responsiveness
services.dbus.packages = [ pkgs.system76-scheduler ];
systemd.services."system76-scheduler" = {
description = "Automatically configure CPU scheduler for responsiveness on AC";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "dbus";
BusName= "com.system76.Scheduler";
ExecStart = "${pkgs.system76-scheduler}/bin/system76-scheduler daemon";
ExecReload = "${pkgs.system76-scheduler}/bin/system76-scheduler daemon reload";
};
};
environment.etc."system76-scheduler/assignments.ron".source =
"${pkgs.system76-scheduler}/etc/system76-scheduler/assignments.ron";
environment.etc."system76-scheduler/config.ron".source =
"${pkgs.system76-scheduler}/etc/system76-scheduler/config.ron";
environment.etc."system76-scheduler/exceptions.ron".source =
"${pkgs.system76-scheduler}/etc/system76-scheduler/exceptions.ron";
# i wanted to be able to use both x and wayland... but honestly wayland is enough for me
services.xserver.libinput.enable = true;
/*
services.xserver = { services.xserver = {
enable = true; enable = true;
libinput.enable = true; libinput.enable = true;
@ -205,7 +261,7 @@ in {
# I couldn't get lightdm to start sway, so let's just do this # I couldn't get lightdm to start sway, so let's just do this
displayManager.startx.enable = true; displayManager.startx.enable = true;
windowManager.i3.enable = true; windowManager.i3.enable = true;
}; };*/
programs.sway.enable = true; programs.sway.enable = true;
programs.firejail.enable = true; programs.firejail.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -215,8 +271,11 @@ in {
man-pages man-pages-posix man-pages man-pages-posix
]; ];
services.dbus.enable = true; services.dbus.enable = true;
# I don't remember whether I really need this...
security.polkit.enable = true; security.polkit.enable = true;
services.printing.enable = true; services.printing.enable = true;
# pipewire:
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
enable = true; enable = true;
@ -289,57 +348,7 @@ in {
# why is this not part of base NixOS? # why is this not part of base NixOS?
systemd.tmpfiles.rules = [ "d /var/lib/systemd/pstore 0755 root root 14d" ]; systemd.tmpfiles.rules = [ "d /var/lib/systemd/pstore 0755 root root 14d" ];
# dedupe
services.beesd = {
# i have a lot of ram :tonystark:
filesystems.cryptroot = {
spec = "UUID=${cryptrootUuid}";
hashTableSizeMB = 128;
extraOptions = [ "--loadavg-target" "8.0" ];
};
filesystems.dataroot = {
spec = "UUID=${datarootUuid}";
hashTableSizeMB = 256;
extraOptions = [ "--loadavg-target" "8.0" ];
};
};
# System76 scheduler (not actually a scheduler, just a renice daemon) for improved responsiveness
services.dbus.packages = [ pkgs.system76-scheduler ];
systemd.services."system76-scheduler" = {
description = "Automatically configure CPU scheduler for responsiveness on AC";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "dbus";
BusName= "com.system76.Scheduler";
ExecStart = "${pkgs.system76-scheduler}/bin/system76-scheduler daemon";
ExecReload = "${pkgs.system76-scheduler}/bin/system76-scheduler daemon reload";
};
};
environment.etc."system76-scheduler/assignments.ron".source =
lib.mkOptionDefault "${pkgs.system76-scheduler}/etc/system76-scheduler/assignments.ron";
environment.etc."system76-scheduler/config.ron".source =
lib.mkOptionDefault "${pkgs.system76-scheduler}/etc/system76-scheduler/config.ron";
environment.etc."system76-scheduler/exceptions.ron".source =
lib.mkOptionDefault "${pkgs.system76-scheduler}/etc/system76-scheduler/exceptions.ron";
# I can't enable early KMS with VFIO, so this will have to do
# (amdgpu resets the font upon being loaded)
systemd.services."systemd-vconsole-setup2" = {
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.systemd}/lib/systemd/systemd-vconsole-setup";
};
wantedBy = ["graphical.target"];
wants = ["multi-user.target"];
after = ["multi-user.target"];
};
# autologin once after boot # autologin once after boot
# --skip-login means directly call login instead of first asking for username # --skip-login means directly call login instead of first asking for username
# (normally login asks for username too, but getty prefers to do it by itself for whatever reason) # (normally login asks for username too, but getty prefers to do it by itself for whatever reason)
services.getty.extraArgs = ["--skip-login"]; services.getty.extraArgs = ["--skip-login"];
@ -354,10 +363,5 @@ in {
exec ${shadow}/bin/login -f user exec ${shadow}/bin/login -f user
fi fi
''; '';
# overlays
nixpkgs.overlays = [(self: super: {
system76-scheduler = super.callPackage ../pkgs/system76-scheduler.nix { };
})];
} }

3
system/pkgs/default.nix Normal file
View file

@ -0,0 +1,3 @@
{ pkgs, ... }: let inherit (pkgs) callPackage; in {
system76-scheduler = callPackage ../pkgs/system76-scheduler.nix { };
}