diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..36b1e04 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "tinymist.fontPaths": ["home-manager/bsod"] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ce58c6 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# nixos config + +## known bugs: +- $TMP pointing to a non-existing directory with direnv: https://github.com/direnv/direnv/issues/1345 + broke because of a nix update, probably because direnv is using nix shell weirdly \ No newline at end of file diff --git a/custom-pkgs/cargo-bisect-rustc/0001-patchelf.patch b/custom-pkgs/cargo-bisect-rustc/0001-patchelf.patch new file mode 100644 index 0000000..7bbf5ce --- /dev/null +++ b/custom-pkgs/cargo-bisect-rustc/0001-patchelf.patch @@ -0,0 +1,64 @@ +diff --git a/src/toolchains.rs b/src/toolchains.rs +index a4be8cd..95e9d16 100644 +--- a/src/toolchains.rs ++++ b/src/toolchains.rs +@@ -19,6 +19,49 @@ use xz2::read::XzDecoder; + + use crate::{Config, GitDate}; + ++fn nix_patchelf(mut toolchain_path: PathBuf) -> Result<(), io::Error> { ++ toolchain_path.push("bin"); ++ ++ for entry in toolchain_path.read_dir()? { ++ let entry = entry?; ++ if !entry.file_type()?.is_file() { ++ continue; ++ } ++ ++ eprintln!( ++ "info: you seem to be running NixOS. Attempting to patch {}", ++ entry.path().to_str().unwrap() ++ ); ++ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf") ++ .arg("--set-interpreter") ++ .arg("@dynamicLinker@") ++ .arg(entry.path()) ++ .output(); ++ } ++ ++ toolchain_path.pop(); ++ toolchain_path.push("lib"); ++ ++ for entry in toolchain_path.read_dir()? { ++ let entry = entry?; ++ if !entry.file_type()?.is_file() { ++ continue; ++ } ++ ++ eprintln!( ++ "info: you seem to be running NixOS. Attempting to patch {}", ++ entry.path().to_str().unwrap() ++ ); ++ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf") ++ .arg("--set-rpath") ++ .arg("@libPath@") ++ .arg(entry.path()) ++ .output(); ++ } ++ ++ Ok(()) ++} ++ + pub const YYYY_MM_DD: &str = "%Y-%m-%d"; + + pub(crate) const NIGHTLY_SERVER: &str = "https://static.rust-lang.org/dist"; +@@ -208,7 +251,8 @@ impl Toolchain { + })?; + } + +- fs::rename(tmpdir.keep(), dest).map_err(InstallError::Move) ++ fs::rename(tmpdir.into_path(), &dest).map_err(InstallError::Move)?; ++ nix_patchelf(dest).map_err(InstallError::Move) + } + + pub(crate) fn remove(&self, dl_params: &DownloadParams) -> io::Result<()> { diff --git a/custom-pkgs/cargo-bisect-rustc/default.nix b/custom-pkgs/cargo-bisect-rustc/default.nix new file mode 100644 index 0000000..aff52a2 --- /dev/null +++ b/custom-pkgs/cargo-bisect-rustc/default.nix @@ -0,0 +1,45 @@ +pkgs: pkgs.rustPlatform.buildRustPackage { + pname = "cargo-bisect-rustc"; + version = "0.6.11"; + + src = pkgs.fetchFromGitHub { + owner = "rust-lang"; + repo = "cargo-bisect-rustc"; + rev = "995147f7863377b3831f84911d21d1895437eee7"; + hash = "sha256-kQmQXMiZAh2zAXkxMoxlTfjrpXMIgXlJfwOsJPIVe94="; + }; + + cargoHash = "sha256-WSO5LvdJkAorSwsICz9NAWKNM7x4aeNvhGLhJSO6Vi8="; + + patches = + let + patchelfPatch = pkgs.runCommand "0001-patchelf.patch" + { + CC = pkgs.stdenv.cc; + patchelf = pkgs.patchelf; + libPath = "$ORIGIN/../lib:${pkgs.lib.makeLibraryPath [ pkgs.zlib ]}"; + } + '' + export dynamicLinker=$(cat $CC/nix-support/dynamic-linker) + substitute ${./0001-patchelf.patch} $out \ + --subst-var patchelf \ + --subst-var dynamicLinker \ + --subst-var libPath + ''; + in + pkgs.lib.optionals pkgs.stdenv.isLinux [ patchelfPatch ]; + + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ openssl xz ]; + + PKG_CONFIG_PATH = "${pkgs.openssl}/lib"; + + # Tests access the network. + doCheck = false; + + meta = with pkgs.lib; { + description = "Bisects rustc, either nightlies or CI artifacts"; + homepage = "https://github.com/rust-lang/cargo-bisect-rustc"; + license = licenses.mit; + }; +} diff --git a/custom-pkgs/crates/default.nix b/custom-pkgs/crates/default.nix new file mode 100644 index 0000000..9d9065b --- /dev/null +++ b/custom-pkgs/crates/default.nix @@ -0,0 +1,23 @@ +pkgs: +let + crates = import ./list.nix pkgs; +in +builtins.map + (crate: pkgs.rustPlatform.buildRustPackage { + pname = crate.pname; + version = crate.version; + src = pkgs.fetchCrate { + pname = crate.pname; + version = crate.version; + hash = crate.downloadHash; + }; + cargoHash = crate.cargoHash; + + meta = { + description = "${crate.pname} crate from crates.io"; + homepage = "https://crates.io/crates/${crate.pname}"; + }; + } + ) + crates + diff --git a/custom-pkgs/crates/list.nix b/custom-pkgs/crates/list.nix new file mode 100644 index 0000000..b2e9b27 --- /dev/null +++ b/custom-pkgs/crates/list.nix @@ -0,0 +1,20 @@ +pkgs: [ + { + pname = "cargo-dl"; + version = "0.1.4"; + downloadHash = "sha256-txSRmOr3tYw72xI5Dqt/y1EboaqFWEMN+lASVXLNdgQ="; + cargoHash = "sha256-bS1al2UnfUxCRjQYfvUKx19WW6sjGIwno78bORd3uBQ="; + } + { + pname = "counts"; + version = "1.0.4"; + downloadHash = "sha256-zLQHUHo3e/nY5UHhX03nK/gr+0rap/bSSlX7HDzr9uo="; + cargoHash = "sha256-pGrXn5/FD9RUbzt5DWM6LkEo0oHmosWy023Vd+EhcGY="; + } + { + pname = "typos-cli"; + version = "1.19.0"; + downloadHash = "sha256-qB0ISYBvblOGmoj1TUA9tddMHk9iDk0R3vlOWclQcMg="; + cargoHash = "sha256-ja4KrF2JdB2SVqnImdY7qdYXOJJgSftWtDCqWQ3ImYs="; + } +] diff --git a/custom-pkgs/default.nix b/custom-pkgs/default.nix new file mode 100644 index 0000000..597cb68 --- /dev/null +++ b/custom-pkgs/default.nix @@ -0,0 +1,10 @@ +pkgs: { + cargo-bisect-rustc = import ./cargo-bisect-rustc/default.nix pkgs; + sl = import ./sl { inherit pkgs; }; + run = import ./run { inherit pkgs; }; + unpem = import ./unpem { inherit pkgs; }; + flash-glove80 = import ./flash-glove80 { inherit pkgs; }; + u = import ./u { inherit pkgs; }; + x = import ./x { inherit pkgs; }; +} + diff --git a/custom-pkgs/flash-glove80/default.nix b/custom-pkgs/flash-glove80/default.nix new file mode 100644 index 0000000..1aed51b --- /dev/null +++ b/custom-pkgs/flash-glove80/default.nix @@ -0,0 +1,4 @@ +{ pkgs }: pkgs.writeShellApplication { + name = "flash-glove80"; + text = builtins.readFile ./flash.sh; +} diff --git a/custom-pkgs/flash-glove80/flash.sh b/custom-pkgs/flash-glove80/flash.sh new file mode 100644 index 0000000..dccfc48 --- /dev/null +++ b/custom-pkgs/flash-glove80/flash.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# shellcheck disable=SC2012 +image=$(ls "$HOME"/Downloads/*.uf2 --sort time | head -n1) +image_mtime=$(stat "$image" --format "%y") + +echo "flashing $image, last modified $image_mtime" + +read -rp "is this correct? (y/n) " +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 +fi + +echo "prompting sudo password once to avoid needing to type it again" +sudo true + +wait_until_present() { + local file="$1" + local side_descr="$2" + local keys="$3" + + while [ ! -e "$file" ]; do + echo "Glove80 $side_descr not connected, re-start it with $keys pressed" + sleep 5 + done + + echo "$side_descr is connected" +} + +flash_side() { + local disk="$1" + local side_descr="$2" + + if [ ! -e "$disk" ]; then + echo "$disk is missing, boot the glove80 while pressing PgDn+I" + exit 1 + fi + + local mountpoint + mountpoint=$(mktemp -d) + + echo "mounting $disk at $mountpoint" + sudo mount "$disk" "$mountpoint" + echo "copying $image to $side_descr" + sudo cp "$image" "$mountpoint/CURRENT.UF2" + echo "done flashing $side_descr" +} + +wait_and_flash() { + local side_shorthand="$1" + local side_descr="$2" + local keys="$3" + + local disk="/dev/disk/by-label/GLV80${side_shorthand}BOOT" + + wait_until_present "$disk" "$side_descr" "$keys" + flash_side "$disk" "$side_descr" +} + +wait_and_flash "RH" "right-hand side" "PgDn+I" +wait_and_flash "LH" "left-hand side" "Magic+E" + +echo "done flashing!" diff --git a/custom-pkgs/run/default.nix b/custom-pkgs/run/default.nix new file mode 100644 index 0000000..11d6fc9 --- /dev/null +++ b/custom-pkgs/run/default.nix @@ -0,0 +1,10 @@ +{ pkgs ? import { } }: pkgs.writeShellScriptBin "run" '' + first="$1" + if [ -z "$first" ]; then + echo "error: must provide package name" + exit 1 + fi + shift + export NIXPKGS_ALLOW_UNFREE=1 + nix run --impure nixpkgs#"$first" -- "$@" +'' diff --git a/custom-pkgs/sl/default.nix b/custom-pkgs/sl/default.nix new file mode 100644 index 0000000..f1a2e16 --- /dev/null +++ b/custom-pkgs/sl/default.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: pkgs.writeShellApplication { + name = "sl"; + runtimeInputs = with pkgs; [ niri jq ]; + derivationArgs = { + # shellcheck can't comprehend our amazingly new bash syntax + checkPhase = null; + }; + text = builtins.readFile ./sl.sh; +} diff --git a/custom-pkgs/sl/sl.sh b/custom-pkgs/sl/sl.sh new file mode 100644 index 0000000..92e4f03 --- /dev/null +++ b/custom-pkgs/sl/sl.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +win_id=$(niri msg --json windows | jq '.[] | select(.is_focused==true) | .id') + +niri msg action move-window-to-floating + +position() { + niri msg --json windows | jq ".[] | select(.id==${win_id}) | .layout.tile_pos_in_workspace_view.[0] | round" +} + +while true; do + before_pos_x=${ position; } + niri msg action move-floating-window --id "$win_id" -x +50 + after_pos_x=${ position; } + + if [[ "$before_pos_x" == "$after_pos_x" ]]; then + break; + fi +done + +while true; do + niri msg action move-floating-window --id "$win_id" -x -50 + after_pos_x=${ position; } + + if (( $after_pos_x <= 0 )); then + break; + fi +done + +niri msg action toggle-window-floating --id "$win_id" diff --git a/custom-pkgs/u/default.nix b/custom-pkgs/u/default.nix new file mode 100644 index 0000000..12e6bf8 --- /dev/null +++ b/custom-pkgs/u/default.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: pkgs.writeShellApplication { + name = "u"; + + text = '' + programs=(cargo git) + + if [ -z "''${1:-}" ]; then + echo "u: universial command executor" + echo "programs: ''${programs[*]}" + exit 0 + fi + + program_to_use="" + + for program in "''${programs[@]}"; do + if PAGER=true "$program" "$1" --help >/dev/null 2>/dev/null; then + if [ -n "$program_to_use" ]; then + echo "u: conflict: $1 is provided by both $program_to_use and $program" >&2 + exit 1 + fi + program_to_use="$program" + fi + done + + if [ -n "$program_to_use" ]; then + exec "$program_to_use" "$@" + fi + + echo "error: cannot find program for $1" >&2 + exit 1 + ''; +} diff --git a/custom-pkgs/unpem/Cargo.lock b/custom-pkgs/unpem/Cargo.lock new file mode 100644 index 0000000..9b90ec3 --- /dev/null +++ b/custom-pkgs/unpem/Cargo.lock @@ -0,0 +1,274 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "clap" +version = "4.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.208" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.208" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unpem" +version = "0.1.0" +dependencies = [ + "clap", + "pem", +] + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/custom-pkgs/unpem/Cargo.toml b/custom-pkgs/unpem/Cargo.toml new file mode 100644 index 0000000..08f52a0 --- /dev/null +++ b/custom-pkgs/unpem/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "unpem" +version = "0.1.0" +edition = "2021" + +[dependencies] +clap = { version = "4.5.16", features = ["derive"] } +pem = "3.0.4" diff --git a/custom-pkgs/unpem/default.nix b/custom-pkgs/unpem/default.nix new file mode 100644 index 0000000..684ebc4 --- /dev/null +++ b/custom-pkgs/unpem/default.nix @@ -0,0 +1,10 @@ +{ pkgs ? import { }, ... }: pkgs.rustPlatform.buildRustPackage { + src = pkgs.lib.cleanSource ./.; + pname = "unpem"; + version = "0.1.0"; + cargoLock.lockFile = ./Cargo.lock; + + meta = { + mainProgram = "unpem"; + }; +} diff --git a/custom-pkgs/unpem/src/main.rs b/custom-pkgs/unpem/src/main.rs new file mode 100644 index 0000000..e9c9440 --- /dev/null +++ b/custom-pkgs/unpem/src/main.rs @@ -0,0 +1,34 @@ +use std::{ + error::Error, + io::{BufReader, Read, Write}, +}; + +use clap::Parser; + +#[derive(clap::Parser)] +struct Args { + file: Option, +} + +fn main() -> Result<(), Box> { + let args = Args::parse(); + + match args.file { + None => unpem(&mut std::io::stdin().lock()), + Some(file) => { + let file = std::fs::File::open(file)?; + let mut file = BufReader::new(file); + unpem(&mut file) + } + } +} + +fn unpem(input: &mut dyn Read) -> Result<(), Box> { + let mut v = Vec::new(); + input.read_to_end(&mut v)?; + let pem = pem::parse(v)?; + + std::io::stdout().write_all(pem.contents())?; + + Ok(()) +} diff --git a/custom-pkgs/x/default.nix b/custom-pkgs/x/default.nix new file mode 100644 index 0000000..904a0cf --- /dev/null +++ b/custom-pkgs/x/default.nix @@ -0,0 +1,19 @@ +{ pkgs ? import { } }: pkgs.stdenv.mkDerivation { + name = "x"; + + src = ./x.rs; + dontUnpack = true; + + nativeBuildInputs = with pkgs; [ rustc ]; + + buildPhase = '' + PYTHON=${pkgs.lib.getExe pkgs.python3} rustc -Copt-level=3 --crate-name x $src --out-dir $out/bin + ''; + + meta = with pkgs.lib; { + description = "Helper for rust-lang/rust x.py"; + homepage = "https://github.com/rust-lang/rust/blob/master/src/tools/x"; + license = licenses.mit; + mainProgram = "x"; + }; +} diff --git a/custom-pkgs/x/x.rs b/custom-pkgs/x/x.rs new file mode 100644 index 0000000..b5f9715 --- /dev/null +++ b/custom-pkgs/x/x.rs @@ -0,0 +1,52 @@ +// git clone https://github.com/rust-lang/rust/blob/0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95/src/tools/x/src/main.rs +// patched to stop doing python probing, stop the probe, please dont, i have a python +//! Run bootstrap from any subdirectory of a rust compiler checkout. +//! +//! We prefer `exec`, to avoid adding an extra process in the process tree. +//! However, since `exec` isn't available on Windows, we indirect through +//! `exec_or_status`, which will call `exec` on unix and `status` on Windows. +//! +//! We use `powershell.exe x.ps1` on Windows, and `sh -c x` on Unix, those are +//! the ones that call `x.py`. We use `sh -c` on Unix, because it is a standard. +//! We also don't use `pwsh` on Windows, because it is not installed by default; + +use std::{ + env, + process::{self, Command}, + os::unix::process::CommandExt, +}; + +fn main() { + match env::args().skip(1).next().as_deref() { + Some("--wrapper-version") => { + println!("0.1.0"); + return; + } + _ => {} + } + let current = match env::current_dir() { + Ok(dir) => dir, + Err(err) => { + eprintln!("Failed to get current directory: {err}"); + process::exit(1); + } + }; + + for dir in current.ancestors() { + let candidate = dir.join("x.py"); + if candidate.exists() { + let mut cmd = Command::new(env!("PYTHON")); + cmd.arg(dir.join("x.py")); + cmd.args(env::args().skip(1)).current_dir(dir); + + let error = cmd.exec(); + eprintln!("Failed to invoke `{:?}`: {}", cmd, error); + } + } + + eprintln!( + "x.py not found. Please run inside of a checkout of `https://github.com/rust-lang/rust`." + ); + + process::exit(1); +} diff --git a/docker-images/build.sh b/docker-images/build.sh new file mode 100755 index 0000000..5a9b541 --- /dev/null +++ b/docker-images/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +p=$(dirname "$0") + +for dockerfile in "$p"/*.Dockerfile; do + imgname=$(basename "$dockerfile" .Dockerfile) + echo "Building $dockerfile" + + docker build "$p" -t "$imgname:latest" -f "$dockerfile" +done diff --git a/docker-images/debian12.Dockerfile b/docker-images/debian12.Dockerfile new file mode 100644 index 0000000..578a6fc --- /dev/null +++ b/docker-images/debian12.Dockerfile @@ -0,0 +1,6 @@ +FROM debian:12 + +RUN apt-get update && apt-get install -y build-essential clang git curl vim + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init.sh +RUN sh rustup-init.sh -y && rm rustup-init.sh diff --git a/flake.lock b/flake.lock index 28a9eda..8737634 100644 --- a/flake.lock +++ b/flake.lock @@ -1,61 +1,283 @@ { "nodes": { + "clippyboard": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770482323, + "narHash": "sha256-RFvjR94RV09DxPuYgp+tStXXJSZy9a8GkTVKdEHFAOo=", + "owner": "Noratrieb", + "repo": "clippyboard", + "rev": "91134a085402ce78238c86574d557f703715a111", + "type": "github" + }, + "original": { + "owner": "Noratrieb", + "repo": "clippyboard", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nur", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ "nixpkgs" - ], - "utils": "utils" + ] }, "locked": { - "lastModified": 1681092193, - "narHash": "sha256-JerCqqOqbT2tBnXQW4EqwFl0hHnuZp21rIQ6lu/N4rI=", + "lastModified": 1776562531, + "narHash": "sha256-Lh5Ns9DI67E+lSMOCGK0S+mFPy0mz0yOGiJTUXiR9JI=", "owner": "nix-community", "repo": "home-manager", - "rev": "f9edbedaf015013eb35f8caacbe0c9666bbc16af", + "rev": "5b56ad02dc643808b8af6d5f3ff179e2ce9593f4", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-22.11", "repo": "home-manager", "type": "github" } }, + "minegrub-theme": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1689938346, + "narHash": "sha256-uB6B1c0vFwng5SHLNxR5LgPfxOW26O8TL0hCn02uwCI=", + "owner": "Lxtharia", + "repo": "minegrub-theme", + "rev": "b6f8a3a7e2fd22d72e2dbdaf563ad0bcb5c78e45", + "type": "github" + }, + "original": { + "owner": "Lxtharia", + "repo": "minegrub-theme", + "rev": "b6f8a3a7e2fd22d72e2dbdaf563ad0bcb5c78e45", + "type": "github" + } + }, + "niri": { + "inputs": { + "niri-stable": "niri-stable", + "niri-unstable": "niri-unstable", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable", + "xwayland-satellite-stable": "xwayland-satellite-stable", + "xwayland-satellite-unstable": "xwayland-satellite-unstable" + }, + "locked": { + "lastModified": 1776602954, + "narHash": "sha256-C41nazGNIM/58ISKaIirq8/z1sDgS6CVJnWBwAzhaGQ=", + "owner": "sodiboo", + "repo": "niri-flake", + "rev": "c175f415488243723dc1a5514b286abbea6f93c1", + "type": "github" + }, + "original": { + "owner": "sodiboo", + "repo": "niri-flake", + "type": "github" + } + }, + "niri-stable": { + "flake": false, + "locked": { + "lastModified": 1756556321, + "narHash": "sha256-RLD89dfjN0RVO86C/Mot0T7aduCygPGaYbog566F0Qo=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "01be0e65f4eb91a9cd624ac0b76aaeab765c7294", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "ref": "v25.08", + "repo": "niri", + "type": "github" + } + }, + "niri-unstable": { + "flake": false, + "locked": { + "lastModified": 1776598536, + "narHash": "sha256-7Bbp0fDBJMDRpKfdHelMXbhY51bdCa5+Qn/+XONaOwk=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "68bb942d2146cd2c8af69c0f16db18396b4388fe", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "repo": "niri", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1684398685, - "narHash": "sha256-TRE62m91iZ5ArVMgA+uj22Yda8JoQuuhc9uwZ+NoX+0=", + "lastModified": 1776169885, + "narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1776434932, + "narHash": "sha256-gyqXNMgk3sh+ogY5svd2eNLJ6oEwzbAeaoBrrxD0lKk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c7f47036d3df2add644c46d712d14262b7d86c0c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1720535198, + "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "628d4bb6e9f4f0c30cfd9b23d3c1cdcec9d3cb5c", + "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-22.11", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1776169885, + "narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1776169885, + "narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nur": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1776614809, + "narHash": "sha256-BnQwcKSWlzpe5BdywlGkIoG4dzIDhGdtFKYn2Q+BBDs=", + "owner": "nix-community", + "repo": "NUR", + "rev": "561c40a02ec3372f469471fb8ee6e8deb91815d5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NUR", + "type": "github" + } + }, "root": { "inputs": { + "clippyboard": "clippyboard", "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "minegrub-theme": "minegrub-theme", + "niri": "niri", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable_2", + "nur": "nur" } }, - "utils": { + "xwayland-satellite-stable": { + "flake": false, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "lastModified": 1755491097, + "narHash": "sha256-m+9tUfsmBeF2Gn4HWa6vSITZ4Gz1eA1F5Kh62B0N4oE=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "388d291e82ffbc73be18169d39470f340707edaa", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "Supreeeme", + "ref": "v0.7", + "repo": "xwayland-satellite", + "type": "github" + } + }, + "xwayland-satellite-unstable": { + "flake": false, + "locked": { + "lastModified": 1773622265, + "narHash": "sha256-wToKwH7IgWdGLMSIWksEDs4eumR6UbbsuPQ42r0oTXQ=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "a879e5e0896a326adc79c474bf457b8b99011027", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "repo": "xwayland-satellite", "type": "github" } } diff --git a/flake.nix b/flake.nix index 4f95f09..cc60479 100644 --- a/flake.nix +++ b/flake.nix @@ -1,44 +1,69 @@ +# Adapted from https://github.com/Misterio77/nix-starter-configs + { - description = "Your new nix config"; + description = "NixOS configuration"; inputs = { # Nixpkgs - nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.11"; + + nur.url = "github:nix-community/NUR"; # Home manager - home-manager.url = "github:nix-community/home-manager/release-22.11"; + home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; - # TODO: Add any other flake you might need - # hardware.url = "github:nixos/nixos-hardware"; + minegrub-theme.url = "github:Lxtharia/minegrub-theme/b6f8a3a7e2fd22d72e2dbdaf563ad0bcb5c78e45"; + minegrub-theme.inputs.nixpkgs.follows = "nixpkgs"; - # Shameless plug: looking for a way to nixify your themes and make - # everything match nicely? Try nix-colors! - # nix-colors.url = "github:misterio77/nix-colors"; + niri.url = "github:sodiboo/niri-flake"; + + clippyboard.url = "github:Noratrieb/clippyboard"; + clippyboard.inputs.nixpkgs.follows = "nixpkgs"; + + # for firefox-nightly + # firefox.url = "github:nix-community/flake-firefox-nightly"; + # firefox.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { nixpkgs, home-manager, ... }@inputs: { + outputs = { nixpkgs, home-manager, nur, ... }@inputs: { # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' + # Available through 'nixos-rebuild --flake .#nixos' nixosConfigurations = { - # FIXME replace with your hostname - your-hostname = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; # Pass flake inputs to our config - # > Our main nixos configuration file < - modules = [ ./nixos/configuration.nix ]; + nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./nixos/desktop.nix + inputs.minegrub-theme.nixosModules.default + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.nora = import ./home-manager/home.nix; + home-manager.extraSpecialArgs = { inherit inputs; }; + } + ]; + }; + scrap = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./nixos/laptop.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.nora = import ./home-manager/laptop.nix; + home-manager.extraSpecialArgs = { inherit inputs; }; + } + ]; }; }; - # Standalone home-manager configuration entrypoint - # Available through 'home-manager --flake .#your-username@your-hostname' - homeConfigurations = { - # FIXME replace with your username@hostname - "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance - extraSpecialArgs = { inherit inputs; }; # Pass flake inputs to our config - # > Our main home-manager configuration file < - modules = [ ./home-manager/home.nix ]; - }; + devShells.${"x86_64-linux"}.c-env = import ./shells/c-env.nix { + pkgs = import nixpkgs { system = "x86_64-linux"; }; }; }; } diff --git a/home-manager/common-packages.nix b/home-manager/common-packages.nix new file mode 100644 index 0000000..5c0a8e8 --- /dev/null +++ b/home-manager/common-packages.nix @@ -0,0 +1,36 @@ +{ pkgs, inputs, ... }: +let + customPkgs = import ../custom-pkgs pkgs; + crates = import ../custom-pkgs/crates pkgs; +in +with pkgs; [ + bacon + bat + cargo-cross + cargo-expand + cargo-mommy + cargo-nextest + dig + fzf + gcc + gdb + gh + git-absorb + git-crypt + hollywood + htop + hyperfine + killall + llvmPackages_21.bintools-unwrapped + inferno + jq + jujutsu + p7zip + python3 + rustup-toolchain-install-master + samply + tokei + customPkgs.u + customPkgs.sl + uwuify +] ++ crates diff --git a/home-manager/common.nix b/home-manager/common.nix new file mode 100644 index 0000000..b73388a --- /dev/null +++ b/home-manager/common.nix @@ -0,0 +1,94 @@ +{ lib +, pkgs +, ... +}: +let + customPkgs = import ../custom-pkgs/default.nix pkgs; +in +{ + programs.neovim.enable = true; + home.file.".cargo/config.toml" = { + text = '' + [target.x86_64-unknown-linux-gnu] + linker = "${lib.getExe pkgs.llvmPackages_21.clang}" + rustflags = ["-Clink-arg=-fuse-ld=${lib.getExe' pkgs.mold "mold"}", "-Ctarget-cpu=native"] + ''; + }; + + home.file.".config/gdb/gdbinit" = { + text = '' + set disassembly-flavor intel + ''; + }; + home.file.".config/gdb/gdbearlyinit" = { + text = '' + set startup-quietly on + ''; + }; + + programs.zoxide = { + enable = true; + enableFishIntegration = true; + }; + + programs.direnv = { + enable = true; + }; + + programs.eza = { + enable = true; + }; + + programs.ripgrep.enable = true; + + programs.fd.enable = true; + + programs.fish = { + enable = true; + interactiveShellInit = '' + set fish_greeting # Disable greeting + ''; + shellAbbrs = { + flamegraph = "perf script | inferno-collapse-perf | inferno-flamegraph > out.svg && firefox out.svg"; + c = "cargo"; + g = "git"; + sc = "scratch"; + }; + shellAliases = { + x = "CARGO_MOMMYS_ACTUAL=${lib.getExe customPkgs.x} ${lib.getExe' pkgs.cargo-mommy "cargo-mommy"}"; + }; + functions = { + "scratch" = { + description = "Makes a temporary directory and moves into it"; + body = '' + cd "$(mktemp --tmpdir -d scratchXXXXXXXXX)" + ''; + }; + }; + }; + + programs.hyfetch = { + enable = true; + settings = { + preset = "transgender"; + mode = "rgb"; + light_dark = "dark"; + lightness = 0.65; + color_align = { + mode = "horizontal"; + custom_colors = [ ]; + fore_back = null; + }; + backend = "fastfetch"; + args = null; + distro = null; + pride_month_shown = [ ]; + pride_month_disable = false; + }; + }; + + programs.home-manager.enable = true; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "22.11"; +} diff --git a/home-manager/config.kdl b/home-manager/config.kdl new file mode 100644 index 0000000..485f1b8 --- /dev/null +++ b/home-manager/config.kdl @@ -0,0 +1,604 @@ +// This config is in the KDL format: https://kdl.dev +// "/-" comments out the following node. +// Check the wiki for a full description of the configuration: +// https://github.com/YaLTeR/niri/wiki/Configuration:-Overview + +// Input device configuration. +// Find the full list of options on the wiki: +// https://github.com/YaLTeR/niri/wiki/Configuration:-Input +input { + keyboard { + xkb { + // You can set rules, model, layout, variant and options. + // For more information, see xkeyboard-config(7). + + // For example: + layout "ch" + // options "compose:rctrl" // i need rctrl for the glove80 so lets remove this for now + // options "grp:win_space_toggle,compose:ralt,ctrl:nocaps" + } + } + + // Next sections include libinput settings. + // Omitting settings disables them, or leaves them at their default values. + touchpad { + // off + tap + // dwt + // dwtp + // drag-lock + natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + // scroll-method "two-finger" + // disabled-on-external-mouse + } + + mouse { + // off + // natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + // scroll-method "no-scroll" + } + + trackpoint { + // off + // natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + // scroll-method "on-button-down" + // scroll-button 273 + // middle-emulation + } + + // Uncomment this to make the mouse warp to the center of newly focused windows. + // warp-mouse-to-focus + + // Focus windows and outputs automatically when moving the mouse into them. + // Setting max-scroll-amount="0%" makes it work only on windows already fully on screen. + // focus-follows-mouse max-scroll-amount="0%" +} + +// You can configure outputs by their name, which you can find +// by running `niri msg outputs` while inside a niri instance. +// The built-in laptop monitor is usually called "eDP-1". +// Find more information on the wiki: +// https://github.com/YaLTeR/niri/wiki/Configuration:-Outputs +// Remember to uncomment the node by removing "/-"! +/-output "eDP-1" { + // Uncomment this line to disable this output. + // off + + // Resolution and, optionally, refresh rate of the output. + // The format is "x" or "x@". + // If the refresh rate is omitted, niri will pick the highest refresh rate + // for the resolution. + // If the mode is omitted altogether or is invalid, niri will pick one automatically. + // Run `niri msg outputs` while inside a niri instance to list all outputs and their modes. + mode "1920x1080@120.030" + + // You can use integer or fractional scale, for example use 1.5 for 150% scale. + scale 2 + + // Transform allows to rotate the output counter-clockwise, valid values are: + // normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270. + transform "normal" + + // Position of the output in the global coordinate space. + // This affects directional monitor actions like "focus-monitor-left", and cursor movement. + // The cursor can only move between directly adjacent outputs. + // Output scale and rotation has to be taken into account for positioning: + // outputs are sized in logical, or scaled, pixels. + // For example, a 3840×2160 output with scale 2.0 will have a logical size of 1920×1080, + // so to put another output directly adjacent to it on the right, set its x to 1920. + // If the position is unset or results in an overlap, the output is instead placed + // automatically. + position x=1280 y=0 +} + +output "Samsung Electric Company LC27G7xT H1AK500000" { + // variable-refresh-rate +} + +// Settings that influence how windows are positioned and sized. +// Find more information on the wiki: +// https://github.com/YaLTeR/niri/wiki/Configuration:-Layout +layout { + // Set gaps around windows in logical pixels. + gaps 16 + + // When to center a column when changing focus, options are: + // - "never", default behavior, focusing an off-screen column will keep at the left + // or right edge of the screen. + // - "always", the focused column will always be centered. + // - "on-overflow", focusing a column will center it if it doesn't fit + // together with the previously focused column. + center-focused-column "never" + + // You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between. + preset-column-widths { + // Proportion sets the width as a fraction of the output width, taking gaps into account. + // For example, you can perfectly fit four windows sized "proportion 0.25" on an output. + // The default preset widths are 1/3, 1/2 and 2/3 of the output. + proportion 0.33333 + proportion 0.5 + proportion 0.66667 + + // Fixed sets the width in logical pixels exactly. + // fixed 1920 + } + + // You can also customize the heights that "switch-preset-window-height" (Mod+Shift+R) toggles between. + // preset-window-heights { } + + // You can change the default width of the new windows. + default-column-width { proportion 0.5; } + // If you leave the brackets empty, the windows themselves will decide their initial width. + // default-column-width {} + + // By default focus ring and border are rendered as a solid background rectangle + // behind windows. That is, they will show up through semitransparent windows. + // This is because windows using client-side decorations can have an arbitrary shape. + // + // If you don't like that, you should uncomment `prefer-no-csd` below. + // Niri will draw focus ring and border *around* windows that agree to omit their + // client-side decorations. + // + // Alternatively, you can override it with a window rule called + // `draw-border-with-background`. + + // You can change how the focus ring looks. + focus-ring { + // Uncomment this line to disable the focus ring. + // off + + // How many logical pixels the ring extends out from the windows. + width 4 + + // Colors can be set in a variety of ways: + // - CSS named colors: "red" + // - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa" + // - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others. + + // Color of the ring on the active monitor. + active-color "#db88c5" + + // Color of the ring on inactive monitors. + inactive-color "#505050" + + // You can also use gradients. They take precedence over solid colors. + // Gradients are rendered the same as CSS linear-gradient(angle, from, to). + // The angle is the same as in linear-gradient, and is optional, + // defaulting to 180 (top-to-bottom gradient). + // You can use any CSS linear-gradient tool on the web to set these up. + // Changing the color space is also supported, check the wiki for more info. + // + // active-gradient from="#80c8ff" to="#bbddff" angle=45 + + // You can also color the gradient relative to the entire view + // of the workspace, rather than relative to just the window itself. + // To do that, set relative-to="workspace-view". + // + // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + } + + // You can also add a border. It's similar to the focus ring, but always visible. + border { + // The settings are the same as for the focus ring. + // If you enable the border, you probably want to disable the focus ring. + off + + width 4 + active-color "#ffc87f" + inactive-color "#505050" + + // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" + // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + } + + // You can enable drop shadows for windows. + shadow { + // Uncomment the next line to enable shadows. + on + + // By default, the shadow draws only around its window, and not behind it. + // Uncomment this setting to make the shadow draw behind its window. + // + // Note that niri has no way of knowing about the CSD window corner + // radius. It has to assume that windows have square corners, leading to + // shadow artifacts inside the CSD rounded corners. This setting fixes + // those artifacts. + // + // However, instead you may want to set prefer-no-csd and/or + // geometry-corner-radius. Then, niri will know the corner radius and + // draw the shadow correctly, without having to draw it behind the + // window. These will also remove client-side shadows if the window + // draws any. + // + draw-behind-window true + + // You can change how shadows look. The values below are in logical + // pixels and match the CSS box-shadow properties. + + // Softness controls the shadow blur radius. + softness 30 + + // Spread expands the shadow. + spread 5 + + // Offset moves the shadow relative to the window. + offset x=0 y=5 + + // You can also change the shadow color and opacity. + color "#0007" + } + + // Struts shrink the area occupied by windows, similarly to layer-shell panels. + // You can think of them as a kind of outer gaps. They are set in logical pixels. + // Left and right struts will cause the next window to the side to always be visible. + // Top and bottom struts will simply add outer gaps in addition to the area occupied by + // layer-shell panels and regular gaps. + struts { + // left 64 + // right 64 + // top 64 + // bottom 64 + } +} + +// Add lines like this to spawn processes at startup. +// Note that running niri as a session supports xdg-desktop-autostart, +// which may be more convenient to use. +// See the binds section below for more spawn examples. +environment { + ELECTRON_OZONE_PLATFORM_HINT "auto" +} + +// Uncomment this line to ask the clients to omit their client-side decorations if possible. +// If the client will specifically ask for CSD, the request will be honored. +// Additionally, clients will be informed that they are tiled, removing some client-side rounded corners. +// This option will also fix border/focus ring drawing behind some semitransparent windows. +// After enabling or disabling this, you need to restart the apps for this to take effect. +// prefer-no-csd + +// You can change the path where screenshots are saved. +// A ~ at the front will be expanded to the home directory. +// The path is formatted with strftime(3) to give you the screenshot date and time. +screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" + +// You can also set this to null to disable saving screenshots to disk. +// screenshot-path null + +// Animation settings. +// The wiki explains how to configure individual animations: +// https://github.com/YaLTeR/niri/wiki/Configuration:-Animations +animations { + // Uncomment to turn off all animations. + // off + + // Slow down all animations by this factor. Values below 1 speed them up instead. + // slowdown 3.0 +} + +// Window rules let you adjust behavior for individual windows. +// Find more information on the wiki: +// https://github.com/YaLTeR/niri/wiki/Configuration:-Window-Rules + +// Work around WezTerm's initial configure bug +// by setting an empty default-column-width. +window-rule { + // This regular expression is intentionally made as specific as possible, + // since this is the default config, and we want no false positives. + // You can get away with just app-id="wezterm" if you want. + match app-id=r#"^org\.wezfurlong\.wezterm$"# + default-column-width {} +} + +// Open the Firefox picture-in-picture player as floating by default. +window-rule { + // This app-id regular expression will work for both: + // - host Firefox (app-id is "firefox") + // - Flatpak Firefox (app-id is "org.mozilla.firefox") + match app-id=r#"firefox$"# title="^Picture-in-Picture$" + open-floating true +} + +// Example: block out two password managers from screen capture. +// (This example rule is commented out with a "/-" in front.) +/-window-rule { + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + + // Use this instead if you want them visible on third-party screenshot tools. + // block-out-from "screencast" +} + +// Example: enable rounded corners for all windows. +// (This example rule is commented out with a "/-" in front.) +window-rule { + geometry-corner-radius 8 + clip-to-geometry true +} + +window-rule { + match app-id="Spotify" + open-on-output "Samsung Electric Company SMS24A450/460 HVMBA01140" +} + + +window-rule { + match app-id="discord" + open-on-output "Lenovo Group Limited LEN G25-10 U4B30R14" +} + +window-rule { + match app-id="clippyboard" + open-floating true +} + +binds { + // Keys consist of modifiers separated by + signs, followed by an XKB key name + // in the end. To find an XKB name for a particular key, you may use a program + // like wev. + // + // "Mod" is a special modifier equal to Super when running on a TTY, and to Alt + // when running as a winit window. + // + // Most actions that you can bind here can also be invoked programmatically with + // `niri msg action do-something`. + + // Mod-Shift-/, which is usually the same as Mod-?, + // shows a list of important hotkeys. + Mod+Shift+Slash { show-hotkey-overlay; } + + // Suggested binds for running programs: terminal, app launcher, screen locker. + Mod+T { spawn "alacritty"; } + Mod+D { spawn "fuzzel"; } + Super+Alt+L { spawn "lock-and-power-off-screen"; } + + // You can also use a shell. Do this if you need pipes, multiple commands, etc. + // Note: the entire command goes as a single argument in the end. + // Mod+T { spawn "bash" "-c" "notify-send hello && exec alacritty"; } + + // Example volume keys mappings for PipeWire & WirePlumber. + // The allow-when-locked=true property makes them work even when the session is locked. + XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1+"; } + XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1-"; } + XF86AudioMute allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; } + XF86AudioMicMute allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; } + XF86AudioPlay allow-when-locked=true { spawn "playerctl" "play-pause"; } + XF86AudioPrev allow-when-locked=true { spawn "playerctl" "previous"; } + XF86AudioNext allow-when-locked=true { spawn "playerctl" "next"; } + + Mod+Q { close-window; } + + Mod+Left { focus-column-left; } + Mod+Down { focus-window-down; } + Mod+Up { focus-window-up; } + Mod+Right { focus-column-right; } + Mod+H { focus-column-left; } + Mod+J { focus-window-down; } + Mod+K { focus-window-up; } + Mod+L { focus-column-right; } + + Mod+Ctrl+Left { move-column-left; } + Mod+Ctrl+Down { move-window-down; } + Mod+Ctrl+Up { move-window-up; } + Mod+Ctrl+Right { move-column-right; } + Mod+Ctrl+H { move-column-left; } + Mod+Ctrl+J { move-window-down; } + Mod+Ctrl+K { move-window-up; } + Mod+Ctrl+L { move-column-right; } + + // Alternative commands that move across workspaces when reaching + // the first or last window in a column. + // Mod+J { focus-window-or-workspace-down; } + // Mod+K { focus-window-or-workspace-up; } + // Mod+Ctrl+J { move-window-down-or-to-workspace-down; } + // Mod+Ctrl+K { move-window-up-or-to-workspace-up; } + + Mod+Home { focus-column-first; } + Mod+End { focus-column-last; } + Mod+Ctrl+Home { move-column-to-first; } + Mod+Ctrl+End { move-column-to-last; } + + Mod+Shift+Left { focus-monitor-left; } + Mod+Shift+Down { focus-monitor-down; } + Mod+Shift+Up { focus-monitor-up; } + Mod+Shift+Right { focus-monitor-right; } + Mod+Shift+H { focus-monitor-left; } + Mod+Shift+J { focus-monitor-down; } + Mod+Shift+K { focus-monitor-up; } + Mod+Shift+L { focus-monitor-right; } + + Mod+Shift+Ctrl+Left { move-column-to-monitor-left; } + Mod+Shift+Ctrl+Down { move-column-to-monitor-down; } + Mod+Shift+Ctrl+Up { move-column-to-monitor-up; } + Mod+Shift+Ctrl+Right { move-column-to-monitor-right; } + Mod+Shift+Ctrl+H { move-column-to-monitor-left; } + Mod+Shift+Ctrl+J { move-column-to-monitor-down; } + Mod+Shift+Ctrl+K { move-column-to-monitor-up; } + Mod+Shift+Ctrl+L { move-column-to-monitor-right; } + + // Alternatively, there are commands to move just a single window: + // Mod+Shift+Ctrl+Left { move-window-to-monitor-left; } + // ... + + // And you can also move a whole workspace to another monitor: + // Mod+Shift+Ctrl+Left { move-workspace-to-monitor-left; } + // ... + + Mod+Page_Down { focus-workspace-down; } + Mod+Page_Up { focus-workspace-up; } + Mod+U { focus-workspace-down; } + Mod+I { focus-workspace-up; } + Mod+Ctrl+Page_Down { move-column-to-workspace-down; } + Mod+Ctrl+Page_Up { move-column-to-workspace-up; } + Mod+Ctrl+U { move-column-to-workspace-down; } + Mod+Ctrl+I { move-column-to-workspace-up; } + + // Alternatively, there are commands to move just a single window: + // Mod+Ctrl+Page_Down { move-window-to-workspace-down; } + // ... + + Mod+Shift+Page_Down { move-workspace-down; } + Mod+Shift+Page_Up { move-workspace-up; } + Mod+Shift+U { move-workspace-down; } + Mod+Shift+I { move-workspace-up; } + + // You can bind mouse wheel scroll ticks using the following syntax. + // These binds will change direction based on the natural-scroll setting. + // + // To avoid scrolling through workspaces really fast, you can use + // the cooldown-ms property. The bind will be rate-limited to this value. + // You can set a cooldown on any bind, but it's most useful for the wheel. + Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; } + Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; } + Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; } + Mod+Ctrl+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; } + + Mod+WheelScrollRight { focus-column-right; } + Mod+WheelScrollLeft { focus-column-left; } + Mod+Ctrl+WheelScrollRight { move-column-right; } + Mod+Ctrl+WheelScrollLeft { move-column-left; } + + // Usually scrolling up and down with Shift in applications results in + // horizontal scrolling; these binds replicate that. + Mod+Shift+WheelScrollDown { focus-column-right; } + Mod+Shift+WheelScrollUp { focus-column-left; } + Mod+Ctrl+Shift+WheelScrollDown { move-column-right; } + Mod+Ctrl+Shift+WheelScrollUp { move-column-left; } + + // Similarly, you can bind touchpad scroll "ticks". + // Touchpad scrolling is continuous, so for these binds it is split into + // discrete intervals. + // These binds are also affected by touchpad's natural-scroll, so these + // example binds are "inverted", since we have natural-scroll enabled for + // touchpads by default. + // Mod+TouchpadScrollDown { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02+"; } + // Mod+TouchpadScrollUp { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.02-"; } + + // You can refer to workspaces by index. However, keep in mind that + // niri is a dynamic workspace system, so these commands are kind of + // "best effort". Trying to refer to a workspace index bigger than + // the current workspace count will instead refer to the bottommost + // (empty) workspace. + // + // For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on + // will all refer to the 3rd workspace. + Mod+1 { focus-workspace 1; } + Mod+2 { focus-workspace 2; } + Mod+3 { focus-workspace 3; } + Mod+4 { focus-workspace 4; } + Mod+5 { focus-workspace 5; } + Mod+6 { focus-workspace 6; } + Mod+7 { focus-workspace 7; } + Mod+8 { focus-workspace 8; } + Mod+9 { focus-workspace 9; } + Mod+Ctrl+1 { move-column-to-workspace 1; } + Mod+Ctrl+2 { move-column-to-workspace 2; } + Mod+Ctrl+3 { move-column-to-workspace 3; } + Mod+Ctrl+4 { move-column-to-workspace 4; } + Mod+Ctrl+5 { move-column-to-workspace 5; } + Mod+Ctrl+6 { move-column-to-workspace 6; } + Mod+Ctrl+7 { move-column-to-workspace 7; } + Mod+Ctrl+8 { move-column-to-workspace 8; } + Mod+Ctrl+9 { move-column-to-workspace 9; } + + // Alternatively, there are commands to move just a single window: + // Mod+Ctrl+1 { move-window-to-workspace 1; } + + // Switches focus between the current and the previous workspace. + // Mod+Tab { focus-workspace-previous; } + + // The following binds move the focused window in and out of a column. + // If the window is alone, they will consume it into the nearby column to the side. + // If the window is already in a column, they will expel it out. + Mod+BracketLeft { consume-or-expel-window-left; } + Mod+BracketRight { consume-or-expel-window-right; } + + // Consume one window from the right to the bottom of the focused column. + Mod+Comma { consume-window-into-column; } + // Expel the bottom window from the focused column to the right. + Mod+Period { expel-window-from-column; } + + Mod+R { switch-preset-column-width; } + Mod+Shift+R { switch-preset-window-height; } + Mod+Ctrl+R { reset-window-height; } + Mod+F { maximize-column; } + Mod+Shift+F { fullscreen-window; } + + // Expand the focused column to space not taken up by other fully visible columns. + // Makes the column "fill the rest of the space". + Mod+Ctrl+F { expand-column-to-available-width; } + + Mod+C { center-column; } + + // Finer width adjustments. + // This command can also: + // * set width in pixels: "1000" + // * adjust width in pixels: "-5" or "+5" + // * set width as a percentage of screen width: "25%" + // * adjust width as a percentage of screen width: "-10%" or "+10%" + // Pixel sizes use logical, or scaled, pixels. I.e. on an output with scale 2.0, + // set-column-width "100" will make the column occupy 200 physical screen pixels. + // requires the numpad but at least makes it possible at all + Mod+KP_Subtract { set-column-width "-10%"; } + Mod+KP_Add { set-column-width "+10%"; } + + // Finer height adjustments when in column with other windows. + // requires the numpad but at least makes it possible at all + Mod+Shift+KP_Subtract { set-window-height "-10%"; } + Mod+Shift+KP_Add { set-window-height "+10%"; } + + // Move the focused window between the floating and the tiling layout. + Mod+P { toggle-window-floating; } + Mod+Shift+P { switch-focus-between-floating-and-tiling; } + + // move around floating windows, sadly not available via binds directly. + Mod+Alt+Up { spawn "niri" "msg" "action" "move-floating-window" "-y" "-50"; } + Mod+Alt+Down { spawn "niri" "msg" "action" "move-floating-window" "-y" "+50"; } + Mod+Alt+Right { spawn "niri" "msg" "action" "move-floating-window" "-x" "+50"; } + Mod+Alt+Left { spawn "niri" "msg" "action" "move-floating-window" "-x" "-50"; } + + Mod+S { set-dynamic-cast-window; } + Mod+Shift+S { set-dynamic-cast-monitor; } + + // Toggle tabbed column display mode. + // Windows in this column will appear as vertical tabs, + // rather than stacked on top of each other. + Mod+W { toggle-column-tabbed-display; } + + // Actions to switch layouts. + // Note: if you uncomment these, make sure you do NOT have + // a matching layout switch hotkey configured in xkb options above. + // Having both at once on the same hotkey will break the switching, + // since it will switch twice upon pressing the hotkey (once by xkb, once by niri). + // Mod+Space { switch-layout "next"; } + // Mod+Shift+Space { switch-layout "prev"; } + + Print { screenshot show-pointer=false; } + Ctrl+Print { screenshot-screen show-pointer=false; } + Alt+Print { screenshot-window; } + + // Applications such as remote-desktop clients and software KVM switches may + // request that niri stops processing the keyboard shortcuts defined here + // so they may, for example, forward the key presses as-is to a remote machine. + // It's a good idea to bind an escape hatch to toggle the inhibitor, + // so a buggy application can't hold your session hostage. + // + // The allow-inhibiting=false property can be applied to other binds as well, + // which ensures niri always processes them, even when an inhibitor is active. + Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } + + // The quit action will show a confirmation dialog to avoid accidental exits. + Mod+Shift+E { quit; } + Ctrl+Alt+Delete { quit; } + + // Paste from clippyboard + Mod+V { spawn "clippyboard-select"; } + Mod+Shift+V { spawn "clippyboard-clear"; } +} diff --git a/home-manager/default-waybar-style.css b/home-manager/default-waybar-style.css new file mode 100644 index 0000000..7e83028 --- /dev/null +++ b/home-manager/default-waybar-style.css @@ -0,0 +1,327 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; +} + +window#waybar { + background-color: rgba(43, 48, 59, 0.5); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + transition-property: background-color; + transition-duration: .5s; +} + +window#waybar.hidden { + opacity: 0.2; +} + +/* +window#waybar.empty { + background-color: transparent; +} +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +window#waybar.termite { + background-color: #3F3F3F; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} + +button { + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each button name */ + border: none; + border-radius: 0; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +button:hover { + background: inherit; + box-shadow: inset 0 -3px #ffffff; +} + +/* you can set a style on hover for any module like this */ +#pulseaudio:hover { + background-color: #a37800; +} + +#workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; +} + +#workspaces button:hover { + background: rgba(0, 0, 0, 0.2); +} + +#workspaces button.focused { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#wireplumber, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#scratchpad, +#power-profiles-daemon, +#mpd { + padding: 0 10px; + color: #ffffff; +} + +#window, +#workspaces { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left > widget:first-child > #workspaces { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right > widget:last-child > #workspaces { + margin-right: 0; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: #000000; +} + +#battery.charging, #battery.plugged { + color: #ffffff; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +/* Using steps() instead of linear as a timing function to limit cpu usage */ +#battery.critical:not(.charging) { + background-color: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: steps(12); + animation-iteration-count: infinite; + animation-direction: alternate; +} + +#power-profiles-daemon { + padding-right: 15px; +} + +#power-profiles-daemon.performance { + background-color: #f53c3c; + color: #ffffff; +} + +#power-profiles-daemon.balanced { + background-color: #2980b9; + color: #ffffff; +} + +#power-profiles-daemon.power-saver { + background-color: #2ecc71; + color: #000000; +} + +label:focus { + background-color: #000000; +} + +#cpu { + background-color: #2ecc71; + color: #000000; +} + +#memory { + background-color: #9b59b6; +} + +#disk { + background-color: #964B00; +} + +#backlight { + background-color: #90b1b1; +} + +#network { + background-color: #2980b9; +} + +#network.disconnected { + background-color: #f53c3c; +} + +#pulseaudio { + background-color: #f1c40f; + color: #000000; +} + +#pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; +} + +#wireplumber { + background-color: #fff0f5; + color: #000000; +} + +#wireplumber.muted { + background-color: #f53c3c; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #2980b9; +} + +#tray > .passive { + -gtk-icon-effect: dim; +} + +#tray > .needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} + +#language { + background: #00b093; + color: #740864; + padding: 0 5px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state { + background: #97e1ad; + color: #000000; + padding: 0 0px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state > label { + padding: 0 5px; +} + +#keyboard-state > label.locked { + background: rgba(0, 0, 0, 0.2); +} + +#scratchpad { + background: rgba(0, 0, 0, 0.2); +} + +#scratchpad.empty { + background-color: transparent; +} + +#privacy { + padding: 0; +} + +#privacy-item { + padding: 0 5px; + color: white; +} + +#privacy-item.screenshare { + background-color: #cf5700; +} + +#privacy-item.audio-in { + background-color: #1ca000; +} + +#privacy-item.audio-out { + background-color: #0069d4; +} diff --git a/home-manager/firefox.nix b/home-manager/firefox.nix new file mode 100644 index 0000000..28b6dfe --- /dev/null +++ b/home-manager/firefox.nix @@ -0,0 +1,51 @@ +{ pkgs, ... }: { + programs.firefox = { + enable = true; + profiles = { + nora = { + id = 0; + name = "nora"; + + extensions.packages = with pkgs.nur.repos.rycee.firefox-addons; [ + ublock-origin + bitwarden + tampermonkey + sidebery + darkreader + ]; + + bookmarks = { + force = true; + settings = [ + { + name = "Nix sites"; + toolbar = true; + bookmarks = [ + { + name = "NixOS options"; + url = "https://search.nixos.org/options"; + } + { + name = "home-manager options"; + url = "https://rycee.gitlab.io/home-manager/options.html"; + } + { + name = "nixpkgs search"; + url = "https://search.nixos.org/packages"; + } + { + name = "Github Notifications"; + url = "https://github.com/notifications"; + } + { + name = "glove80 layout"; + url = "https://my.moergo.com/glove80/#/layout/user/4ade12f3-81d7-4342-8196-9c13c43ac94e"; + } + ]; + } + ]; + }; + }; + }; + }; +} diff --git a/home-manager/git.nix b/home-manager/git.nix new file mode 100644 index 0000000..ddab0be --- /dev/null +++ b/home-manager/git.nix @@ -0,0 +1,56 @@ +{ pkgs, lib, ... }: { + programs.git = { + enable = true; + + signing.format = null; + + settings = { + user = { + name = "Noratrieb"; + email = "48135649+Noratrieb@users.noreply.github.com"; + }; + + alias = { + # simple aliases + c = "checkout"; + st = "status"; + p = "push"; + rc = "rebase --continue"; + ra = "rebase --abort"; + amend = "commit --amend --no-edit"; + # complex renames + hardupdate = "!git fetch && git reset --hard \"origin/$(git rev-parse --abbrev-ref HEAD)\""; + fpush = "push --force-with-lease"; + resq = "rebase --autosquash -i"; + autosquash = "!${lib.getExe pkgs.git-revise} -i $(git merge-base HEAD origin/HEAD) --autosquash"; + autosq = "autosquash"; + pfush = "!echo \"hör uf ume z'pfusche und machs richtig\""; + sw = "!git checkout $(git branch --format \"%(refname:lstrip=2)\" | ${lib.getExe' pkgs.fzf "fzf"})"; + # lol + build = "!cargo build"; + }; + + # TODO: See https://jvns.ca/blog/2024/02/16/popular-git-config-options + core.autocrlf = false; + core.editor = "${lib.getExe pkgs.neovim}"; + pull.ff = "only"; + push.autoSetupRemote = true; + init.defaultBranch = "main"; + merge.conflictstyle = "zdiff3"; + + # https://github.com/rust-lang/rust/blob/a83cf567b5949691de67f06895d9fe0404c40d27/.git-blame-ignore-revs + # doesn't work cause lol its an error to not have the file + # blame.ignoreRevsFile = ".git-blame-ignore-revs"; + + # This makes it so that pushing always uses SSH, even if the remote was configured as HTTPS. + "url \"git@github.com:\"".pushInsteadOf = "https://github.com/"; + "url \"git@gitlab.com:\"".pushInsteadOf = "https://gitlab.com/"; + "url \"git@gist.github.com:\"".pushInsteadOf = "https://gist.github.com/"; + }; + }; + + programs.difftastic = { + enable = true; + git.enable = true; + }; +} diff --git a/home-manager/home.nix b/home-manager/home.nix index ea28c5e..cfbbf59 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -1,7 +1,14 @@ # This is your home-manager configuration file # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) -{ inputs, lib, config, pkgs, ... }: { +{ pkgs +, inputs +, ... +}: +let + customPkgs = import ../custom-pkgs/default.nix pkgs; +in +{ # You can import other home-manager modules here imports = [ # If you want to use home-manager modules from other flakes (such as nix-colors): @@ -9,47 +16,72 @@ # You can also split up your configuration and import pieces of it here: # ./nvim.nix + ./common.nix + ./git.nix + ./firefox.nix + ./vscode.nix + ./waybar.nix + ./wallpaper.nix + ./swaylock.nix + ./swaync.nix ]; - nixpkgs = { - # You can add overlays here - overlays = [ - # If you want to use overlays exported from other flakes: - # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - # Workaround for https://github.com/nix-community/home-manager/issues/2942 - allowUnfreePredicate = (_: true); - }; - }; - - # TODO: Set your username home = { - username = "your-username"; - homeDirectory = "/home/your-username"; + username = "nora"; + homeDirectory = "/home/nora"; }; - # Add stuff for your user as you see fit: - # programs.neovim.enable = true; - # home.packages = with pkgs; [ steam ]; + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ obs-pipewire-audio-capture ]; + }; - # Enable home-manager and git - programs.home-manager.enable = true; - programs.git.enable = true; + programs.niri = { + config = builtins.readFile ./config.kdl; + }; + + services.playerctld.enable = true; + + home.packages = with pkgs; [ + audacity + customPkgs.cargo-bisect-rustc + customPkgs.run + customPkgs.unpem + customPkgs.flash-glove80 + discord + obsidian + prismlauncher + spotify + libreoffice + rustup # rustup from nix for rust :) + gamescope # so i can put it in steam startup command lines + wl-clipboard + (olympus.override { + celesteWrapper = "steam-run"; + }) + archipelago + (pkgs.writeShellApplication { + name = "lock-and-power-off-screen"; + text = '' + niri msg action power-off-monitors + exec swaylock + ''; + }) + (pkgs.writeShellApplication { + name = "shell.nix"; + text = '' + cat > shell.nix < {} }: pkgs.mkShell { + buildInputs = with pkgs; [ ]; + packages = with pkgs; [ ]; + } + EOF + + echo "use nix" > .envrc + ''; + }) + ] ++ import ./common-packages.nix { inherit pkgs inputs; }; # Nicely reload system units when changing configs systemd.user.startServices = "sd-switch"; - - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "22.11"; } diff --git a/home-manager/laptop.nix b/home-manager/laptop.nix new file mode 100644 index 0000000..c5239e3 --- /dev/null +++ b/home-manager/laptop.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + imports = [ + ./home.nix + ]; + + home.packages = with pkgs; [ krita ]; + + is-laptop = true; +} diff --git a/home-manager/swaylock.nix b/home-manager/swaylock.nix new file mode 100644 index 0000000..bcf8325 --- /dev/null +++ b/home-manager/swaylock.nix @@ -0,0 +1,6 @@ +{ ... }: { + programs.swaylock.enable = true; + programs.swaylock.settings = { + image = "/run/user/1000/lockscreen.png"; + }; +} diff --git a/home-manager/swaync.nix b/home-manager/swaync.nix new file mode 100644 index 0000000..8c61906 --- /dev/null +++ b/home-manager/swaync.nix @@ -0,0 +1,9 @@ +{ ... }: { + /*services.swaync = { + enable = true; + settings = { + "notification-window-preferred-output" = "Samsung Electric Company SMS24A450/460 HVMBA01140"; + }; + };*/ +} + diff --git a/home-manager/vscode.nix b/home-manager/vscode.nix new file mode 100644 index 0000000..9ca68c6 --- /dev/null +++ b/home-manager/vscode.nix @@ -0,0 +1,150 @@ +{ pkgs, lib, ... }: { + programs.vscode = { + enable = true; + package = pkgs.vscode; + mutableExtensionsDir = false; + profiles.default = { + enableUpdateCheck = false; + keybindings = [ + { + key = "ctrl+[BracketLeft]"; + command = "workbench.action.terminal.focus"; + when = "terminalProcessSupported"; + } + ]; + userSettings = { + # Note: In settings.json, `.` in a key is not equivalent to a nested object property. + # Language-specific + "rust-analyzer.server.path" = lib.getExe (pkgs.writeShellApplication { + name = "rust-analyzer-nightly-wrapper"; + # Ensure that we always use rust-analyzer from the nightly toolchain + # - in case a rust-toolchain.toml doens't have rust-analyzer + # - to ensure we get the latest fixes even if an older toolchain is used + # We can't do rust-analyzer +nightly, as that would inherit use of the nightly toolchain + # to all children of r-a, including cargo, which is very bad. + text = '' + ra=$(${lib.getExe' pkgs.rustup "rustup"} +nightly which rust-analyzer) + exec "$ra" + ''; + }); + "[nix]"."editor.formatOnSave" = true; + "[nix]"."editor.defaultFormatter" = "jnoortheen.nix-ide"; + "nix.enableLanguageServer" = true; + "nix.serverPath" = "${lib.getExe pkgs.nil}"; + "nix.serverSettings" = { + nil = { + formatting = { + command = [ "${lib.getExe pkgs.nixpkgs-fmt}" ]; + }; + }; + }; + "[typescript]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + "[javascript]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + "[json]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + "[jsonc]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + "[html]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + "[css]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + "[typescriptreact]"."editor.defaultFormatter" = "esbenp.prettier-vscode"; + # Generic + "window.zoomLevel" = 1; + "terminal.integrated.enableMultiLinePasteWarning" = false; + "git.confirmSync" = false; + "debug.allowBreakpointsEverywhere" = false; + # "editor.fontFamily" = "'Monaspace Neon Var', Arial"; + "editor.fontLigatures" = true; + "terminal.integrated.scrollback" = 5000; + "terminal.integrated.stickyScroll.enabled" = false; + "chat.agent.enabled" = false; + "workbench.secondarySideBar.defaultVisibility" = "hidden"; # fuck you for this naming, this is just ai garbage + "chat.disableAIFeatures" = true; + }; + extensions = with pkgs.vscode-extensions; [ + bmalehorn.vscode-fish + dbaeumer.vscode-eslint + eamodio.gitlens + esbenp.prettier-vscode + github.vscode-github-actions + golang.go + hashicorp.terraform + jnoortheen.nix-ide + timonwong.shellcheck + mads-hartmann.bash-ide-vscode + ms-azuretools.vscode-docker + ms-python.python + ms-vscode-remote.remote-ssh + ms-vscode.cmake-tools + ms-vscode.cpptools + ms-vscode.hexeditor + myriad-dreamin.tinymist + redhat.vscode-yaml + rust-lang.rust-analyzer + tamasfe.even-better-toml + tomoki1207.pdf + usernamehw.errorlens + vadimcn.vscode-lldb + ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ + { + publisher = "dtsvet"; + name = "vscode-wasm"; + version = "1.4.1"; + sha256 = "sha256-zs7E3pxf4P8kb3J+5zLoAO2dvTeepuCuBJi5s354k0I="; + } + { + publisher = "redhat"; + name = "ansible"; + version = "2.7.98"; + sha256 = "sha256-b3Z40IeQbtYci2LA4/OlJkfqMB78cWRNTNWd89lfhy4="; + } + { + publisher = "matthewpi"; + name = "caddyfile-support"; + version = "0.3.0"; + sha256 = "sha256-1yiOnvC2w33kiPRdQYskee38Cid/GOj9becLadP1fUY="; + } + { + publisher = "evan-buss"; + name = "font-switcher"; + version = "4.1.0"; + sha256 = "sha256-KkXUfA/W73kRfs1TpguXtZvBXFiSMXXzU9AYZGwpVsY="; + } + { + publisher = "polymeilex"; + name = "wgsl"; + version = "0.1.17"; + sha256 = "sha256-vGqvVrr3wNG6HOJxOnJEohdrzlBYspysTLQvWuP0QIw="; + } + { + publisher = "sunshaoce"; + name = "risc-v"; + version = "1.158.12"; + sha256 = "sha256-+HLAkxU9hIhP8tn0jVI2L2HcYusmHSpoaG7dHA7WgxA="; + } + { + publisher = "styled-components"; + name = "vscode-styled-components"; + version = "1.7.8"; + sha256 = "sha256-VoLAjBcAizTxd+BHwXoNSlSxqXno3PjVxaickLCtnsw="; + } + ] ++ [ + ((pkgs.vscode-utils.buildVscodeExtension { + pname = "riverdelta"; + version = "0.1.0"; + src = builtins.fetchGit { + url = "https://github.com/Noratrieb/riverdelta"; + rev = "64d81b56084d9a7663517b367b4533fb8ea83a92"; + }; + vscodeExtPublisher = "Noratrieb"; + vscodeExtName = "riverdelta"; + vscodeExtUniqueId = "Noratrieb.riverdelta"; + buildPhase = '' + runHook preBuild; + cd ./vscode + runHook postBuild; + ''; + }).overrideAttrs + (_: { sourceRoot = null; })) + ]; + }; + + }; +} diff --git a/home-manager/wallpaper.nix b/home-manager/wallpaper.nix new file mode 100644 index 0000000..44d2135 --- /dev/null +++ b/home-manager/wallpaper.nix @@ -0,0 +1,37 @@ +{ pkgs, config, ... }: + + +let + pkg = (import + (pkgs.fetchFromGitHub { + owner = "Noratrieb"; + repo = "colouncher"; + rev = "a68d0dff63c32f84354f97aed5ac52ce3e0fa284"; + hash = "sha256-NhZMBKxqHCQSvvj2NjXUlCQ5JvRPdGTnftTxdciLlPQ="; + })) + { inherit pkgs; }; +in +{ + systemd.user.services.colouncher = { + Unit = { + Description = "Color-based program-launching wallpaper for Wayland"; + PartOf = [ + config.wayland.systemd.target + ]; + After = [ config.wayland.systemd.target ]; + ConditionEnvironment = "WAYLAND_DISPLAY"; + }; + Service = { + ExecStart = pkgs.lib.getExe pkg; + Restart = "on-failure"; + Type = "notify"; + Environment = [ + "LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.vulkan-loader]}" + ]; + }; + + Install.WantedBy = [ + config.wayland.systemd.target + ]; + }; +} diff --git a/home-manager/waybar.nix b/home-manager/waybar.nix new file mode 100644 index 0000000..26bb5a7 --- /dev/null +++ b/home-manager/waybar.nix @@ -0,0 +1,257 @@ +{ config, pkgs, lib, ... }: + +{ + options.is-laptop = lib.mkEnableOption "whether the computer is a laptop"; + + config = { + home.file."${config.xdg.configHome}/waybar/config.jsonc" = { + text = + builtins.toJSON { + height = 35; + spacing = 4; + + modules-left = [ + "systemd-failed-units" + "custom/music-back" + "mpris" + "custom/music-next" + ]; + modules-center = [ + "clock" + ]; + modules-right = [ + "bluetooth" + "privacy" + "pulseaudio" + "cpu" + "memory" + "tray" + ] ++ + (if (config.is-laptop) then + [ "network" "power-profiles-daemon" "battery" ] + else [ ]) ++ + [ + "custom/power" + ]; + + systemd-failed-units = { + hide-on-ok = true; # Hide if there are zero failed units. + format = "✗ {nr_failed}"; + # https://github.com/Alexays/Waybar/issues/4241#issuecomment-3277122575 + format-ok = "✓ there is an 'activating' unit"; + system = true; # monitor sytem units + user = true; # monitor user units + }; + "custom/music-back" = { + format = "⏴"; + tooltip = true; + tooltip-format = "Play previous song"; + on-click = "${lib.getExe pkgs.playerctl} previous"; + }; + mpris = { + format = "{status_icon} {dynamic}"; + dynamic-order = [ "title" "artist" ]; + status-icons = { + paused = "⏸"; + }; + }; + "custom/music-next" = { + format = "⏵"; + tooltip = true; + tooltip-format = "Play next song"; + on-click = "${lib.getExe pkgs.playerctl} next"; + }; + clock = { + interval = 1; + format = "{:%a %F %H:%M:%S}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "right"; + on-scroll = 1; + format = { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weekdays = "{}"; + today = "{}"; + }; + }; + actions = { + on-click-right = "mode"; + on-scroll-up = "shift_up"; + on-scroll-down = "shift_down"; + }; + }; + + bluetooth = { + format = " {status}"; + format-disabled = ""; # an empty format will hide the module + format-connected = " {num_connections} connected"; + on-click = lib.getExe' pkgs.blueman "blueman"; + }; + pulseaudio = { + # "scroll-step": 1, // %, can be a float + "format" = "{volume}% {icon} {format_source}"; + "format-bluetooth" = "{volume}% {icon} {format_source}"; + "format-bluetooth-muted" = " {icon} {format_source}"; + "format-muted" = " {format_source}"; + "format-source" = "{volume}% "; + "format-source-muted" = ""; + "format-icons" = { + "headphone" = ""; + "hands-free" = ""; + "headset" = ""; + "phone" = ""; + "portable" = ""; + "car" = ""; + "default" = [ "" "" "" ]; + }; + "on-click" = lib.getExe pkgs.pavucontrol; + }; + cpu = { + format = "{usage}% "; + tooltip = false; + }; + memory = { + format = "{}% "; + }; + tray = { + spacing = 10; + }; + "network" = { + # "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi" = " ({signalStrength}%)"; + "format-ethernet" = "{ipaddr}/{cidr} "; + "tooltip-format" = "{ifname} via {gwaddr}  ({ipaddr}/{cidr})"; + "format-linked" = "{ifname} (No IP) "; + "format-disconnected" = "Disconnected ⚠"; + "format-alt" = "{ifname}: {ipaddr}/{cidr}"; + }; + "power-profiles-daemon" = { + "format" = "{icon}"; + "tooltip-format" = "Power profile: {profile}\nDriver: {driver}"; + "tooltip" = true; + "format-icons" = { + "default" = ""; + "performance" = ""; + "balanced" = ""; + "power-saver" = ""; + }; + }; + "battery" = { + "states" = { + # "good": 95, + "warning" = 30; + "critical" = 5; + }; + "format" = "{capacity}% {icon}"; + "format-full" = "{capacity}% {icon}"; + "format-charging" = "{capacity}% "; + "format-plugged" = "{capacity}% "; + "format-alt" = "{time} {icon}"; + # "format-good": "", // An empty format will hide the module + # "format-full": "", + "format-icons" = [ "" "" "" "" "" ]; + }; + "custom/power" = + let + power-menu = pkgs.writeText "power_menu.xml" '' + + + + + + Lock 🔒 + + + + + + + + Reboot ♻️ + + + + + Poweroff 💤 + + + + + ''; + in + { + "format" = "⏻"; + "tooltip" = false; + "menu" = "on-click"; + "menu-file" = power-menu; + "menu-actions" = { + "lock" = "lock-and-power-off-screen"; + "reboot" = "reboot"; + "poweroff" = "poweroff"; + }; + }; + }; + }; + home.file."${config.xdg.configHome}/waybar/style.css" = { + text = '' + ${builtins.readFile ./default-waybar-style.css} + + window#waybar { + background: linear-gradient( + to right, + rgb(131, 80, 117) 15%, + rgb(158, 103, 143) 30%, + rgb(131, 80, 117) 45%, + #db88c5 + ); + border-bottom: none; + color: black; + } + + #systemd-failed-units { + padding-left: 30px; + padding-right: 30px; + background-color: red; + } + + #mpris { + color: white; + } + + #custom-music-back, #custom-music-next { + font-size: 20px; + color: white; + } + + #custom-music-back { + padding: 0 10px 0 15px; + } + #custom-music-next { + padding: 0 10px; + } + + #clock { + background: unset; + color: white; + } + + #privacy *, #pulseaudio, #cpu, #memory, #tray, #network, #power-profiles-daemon, #battery { + background-color: unset; + color: black; + } + + #custom-power { + padding-left: 15px; + padding-right: 15px; + font-size: 30px; + background-color: rebeccapurple; + color: white; + } + ''; + }; + }; +} diff --git a/nixos/bsod/bsod.png b/nixos/bsod/bsod.png new file mode 100644 index 0000000..d744891 Binary files /dev/null and b/nixos/bsod/bsod.png differ diff --git a/nixos/bsod/bsod.typ b/nixos/bsod/bsod.typ new file mode 100644 index 0000000..ba6d6f6 --- /dev/null +++ b/nixos/bsod/bsod.typ @@ -0,0 +1,46 @@ +#import "@preview/cades:0.3.1": qr-code + +#let background-color = rgb(0x00, 0x78, 0xd7) +#let url = "https://noratrieb.dev" +#let percent = sys.inputs.at("percent", default: "20"); +#let stopcode = sys.inputs.at("stopcode", default: "KASAN_ENLIGHTENMENT_VIOLATION") + +#set page( + flipped: true, + margin: ( + top: 184pt, + right: 0pt, + left: 190pt, + bottom: 0pt, + ), + width: 1080pt, + height: 1920pt, + fill: background-color, +) + +#set text(font: "Segoe UI") + +#set text(rgb(255, 255, 255)) + +// :( +#text(size: 210pt, [:(]) + +#place(dx: 17pt, dy: 77pt, text(size: 42pt, [Your PC ran into a problem and needs to restart. We\'re])) +#place(dx: 21pt, dy: 136pt, text(size: 42pt, [just collecting some error info, and then we\'ll restart for])) +#place(dx: 19pt, dy: 195pt, text(size: 42pt, [you.])) + +#place(dx: 18pt, dy: 284pt, text(size: 42pt, [#percent% complete])) + +#place(dx: 152pt, dy: 371pt, text( + size: 20pt, + [For more information about this issue and possible fixes, visit https://www.windows.com/stopcode], +)) + +#place(dx: 17pt, dy: 371pt, [ + #rect(width: 115pt, height: 115pt, inset: 9pt, fill: white, qr-code(url, color: background-color)) +]) + + +#place(dx: 151pt, dy: 438pt, text(size: 16pt, [If you call a support person, give them this info:])) + +#place(dx: 151pt, dy: 472pt, text(size: 16pt, [Stop code: #stopcode])) diff --git a/nixos/bsod/codes.txt b/nixos/bsod/codes.txt new file mode 100644 index 0000000..c234438 --- /dev/null +++ b/nixos/bsod/codes.txt @@ -0,0 +1,379 @@ +APC_INDEX_MISMATCH +DEVICE_QUEUE_NOT_BUSY +INVALID_AFFINITY_SET +INVALID_DATA_ACCESS_TRAP +INVALID_PROCESS_ATTACH_ATTEMPT +INVALID_PROCESS_DETACH_ATTEMPT +INVALID_SOFTWARE_INTERRUPT +IRQL_NOT_DISPATCH_LEVEL +IRQL_NOT_GREATER_OR_EQUAL +IRQL_NOT_LESS_OR_EQUAL +NO_EXCEPTION_HANDLING_SUPPORT +MAXIMUM_WAIT_OBJECTS_EXCEEDED +MUTEX_LEVEL_NUMBER_VIOLATION +NO_USER_MODE_CONTEXT +SPIN_LOCK_ALREADY_OWNED +SPIN_LOCK_NOT_OWNED +THREAD_NOT_MUTEX_OWNER +TRAP_CAUSE_UNKNOWN +EMPTY_THREAD_REAPER_LIST +CREATE_DELETE_LOCK_NOT_LOCKED +LAST_CHANCE_CALLED_FROM_KMODE +CID_HANDLE_CREATION +CID_HANDLE_DELETION +REFERENCE_BY_POINTER +BAD_POOL_HEADER +MEMORY_MANAGEMENT +PFN_SHARE_COUNT +PFN_REFERENCE_COUNT +NO_SPIN_LOCK_AVAILABLE +KMODE_EXCEPTION_NOT_HANDLED +SHARED_RESOURCE_CONV_ERROR +KERNEL_APC_PENDING_DURING_EXIT +QUOTA_UNDERFLOW +FILE_SYSTEM +FAT_FILE_SYSTEM +NTFS_FILE_SYSTEM +NPFS_FILE_SYSTEM +CDFS_FILE_SYSTEM +RDR_FILE_SYSTEM +CORRUPT_ACCESS_TOKEN +SECURITY_SYSTEM +INCONSISTENT_IRP +PANIC_STACK_SWITCH +PORT_DRIVER_INTERNAL +SCSI_DISK_DRIVER_INTERNAL +DATA_BUS_ERROR +INSTRUCTION_BUS_ERROR +SET_OF_INVALID_CONTEXT +PHASE0_INITIALIZATION_FAILED +PHASE1_INITIALIZATION_FAILED +UNEXPECTED_INITIALIZATION_CALL +CACHE_MANAGER +NO_MORE_IRP_STACK_LOCATIONS +DEVICE_REFERENCE_COUNT_NOT_ZERO +FLOPPY_INTERNAL_ERROR +SERIAL_DRIVER_INTERNAL +SYSTEM_EXIT_OWNED_MUTEX +SYSTEM_UNWIND_PREVIOUS_USER +SYSTEM_SERVICE_EXCEPTION +INTERRUPT_UNWIND_ATTEMPTED +INTERRUPT_EXCEPTION_NOT_HANDLED +MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED +NO_MORE_SYSTEM_PTES +TARGET_MDL_TOO_SMALL +MUST_SUCCEED_POOL_EMPTY +ATDISK_DRIVER_INTERNAL +NO_SUCH_PARTITION +MULTIPLE_IRP_COMPLETE_REQUESTS +INSUFFICIENT_SYSTEM_MAP_REGS +DEREF_UNKNOWN_LOGON_SESSION +REF_UNKNOWN_LOGON_SESSION +CANCEL_STATE_IN_COMPLETED_IRP +PAGE_FAULT_WITH_INTERRUPTS_OFF +IRQL_GT_ZERO_AT_SYSTEM_SERVICE +STREAMS_INTERNAL_ERROR +FATAL_UNHANDLED_HARD_ERROR +NO_PAGES_AVAILABLE +PFN_LIST_CORRUPT +NDIS_INTERNAL_ERROR +PAGE_FAULT_IN_NONPAGED_AREA +REGISTRY_ERROR +MAILSLOT_FILE_SYSTEM +NO_BOOT_DEVICE +LM_SERVER_INTERNAL_ERROR +DATA_COHERENCY_EXCEPTION +INSTRUCTION_COHERENCY_EXCEPTION +XNS_INTERNAL_ERROR +FTDISK_INTERNAL_ERROR +PINBALL_FILE_SYSTEM +CRITICAL_SERVICE_FAILED +SET_ENV_VAR_FAILED +HAL_INITIALIZATION_FAILED +UNSUPPORTED_PROCESSOR +OBJECT_INITIALIZATION_FAILED +SECURITY_INITIALIZATION_FAILED +PROCESS_INITIALIZATION_FAILED +HAL1_INITIALIZATION_FAILED +OBJECT1_INITIALIZATION_FAILED +SECURITY1_INITIALIZATION_FAILED +SYMBOLIC_INITIALIZATION_FAILED +MEMORY1_INITIALIZATION_FAILED +CACHE_INITIALIZATION_FAILED +CONFIG_INITIALIZATION_FAILED +FILE_INITIALIZATION_FAILED +IO1_INITIALIZATION_FAILED +LPC_INITIALIZATION_FAILED +PROCESS1_INITIALIZATION_FAILED +REFMON_INITIALIZATION_FAILED +SESSION1_INITIALIZATION_FAILED +SESSION2_INITIALIZATION_FAILED +SESSION3_INITIALIZATION_FAILED +SESSION4_INITIALIZATION_FAILED +SESSION5_INITIALIZATION_FAILED +ASSIGN_DRIVE_LETTERS_FAILED +CONFIG_LIST_FAILED +BAD_SYSTEM_CONFIG_INFO +CANNOT_WRITE_CONFIGURATION +PROCESS_HAS_LOCKED_PAGES +KERNEL_STACK_INPAGE_ERROR +PHASE0_EXCEPTION +MISMATCHED_HAL +KERNEL_DATA_INPAGE_ERROR +INACCESSIBLE_BOOT_DEVICE +BUGCODE_NDIS_DRIVER +INSTALL_MORE_MEMORY +SYSTEM_THREAD_EXCEPTION_NOT_HANDLED +UNEXPECTED_KERNEL_MODE_TRAP +NMI_HARDWARE_FAILURE +SPIN_LOCK_INIT_FAILURE +DFS_FILE_SYSTEM +SETUP_FAILURE +MBR_CHECKSUM_MISMATCH +KERNEL_MODE_EXCEPTION_NOT_HANDLED +PP0_INITIALIZATION_FAILED +PP1_INITIALIZATION_FAILED +UP_DRIVER_ON_MP_SYSTEM +INVALID_KERNEL_HANDLE +KERNEL_STACK_LOCKED_AT_EXIT +INVALID_WORK_QUEUE_ITEM +BOUND_IMAGE_UNSUPPORTED +END_OF_NT_EVALUATION_PERIOD +INVALID_REGION_OR_SEGMENT +SYSTEM_LICENSE_VIOLATION +UDFS_FILE_SYSTEM +MACHINE_CHECK_EXCEPTION +USER_MODE_HEALTH_MONITOR +DRIVER_POWER_STATE_FAILURE +INTERNAL_POWER_ERROR +PCI_BUS_DRIVER_INTERNAL +MEMORY_IMAGE_CORRUPT +ACPI_DRIVER_INTERNAL +CNSS_FILE_SYSTEM_FILTER +ACPI_BIOS_ERROR +BAD_EXHANDLE +HAL_MEMORY_ALLOCATION +VIDEO_DRIVER_DEBUG_REPORT_REQUEST +BGI_DETECTED_VIOLATION +VIDEO_DRIVER_INIT_FAILURE +ATTEMPTED_SWITCH_FROM_DPC +CHIPSET_DETECTED_ERROR +SESSION_HAS_VALID_VIEWS_ON_EXIT +NETWORK_BOOT_INITIALIZATION_FAILED +NETWORK_BOOT_DUPLICATE_ADDRESS +INVALID_HIBERNATED_STATE +ATTEMPTED_WRITE_TO_READONLY_MEMORY +MUTEX_ALREADY_OWNED +SPECIAL_POOL_DETECTED_MEMORY_CORRUPTION +BAD_POOL_CALLER +DRIVER_VERIFIER_DETECTED_VIOLATION +DRIVER_CORRUPTED_EXPOOL +DRIVER_CAUGHT_MODIFYING_FREED_POOL +TIMER_OR_DPC_INVALID +IRQL_UNEXPECTED_VALUE +DRIVER_VERIFIER_IOMANAGER_VIOLATION +PNP_DETECTED_FATAL_ERROR +DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS +PAGE_FAULT_IN_FREED_SPECIAL_POOL +PAGE_FAULT_BEYOND_END_OF_ALLOCATION +DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS +TERMINAL_SERVER_DRIVER_MADE_INCORRECT_MEMORY_REFERENCE +DRIVER_CORRUPTED_MMPOOL +DRIVER_IRQL_NOT_LESS_OR_EQUAL +BUGCODE_ID_DRIVER +DRIVER_PORTION_MUST_BE_NONPAGED +SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD +DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL +DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION +DRIVER_UNMAPPING_INVALID_VIEW +DRIVER_USED_EXCESSIVE_PTES +LOCKED_PAGES_TRACKER_CORRUPTION +SYSTEM_PTE_MISUSE +DRIVER_CORRUPTED_SYSPTES +DRIVER_INVALID_STACK_ACCESS +POOL_CORRUPTION_IN_FILE_AREA +IMPERSONATING_WORKER_THREAD +ACPI_BIOS_FATAL_ERROR +WORKER_THREAD_RETURNED_AT_BAD_IRQL +MANUALLY_INITIATED_CRASH +RESOURCE_NOT_OWNED +WORKER_INVALID +DRIVER_VERIFIER_DMA_VIOLATION +INVALID_FLOATING_POINT_STATE +INVALID_CANCEL_OF_FILE_OPEN +ACTIVE_EX_WORKER_THREAD_TERMINATION +THREAD_STUCK_IN_DEVICE_DRIVER +DIRTY_MAPPED_PAGES_CONGESTION +SESSION_HAS_VALID_SPECIAL_POOL_ON_EXIT +UNMOUNTABLE_BOOT_VOLUME +CRITICAL_PROCESS_DIED +STORAGE_MINIPORT_ERROR +SCSI_VERIFIER_DETECTED_VIOLATION +HARDWARE_INTERRUPT_STORM +DISORDERLY_SHUTDOWN +CRITICAL_OBJECT_TERMINATION +FLTMGR_FILE_SYSTEM +PCI_VERIFIER_DETECTED_VIOLATION +DRIVER_OVERRAN_STACK_BUFFER +RAMDISK_BOOT_INITIALIZATION_FAILED +DRIVER_RETURNED_STATUS_REPARSE_FOR_VOLUME_OPEN +HTTP_DRIVER_CORRUPTED +ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY +DIRTY_NOWRITE_PAGES_CONGESTION +BUGCODE_USB_DRIVER +RESERVE_QUEUE_OVERFLOW +LOADER_BLOCK_MISMATCH +CLOCK_WATCHDOG_TIMEOUT +DPC_WATCHDOG_TIMEOUT +MUP_FILE_SYSTEM +AGP_INVALID_ACCESS +AGP_GART_CORRUPTION +AGP_ILLEGALLY_REPROGRAMMED +THIRD_PARTY_FILE_SYSTEM_FAILURE +CRITICAL_STRUCTURE_CORRUPTION +APP_TAGGING_INITIALIZATION_FAILED +FSRTL_EXTRA_CREATE_PARAMETER_VIOLATION +WDF_VIOLATION +VIDEO_MEMORY_MANAGEMENT_INTERNAL +RESOURCE_MANAGER_EXCEPTION_NOT_HANDLED +RECURSIVE_NMI +MSRPC_STATE_VIOLATION +VIDEO_DXGKRNL_FATAL_ERROR +VIDEO_SHADOW_DRIVER_FATAL_ERROR +AGP_INTERNAL +VIDEO_TDR_FAILURE +VIDEO_TDR_TIMEOUT_DETECTED +VIDEO_SCHEDULER_INTERNAL_ERROR +EM_INITIALIZATION_FAILURE +DRIVER_RETURNED_HOLDING_CANCEL_LOCK +ATTEMPTED_WRITE_TO_CM_PROTECTED_STORAGE +EVENT_TRACING_FATAL_ERROR +TOO_MANY_RECURSIVE_FAULTS +INVALID_DRIVER_HANDLE +BITLOCKER_FATAL_ERROR +DRIVER_VIOLATION +WHEA_INTERNAL_ERROR +CRYPTO_SELF_TEST_FAILURE +WHEA_UNCORRECTABLE_ERROR +NMR_INVALID_STATE +NETIO_INVALID_POOL_CALLER +PAGE_NOT_ZERO +WORKER_THREAD_RETURNED_WITH_BAD_IO_PRIORITY +WORKER_THREAD_RETURNED_WITH_BAD_PAGING_IO_PRIORITY +MUI_NO_VALID_SYSTEM_LANGUAGE +FAULTY_HARDWARE_CORRUPTED_PAGE +EXFAT_FILE_SYSTEM +VOLSNAP_OVERLAPPED_TABLE_ACCESS +INVALID_MDL_RANGE +VHD_BOOT_INITIALIZATION_FAILED +DYNAMIC_ADD_PROCESSOR_MISMATCH +INVALID_EXTENDED_PROCESSOR_STATE +RESOURCE_OWNER_POINTER_INVALID +DPC_WATCHDOG_VIOLATION +DRIVE_EXTENDER +REGISTRY_FILTER_DRIVER_EXCEPTION +VHD_BOOT_HOST_VOLUME_NOT_ENOUGH_SPACE +WIN32K_HANDLE_MANAGER +GPIO_CONTROLLER_DRIVER_ERROR +KERNEL_SECURITY_CHECK_FAILURE +KERNEL_MODE_HEAP_CORRUPTION +PASSIVE_INTERRUPT_ERROR +INVALID_IO_BOOST_STATE +CRITICAL_INITIALIZATION_FAILURE +STORAGE_DEVICE_ABNORMALITY_DETECTED +PROCESSOR_DRIVER_INTERNAL +BUGCODE_USB3_DRIVER +SECURE_BOOT_VIOLATION +ABNORMAL_RESET_DETECTED +REFS_FILE_SYSTEM +KERNEL_WMI_INTERNAL +SOC_SUBSYSTEM_FAILURE +FATAL_ABNORMAL_RESET_ERROR +EXCEPTION_SCOPE_INVALID +SOC_CRITICAL_DEVICE_REMOVED +PDC_WATCHDOG_TIMEOUT +TCPIP_AOAC_NIC_ACTIVE_REFERENCE_LEAK +UNSUPPORTED_INSTRUCTION_MODE +INVALID_PUSH_LOCK_FLAGS +KERNEL_LOCK_ENTRY_LEAKED_ON_THREAD_TERMINATION +UNEXPECTED_STORE_EXCEPTION +OS_DATA_TAMPERING +KERNEL_THREAD_PRIORITY_FLOOR_VIOLATION +ILLEGAL_IOMMU_PAGE_FAULT +HAL_ILLEGAL_IOMMU_PAGE_FAULT +SDBUS_INTERNAL_ERROR +WORKER_THREAD_RETURNED_WITH_SYSTEM_PAGE_PRIORITY_ACTIVE +WIN32K_ATOMIC_CHECK_FAILURE +KERNEL_AUTO_BOOST_INVALID_LOCK_RELEASE +WORKER_THREAD_TEST_CONDITION +WIN32K_CRITICAL_FAILURE +INVALID_RUNDOWN_PROTECTION_FLAGS +INVALID_SLOT_ALLOCATOR_FLAGS +ERESOURCE_INVALID_RELEASE +CLUSTER_CSV_CLUSSVC_DISCONNECT_WATCHDOG +CRYPTO_LIBRARY_INTERNAL_ERROR +COREMSGCALL_INTERNAL_ERROR +COREMSG_INTERNAL_ERROR +ELAM_DRIVER_DETECTED_FATAL_ERROR +PROFILER_CONFIGURATION_ILLEGAL +MICROCODE_REVISION_MISMATCH +VIDEO_DWMINIT_TIMEOUT_FALLBACK_BDD +BAD_OBJECT_HEADER +SECURE_KERNEL_ERROR +HYPERGUARD_VIOLATION +SECURE_FAULT_UNHANDLED +KERNEL_PARTITION_REFERENCE_VIOLATION +PF_DETECTED_CORRUPTION +KERNEL_AUTO_BOOST_LOCK_ACQUISITION_WITH_RAISED_IRQL +LOADER_ROLLBACK_DETECTED +WIN32K_SECURITY_FAILURE +KERNEL_STORAGE_SLOT_IN_USE +WORKER_THREAD_RETURNED_WHILE_ATTACHED_TO_SILO +TTM_FATAL_ERROR +WIN32K_POWER_WATCHDOG_TIMEOUT +TTM_WATCHDOG_TIMEOUT +WIN32K_CALLOUT_WATCHDOG_BUGCHECK +EXCEPTION_ON_INVALID_STACK +UNWIND_ON_INVALID_STACK +FAST_ERESOURCE_PRECONDITION_VIOLATION +STORE_DATA_STRUCTURE_CORRUPTION +MANUALLY_INITIATED_POWER_BUTTON_HOLD +SYNTHETIC_WATCHDOG_TIMEOUT +INVALID_SILO_DETACH +INVALID_CALLBACK_STACK_ADDRESS +INVALID_KERNEL_STACK_ADDRESS +HARDWARE_WATCHDOG_TIMEOUT +CPI_FIRMWARE_WATCHDOG_TIMEOUT +WORKER_THREAD_INVALID_STATE +WFP_INVALID_OPERATION +DRIVER_PNP_WATCHDOG +WORKER_THREAD_RETURNED_WITH_NON_DEFAULT_WORKLOAD_CLASS +EFS_FATAL_ERROR +UCMUCSI_FAILURE +HAL_IOMMU_INTERNAL_ERROR +HAL_BLOCKED_PROCESSOR_INTERNAL_ERROR +IPI_WATCHDOG_TIMEOUT +DMA_COMMON_BUFFER_VECTOR_ERROR +BUGCODE_MBBADAPTER_DRIVER +BUGCODE_WIFIADAPTER_DRIVER +PROCESSOR_START_TIMEOUT +VIDEO_DXGKRNL_SYSMM_FATAL_ERROR +ILLEGAL_ATS_INITIALIZATION +SECURE_PCI_CONFIG_SPACE_ACCESS_VIOLATION +DAM_WATCHDOG_TIMEOUT +HANDLE_ERROR_ON_CRITICAL_THREAD +KASAN_ENLIGHTENMENT_VIOLATION +KASAN_ILLEGAL_ACCESS +XBOX_ERACTRL_CS_TIMEOUT +BC_BLUETOOTH_VERIFIER_FAULT +BC_BTHMINI_VERIFIER_FAULT +HYPERVISOR_ERROR +SYSTEM_THREAD_EXCEPTION_NOT_HANDLED_M +UNEXPECTED_KERNEL_MODE_TRAP_M +KERNEL_MODE_EXCEPTION_NOT_HANDLED_M +THREAD_STUCK_IN_DEVICE_DRIVER_M +THREAD_TERMINATE_HELD_MUTEX +STATUS_CANNOT_LOAD_REGISTRY_FILE +WINLOGON_FATAL_ERROR +STATUS_IMAGE_CHECKSUM_MISMATCH +MANUALLY_INITIATED_CRASH1 diff --git a/nixos/bsod/default.nix b/nixos/bsod/default.nix new file mode 100644 index 0000000..581705d --- /dev/null +++ b/nixos/bsod/default.nix @@ -0,0 +1,9 @@ +{ pkgs, lib }: pkgs.writeShellApplication { + name = "regenerate-bsod-lockscreen"; + text = '' + echo "Regenerating the lock screen..." + stopcode=$(shuf -n 1 < "${./codes.txt}") + percent=$(shuf -i 0-101 -n1) + ${lib.getExe pkgs.typst} compile --input "stopcode=$stopcode" --input "percent=$percent" --font-path ${./fonts} ${./bsod.typ} --format png --ppi 200 "/run/user/$(id -u)/lockscreen.png" + ''; +} diff --git a/nixos/bsod/fonts/segoeuisemilight.ttf b/nixos/bsod/fonts/segoeuisemilight.ttf new file mode 100644 index 0000000..2dc260e Binary files /dev/null and b/nixos/bsod/fonts/segoeuisemilight.ttf differ diff --git a/nixos/configuration.nix b/nixos/configuration.nix index bd8fd26..bbbaaf6 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -8,30 +8,26 @@ # inputs.hardware.nixosModules.common-cpu-amd # inputs.hardware.nixosModules.common-ssd - # You can also split up your configuration and import pieces of it here: - # ./users.nix - - # Import your generated (nixos-generate-config) hardware configuration - ./hardware-configuration.nix + inputs.niri.nixosModules.niri + inputs.clippyboard.nixosModules.default ]; nixpkgs = { - # You can add overlays here overlays = [ # If you want to use overlays exported from other flakes: # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) + inputs.nur.overlays.default + inputs.niri.overlays.niri + # final: prev: { + # curl = prev.curl.override { + # # vquic is sad right now. + # # http3Support = true; + # }; + # ) ]; - # Configure your nixpkgs instance config = { - # Disable if you don't want unfree packages allowUnfree = true; + nvidia.acceptLicense = true; }; }; @@ -52,41 +48,277 @@ }; }; - # FIXME: Add the rest of your current configuration + networking.networkmanager.enable = true; - # TODO: Set your hostname - networking.hostName = "your-hostname"; + time.timeZone = "Europe/Zurich"; - # TODO: This is just an example, be sure to use whatever bootloader you prefer - boot.loader.systemd-boot.enable = true; + i18n.defaultLocale = "en_US.UTF-8"; - # TODO: Configure your system-wide user settings (groups, etc), add more users as needed. - users.users = { - # FIXME: Replace with your username - your-username = { - # TODO: You can set an initial password for your user. - # If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install. - # Be sure to change it (using passwd) after rebooting! - initialPassword = "correcthorsebatterystaple"; - isNormalUser = true; - openssh.authorizedKeys.keys = [ - # TODO: Add your SSH public key(s) here, if you plan on using SSH to connect - ]; - # TODO: Be sure to add any other groups you need (such as networkmanager, audio, docker, etc) - extraGroups = [ "wheel" ]; + # Bootloader. + # boot.loader.systemd-boot.enable = true; + + boot.binfmt = { + emulatedSystems = [ /*"wasm32-wasi"*/ "aarch64-linux" ]; # https://github.com/NixOS/nixpkgs/issues/444423 + preferStaticEmulators = true; # required to work with podman (apparently) + }; + + boot.kernelPackages = pkgs.linuxPackages_latest; + + boot.kernel.sysctl = { + "net.ipv4.ip_forward" = 1; + "net.ipv6.conf.all.forwarding" = 1; + # 100 seems to be a good value for SSDs https://chrisdown.name/2018/01/02/in-defence-of-swap.html, + # as anon and file pages are equally expensive so 100 balances them out. + "vm.swappiness" = 100; + # 340 is 0x154, which enables Rqs + # - n (denice RT tasks) + # - e (SIGTERM everyone but PID 1) + # - i (same but SIGKILL) + # - f (hallucinate OOM and kill one unlucky motherfucker) + # - s (Sync Em All 1989) + # - k (ghetto Ctrl+Alt+Del-to-log-in) + # - r (unraw) + "kernel.sysrq" = 340; + }; + + # Enable the Wayland windowing system. + services.displayManager.gdm.enable = true; + services.desktopManager = { + gnome = { + enable = true; + extraGSettingsOverrides = '' + [org.gnome.mutter] + experimental-features=['scale-monitor-framebuffer'] + ''; + extraGSettingsOverridePackages = [ pkgs.mutter ]; + }; + }; + services.xserver = { + enable = true; + desktopManager.wallpaper.mode = "fill"; + + # Configure keymap in X11 + xkb = { + layout = "ch"; + variant = ""; + }; + + # mouse settings + # https://unix.stackexchange.com/questions/58900/how-to-scroll-the-screen-using-the-middle-click + #libinput.mouse = { + # scrollMethod = "button"; + # # 2=middle mouse button + # scrollButton = 2; + #}; + }; + + hardware.graphics = { + enable = true; + enable32Bit = true; # for games stores?? + extraPackages = with pkgs; [ + libva-vdpau-driver # i have no idea what this is doing lol + ]; + }; + + niri-flake.cache.enable = false; + programs.niri = { + enable = true; + package = pkgs.niri; + }; + services.displayManager.enable = true; + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-gnome pkgs.gnome-keyring ]; + services.gnome = { + gcr-ssh-agent.enable = true; + }; + programs.waybar.enable = true; + + # something is wrong https://github.com/NixOS/nixpkgs/issues/477219 + services.speechd.enable = lib.mkForce false; + + # lol what https://github.com/NixOS/nixpkgs/issues/462935 + systemd.user.services.orca.wantedBy = lib.mkForce [ ]; + + services.clippyboard.enable = true; + + services.flatpak.enable = true; + + programs.appimage = { + enable = true; + binfmt = true; + }; + + console.keyMap = "sg"; + + # do you even print bro? have you ever printed bro? don't cups me bro. + services.printing.enable = false; + + services.earlyoom = { + enable = true; + enableNotifications = true; + # as soon as it starts swapping its SO over (hm) + freeSwapThreshold = 90; + }; + + # Shows notification for `net.nuetzlich.SystemNotifications.Notify` D-Bus messages + services.systembus-notify.enable = true; + + # Enable sound with pipewire. + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + fonts = { + enableDefaultPackages = true; + packages = with pkgs; [ fira-code monaspace font-awesome ]; + }; + + users = { + users = { + nora = { + uid = 1000; + isNormalUser = true; + home = "/home/nora"; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG0n1ikUG9rYqobh7WpAyXrqZqxQoQ2zNJrFPj12gTpP" + ]; + extraGroups = [ "wheel" "networkmanager" "audio" "libvirtd" "docker" ]; + packages = with pkgs; [ + vscode + chromium + ]; + shell = pkgs.fish; + }; + }; + extraGroups = { + vboxusers = { + members = [ "nora" ]; + }; }; }; - # This setups a SSH server. Very important if you're setting up a headless system. - # Feel free to remove if you don't need it. - services.openssh = { - enable = true; - # Forbid root login through SSH. - permitRootLogin = "no"; - # Use keys only. Remove if you want to SSH using password (not recommended) - passwordAuthentication = false; + systemd.user = { + services.regenerate-bsod-lockscreen = { + description = "Regenerate the lock screen image"; + serviceConfig = { + Type = "oneshot"; + ExecStart = lib.getExe (import ./bsod { inherit pkgs lib; }); + }; + }; + timers.regenerate-bsod-lockscreen = { + description = "Regenerate the lock screen image"; + wantedBy = [ "timers.target" ]; + timerConfig = { + Unit = "regenerate-bsod-lockscreen.service"; + OnBootSec = "10s"; + OnUnitActiveSec = "60s"; + AccuracySec = "5s"; + }; + }; }; - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - system.stateVersion = "22.11"; + xdg.mime.defaultApplications = { + "text/html" = "firefox.desktop"; + "x-scheme-handler/http" = "firefox.desktop"; + "x-scheme-handler/https" = "firefox.desktop"; + }; + # This is apparently used by Electron? Maybe not anymore. + environment.sessionVariables.DEFAULT_BROWSER = lib.getExe pkgs.firefox; + + environment.enableDebugInfo = true; + environment.systemPackages = with pkgs; [ + vim + wget + curl + # for firefox-nightly + # inputs.firefox.packages.${pkgs.system}.firefox-nightly-bin + firefox + git + perf + fish + unzip + (steam.override { + extraPkgs = pkgs: [ mesa-demos ]; # i have no idea what this is doing lol + }).run + # Wine for 32 and 64 bit applications + wineWow64Packages.stable + lutris + virt-manager + podman + fastfetch + podman-compose + man-pages + man-pages-posix + bpftrace + file + comma + alacritty + fuzzel + xwayland-satellite + mpv + wl-mirror + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + programs.steam = { + enable = true; + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + extest.enable = true; # for potentially working controllers + }; + + programs.fish = { + enable = true; + }; + + programs.java.enable = true; + + programs.nix-ld = { + # i love programs that work + enable = true; + }; + + virtualisation = { + libvirtd = { + enable = true; + qemu = { + # enable TPM emulation + swtpm.enable = true; + }; + }; + podman = { + enable = true; + defaultNetwork.settings.dns_enabled = true; + }; + docker.enable = true; + virtualbox.host = { + enable = false; # failed to build? + }; + }; + + hardware.enableAllFirmware = true; + + # Open ports in the firewall. + networking.firewall = { + enable = true; + }; + + system.nixos.distroName = "🏳️‍⚧️"; } diff --git a/nixos/hardware-configuration.nix b/nixos/desktop-hardware-configuration.nix similarity index 68% rename from nixos/hardware-configuration.nix rename to nixos/desktop-hardware-configuration.nix index e91fffe..f7db76c 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/desktop-hardware-configuration.nix @@ -1,11 +1,12 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { imports = - [ (modulesPath + "/installer/scan/not-detected.nix") + [ + (modulesPath + "/installer/scan/not-detected.nix") ]; boot.initrd.availableKernelModules = [ "nvme" "ahci" "xhci_pci" "usbhid" "usb_storage" "sd_mod" ]; @@ -14,18 +15,31 @@ boot.extraModulePackages = [ ]; fileSystems."/" = - { device = "/dev/disk/by-uuid/32d0dca2-de5c-4512-8be3-ab7a75ac4a20"; + { + device = "/dev/disk/by-uuid/32d0dca2-de5c-4512-8be3-ab7a75ac4a20"; + fsType = "ext4"; + }; + + fileSystems."/mnt/1" = + { + device = "/dev/disk/by-uuid/8ceed88b-8e66-403e-a0f3-16907c228c6b"; + fsType = "ext4"; + }; + + fileSystems."/mnt/2" = + { + device = "/dev/disk/by-uuid/070623af-08eb-4496-b16b-018063336b0a"; fsType = "ext4"; }; fileSystems."/boot/efi" = - { device = "/dev/disk/by-uuid/2027-FC69"; + { + device = "/dev/disk/by-uuid/2027-FC69"; fsType = "vfat"; }; swapDevices = - [ { device = "/dev/disk/by-uuid/7052ef54-be53-48bf-8b3e-9d24d5f34d5f"; } - ]; + [{ device = "/dev/disk/by-uuid/7052ef54-be53-48bf-8b3e-9d24d5f34d5f"; }]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/nixos/desktop.nix b/nixos/desktop.nix new file mode 100644 index 0000000..bf8c841 --- /dev/null +++ b/nixos/desktop.nix @@ -0,0 +1,110 @@ +{ pkgs, config, ... }: { + imports = [ + ./desktop-hardware-configuration.nix + ./paperless.nix + ./configuration.nix + ]; + + networking = { + hostName = "nixos"; + extraHosts = + '' + 192.168.122.44 illumos-vm + ''; + }; + + # Windows sets the hardware clock in local time by default. + time.hardwareClockInLocalTime = true; + + boot.loader.grub = { + enable = true; + device = "nodev"; + efiSupport = true; + useOSProber = true; + minegrub-theme = { + enable = true; + }; + }; + + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + + boot.supportedFilesystems = [ "ntfs" ]; + + fileSystems."/mnt/nas" = { + device = "192.168.178.47:/volume1/homes"; + fsType = "nfs"; + }; + + services.xserver = { + # ndivia drivers + # long story short night light mode is currently broken with nvidia drivers. LMAO + # - https://forums.developer.nvidia.com/t/screen-freezes-at-random-intervals-with-rtx-4060-max-q-mobile-multiple-driver-versions-tested/295811/6?u=mirao + videoDrivers = [ "nvidia" ]; + }; + + hardware.nvidia = { + # https://github.com/NixOS/nixpkgs/issues/299944#issuecomment-2027246826 + modesetting.enable = true; + open = true; + }; + + programs.coolercontrol.enable = true; + + services.tailscale = { + enable = true; + useRoutingFeatures = "both"; + }; + + services.openssh = { + enable = true; + hostKeys = [ + { + path = "/etc/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + } + { + # P256 + path = "/etc/ssh/ssh_host_ecdsa_key"; + type = "ecdsa"; + } + { + bits = 4096; + path = "/etc/ssh/ssh_host_rsa_key"; + type = "rsa"; + } + ]; + settings.PermitRootLogin = "no"; + settings.PasswordAuthentication = false; + }; + + environment.systemPackages = with pkgs; [ + tailscale + os-prober + usbutils # steam client logs complain about lsusb + kdiskmark + ]; + + networking.firewall = { + trustedInterfaces = [ "tailscale0" ]; + allowedUDPPorts = [ config.services.tailscale.port ]; + allowedTCPPorts = [ /*SSH*/ 22 ]; + + # https://github.com/tailscale/tailscale/issues/4432#issuecomment-1112819111 + checkReversePath = "loose"; + }; + + # TODO: ENABLE NVIDIA DRIVERS WHEN THEY STOP BEING READY + #hardware.nvidia-container-toolkit.enable = true; + + networking.interfaces.enp39s0.wakeOnLan.enable = true; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = "22.11"; +} diff --git a/nixos/laptop-hardware-configuration.nix b/nixos/laptop-hardware-configuration.nix new file mode 100644 index 0000000..1e5aca7 --- /dev/null +++ b/nixos/laptop-hardware-configuration.nix @@ -0,0 +1,40 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/646dc4c1-53aa-4fce-9328-f7c42a5b5ea8"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-c16da30d-5953-4ce9-995a-f4acd77dcaf7".device = "/dev/disk/by-uuid/c16da30d-5953-4ce9-995a-f4acd77dcaf7"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/E494-B917"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/laptop.nix b/nixos/laptop.nix new file mode 100644 index 0000000..39681b6 --- /dev/null +++ b/nixos/laptop.nix @@ -0,0 +1,15 @@ +{ ... }: { + imports = [ + ./laptop-hardware-configuration.nix + ./configuration.nix + ]; + + networking = { + hostName = "scrap"; + }; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + system.stateVersion = "25.11"; +} diff --git a/nixos/paperless.nix b/nixos/paperless.nix new file mode 100644 index 0000000..cdcee4e --- /dev/null +++ b/nixos/paperless.nix @@ -0,0 +1,46 @@ +{ lib, pkgs, ... }: +let localDir = "/home/nora/.local/share/paperless-ngx"; nasDir = "/mnt/nas/HEY/_Nora/paperless"; in { + services.paperless = { + enable = true; + dataDir = "${localDir}/data"; + mediaDir = "${localDir}/media"; + consumptionDir = "${nasDir}/consume"; + address = "0.0.0.0"; + port = 8010; + user = "nora"; + environmentFile = "${localDir}/secrets-environment"; + settings = { + PAPERLESS_TIME_ZONE = "Europe/Zurich"; + PAPERLESS_ADMIN_USER = "nora"; + PAPERLESS_OCR_LANGUAGE = "deu+eng"; + }; + exporter = { + enable = true; + directory = "${nasDir}/export"; + }; + }; + + + systemd.services.paperless-ngx-backup = { + description = "paperless-ngx data backup to NAS"; + serviceConfig = { + Type = "oneshot"; + User = "nora"; + ExecStart = '' + ${lib.getExe pkgs.rsync} -a -v --delete --exclude=redis ${localDir}/ ${nasDir}/backup + ''; + }; + }; + systemd.timers.paperless-ngx-backup = { + description = "paperless-ngx data backup to NAS"; + wantedBy = [ "timers.target" ]; + after = [ "mnt-nas.mount" ]; + timerConfig = { + Unit = "paperless-ngx-backup.service"; + OnCalendar = "daily UTC"; + RandomizedDelaySec = 1800; + FixedRandomDelay = true; + Persistent = true; # ensure it still runs if the computer was down at the timer of trigger + }; + }; +} diff --git a/shells/c-env.nix b/shells/c-env.nix new file mode 100644 index 0000000..bde315a --- /dev/null +++ b/shells/c-env.nix @@ -0,0 +1,11 @@ +{ pkgs }: pkgs.mkShell { + buildInputs = with pkgs; [ openssl zlib libpq sqlite ]; + nativeBuildInputs = with pkgs; [ + pkg-config + cmake + ninja + llvmPackages_21.clang + llvmPackages_21.lld + llvmPackages_21.bintools-unwrapped + ]; +}