From 0f33c80edda96e28714a215e323448dba68e9e3a Mon Sep 17 00:00:00 2001 From: Lukas Wurzinger Date: Sun, 1 Dec 2024 05:03:34 +0100 Subject: [PATCH] whatever --- classes/desktop/devenv.nix | 3 +++ classes/desktop/fonts.nix | 2 +- classes/desktop/gamemode.nix | 7 +++++- classes/desktop/gnome.nix | 9 ++++++++ classes/desktop/hardware.nix | 3 ++- classes/desktop/helix.nix | 17 ++++++++++++++ classes/desktop/neovide.nix | 5 ---- classes/desktop/networking.nix | 7 +++++- classes/desktop/pipewire.nix | 1 - classes/desktop/plasma.nix | 25 -------------------- classes/desktop/printing.nix | 25 +++++++++++++------- common/users.nix | 1 + disk.sh | 42 ++++++++++++++++++++++++++++++++-- flake.lock | 37 +++++++++++++++++++++++++++++- flake.nix | 1 + 15 files changed, 139 insertions(+), 46 deletions(-) create mode 100644 classes/desktop/devenv.nix create mode 100644 classes/desktop/gnome.nix create mode 100644 classes/desktop/helix.nix delete mode 100644 classes/desktop/neovide.nix delete mode 100644 classes/desktop/plasma.nix diff --git a/classes/desktop/devenv.nix b/classes/desktop/devenv.nix new file mode 100644 index 0000000..32fb44b --- /dev/null +++ b/classes/desktop/devenv.nix @@ -0,0 +1,3 @@ +{pkgs, ...}: { + environment.systemPackages = [pkgs.devenv]; +} diff --git a/classes/desktop/fonts.nix b/classes/desktop/fonts.nix index 48e47b6..bf59051 100644 --- a/classes/desktop/fonts.nix +++ b/classes/desktop/fonts.nix @@ -8,7 +8,7 @@ pkgs.noto-fonts-cjk-serif pkgs.noto-fonts-monochrome-emoji pkgs.noto-fonts-color-emoji - (pkgs.nerdfonts.override {fonts = ["FiraCode"];}) + pkgs.nerd-fonts.fira-code ]; fontconfig = { diff --git a/classes/desktop/gamemode.nix b/classes/desktop/gamemode.nix index 36e3c0d..7e15ae5 100644 --- a/classes/desktop/gamemode.nix +++ b/classes/desktop/gamemode.nix @@ -1,8 +1,11 @@ { + config, lib, pkgs, ... -}: { +}: let + inherit (config.users) mainUser; +in { programs.gamemode = { enable = true; settings = { @@ -15,4 +18,6 @@ }; }; }; + + users.users.${mainUser}.extraGroups = ["gamemode"]; } diff --git a/classes/desktop/gnome.nix b/classes/desktop/gnome.nix new file mode 100644 index 0000000..382aa9b --- /dev/null +++ b/classes/desktop/gnome.nix @@ -0,0 +1,9 @@ +{ + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; + + xdg.portal.xdgOpenUsePortal = true; +} diff --git a/classes/desktop/hardware.nix b/classes/desktop/hardware.nix index 476bbf1..7a541de 100644 --- a/classes/desktop/hardware.nix +++ b/classes/desktop/hardware.nix @@ -3,7 +3,8 @@ bluetooth.enable = true; xone.enable = true; xpadneo.enable = true; - opentabletdriver.enable = true; + # TODO + # opentabletdriver.enable = true; graphics = { enable = true; enable32Bit = true; diff --git a/classes/desktop/helix.nix b/classes/desktop/helix.nix new file mode 100644 index 0000000..4582e43 --- /dev/null +++ b/classes/desktop/helix.nix @@ -0,0 +1,17 @@ +{ + inputs, + lib, + pkgs, + ... +}: let + package = inputs.hxwrap.packages.${pkgs.system}.default; +in { + environment.systemPackages = [package]; + + environment.variables = let + exe = builtins.baseNameOf (lib.getExe package); + in { + EDITOR = exe; + VISUAL = exe; + }; +} diff --git a/classes/desktop/neovide.nix b/classes/desktop/neovide.nix deleted file mode 100644 index 6821dbf..0000000 --- a/classes/desktop/neovide.nix +++ /dev/null @@ -1,5 +0,0 @@ -{pkgs, ...}: let - package = pkgs.neovide; -in { - environment.systemPackages = [package]; -} diff --git a/classes/desktop/networking.nix b/classes/desktop/networking.nix index 1844edb..b5f5f01 100644 --- a/classes/desktop/networking.nix +++ b/classes/desktop/networking.nix @@ -1,6 +1,9 @@ -{ +{config, ...}: let + inherit (config.users) mainUser; +in { services.resolved.enable = true; + # TODO networking = { networkmanager = { enable = true; @@ -34,4 +37,6 @@ ]; }; }; + + users.users.${mainUser}.extraGroups = ["networkmanager"]; } diff --git a/classes/desktop/pipewire.nix b/classes/desktop/pipewire.nix index f22fcef..157b2af 100644 --- a/classes/desktop/pipewire.nix +++ b/classes/desktop/pipewire.nix @@ -1,5 +1,4 @@ { - hardware.pulseaudio.enable = false; security.rtkit.enable = true; services.pipewire = { diff --git a/classes/desktop/plasma.nix b/classes/desktop/plasma.nix deleted file mode 100644 index 41f2ecf..0000000 --- a/classes/desktop/plasma.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - lib, - pkgs, - ... -}: { - services = { - desktopManager.plasma6.enable = true; - displayManager.sddm = { - enable = true; - wayland.enable = true; - }; - }; - - environment.systemPackages = with pkgs.kdePackages; [sddm-kcm discover kate]; - - programs = { - kdeconnect.enable = true; - partition-manager.enable = true; - }; - - xdg.portal = { - xdgOpenUsePortal = true; - extraPortals = [pkgs.xdg-desktop-portal-gtk]; - }; -} diff --git a/classes/desktop/printing.nix b/classes/desktop/printing.nix index a7b3b55..eb7d94f 100644 --- a/classes/desktop/printing.nix +++ b/classes/desktop/printing.nix @@ -1,10 +1,19 @@ -{ - services = { - printing = { - enable = true; - webInterface = true; - cups-pdf.enable = true; - }; - system-config-printer.enable = true; +{pkgs, ...}: { + services.printing = { + enable = true; + webInterface = true; + cups-pdf.enable = true; + drivers = [ + pkgs.gutenprint + pkgs.gutenprintBin + pkgs.hplip + pkgs.hplipWithPlugin + pkgs.postscript-lexmark + pkgs.samsung-unified-linux-driver + pkgs.splix + pkgs.brlaser + pkgs.brgenml1lpr + pkgs.cnijfilter2 + ]; }; } diff --git a/common/users.nix b/common/users.nix index f62fbf8..a550e86 100644 --- a/common/users.nix +++ b/common/users.nix @@ -16,6 +16,7 @@ in { openssh.authorizedKeys.keys = builtins.attrValues (import ../pubkeys.nix).hosts; }; ${mainUser} = { + description = "Lukas Wurzinger"; uid = 1000; isNormalUser = true; hashedPasswordFile = config.age.secrets."user-${mainUser}".path; diff --git a/disk.sh b/disk.sh index cd750e0..d4be5c4 100644 --- a/disk.sh +++ b/disk.sh @@ -2,19 +2,25 @@ set -o errexit set -o nounset set -o pipefail -opts=$(getopt --options r:m:b:l:c: --longoptions=root:,boot-label:,main-label: --name "$0" -- "$@") +opts=$(getopt --options r:m:b:l:c: --longoptions=root:,mapping:,boot-label:,main-label:,cryptmain-label: --name "$0" -- "$@") eval set -- "$opts" root=/mnt +mapping=main bootlbl=BOOT mainlbl=main +cryptmainlbl=cryptmain while true; do case "$1" in -r | --root) root=$2 shift 2 ;; + -m | --mapping) + mapping=$2 + shift 2 + ;; -b | --boot-label) bootlbl=${2^^} shift 2 @@ -23,6 +29,10 @@ while true; do mainlbl=$2 shift 2 ;; + -c | --cryptmain-label) + cryptmainlbl=$2 + shift 2 + ;; --) shift break @@ -49,10 +59,38 @@ while IFS= read -r k; do done < <(jq '.partitiontable.partitions | keys[]' <<<"$json") bootfs="${parts[0]}" -mainfs="${parts[1]}" +mainblkdev="${parts[1]}" mkfs.vfat -F 32 -n "$bootlbl" -- "$bootfs" >/dev/null +while true; do + read -r -p 'Do you want your main partition to be encrypted [y/N]? ' luks + case "$luks" in + [Yy]*) + while true; do + read -r -s -p 'Enter password: ' password + printf '\n' + read -r -s -p 'Re-enter password: ' repassword + printf '\n' + if [[ "$password" == "$repassword" ]]; then + break + fi + done + + cryptsetup luksFormat --batch-mode --label "$cryptmainlbl" "$mainblkdev" <<<"$password" + cryptsetup open "$mainblkdev" "$mapping" <<<"$password" + + mainfs=/dev/mapper/$mapping + break + ;; + '' | [Nn]*) + mainfs=$mainblkdev + break + ;; + *) printf 'Please answer with yes or no\n' 1>&2 ;; + esac +done + mkfs.ext4 -q -F -L "$mainlbl" -- "$mainfs" mkdir --parents -- "$root" mount --options noatime -- "$mainfs" "$root" diff --git a/flake.lock b/flake.lock index 864cdc1..7b88d23 100644 --- a/flake.lock +++ b/flake.lock @@ -97,6 +97,24 @@ "type": "github" } }, + "hxwrap": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1730417950, + "narHash": "sha256-2Lh+av929qXmYRIZ5FONrWCUWrvDFLVID2deEZCn4ek=", + "owner": "lukaswrz", + "repo": "hxwrap", + "rev": "13f97ac98899eaa33481aa912b42cf7350d16211", + "type": "github" + }, + "original": { + "owner": "lukaswrz", + "repo": "hxwrap", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1703013332, @@ -126,6 +144,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1730200266, + "narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1732837521, "narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=", @@ -146,7 +180,8 @@ "agenix": "agenix", "flake-parts": "flake-parts", "hardware": "hardware", - "nixpkgs": "nixpkgs_2" + "hxwrap": "hxwrap", + "nixpkgs": "nixpkgs_3" } }, "systems": { diff --git a/flake.nix b/flake.nix index 169f317..6fb3fcb 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,7 @@ flake-parts.url = "github:hercules-ci/flake-parts"; hardware.url = "github:NixOS/nixos-hardware"; agenix.url = "github:ryantm/agenix"; + hxwrap.url = "github:lukaswrz/hxwrap"; }; outputs = {