diff --git a/.githooks/pre-commit b/.githooks/pre-commit index dc54442..b8babfa 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -11,6 +11,6 @@ for i in $STAGED; do done deadnix -qe $STAGED -alejandra -q $STAGED +nixfmt -q $STAGED git add $STAGED diff --git a/flake.lock b/flake.lock index 03179cd..8d0e04a 100644 --- a/flake.lock +++ b/flake.lock @@ -59,11 +59,11 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", "type": "github" }, "original": { @@ -88,6 +88,37 @@ "type": "github" } }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "lowdown-src": { "flake": false, "locked": { @@ -139,24 +170,50 @@ "inputs": { "flake-compat": "flake-compat", "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs", + "nixpkgs": [ + "unstable" + ], "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1694007573, - "narHash": "sha256-DThtWWrG8JHzG6oS/JA/0mOVRj7IxHNdVnXk291wJRs=", + "lastModified": 1694067117, + "narHash": "sha256-fstL4alQM8QpsunEtaErpURwQ0yoTh19YdjobsN2ids=", "owner": "NixOS", "repo": "nix", - "rev": "3a62651bd663a849a568bf69017d0f3b1addd564", + "rev": "2da46530d0bb4faf8ca0605f8fdffca7bd5baa73", "type": "github" }, "original": { "owner": "NixOS", - "ref": "3a62651bd663a849a568bf69017d0f3b1addd564", + "ref": "2.17-maintenance", "repo": "nix", "type": "github" } }, + "nixfmt": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils", + "nixpkgs": [ + "unstable" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1689712241, + "narHash": "sha256-SJlTDNBYBJVl8HrHPT8kWKqVxa7MNSosLI07svHG1A8=", + "owner": "piegamesde", + "repo": "nixfmt", + "rev": "a93dcf7e9e19b4308d6cdb50da829839bf88817a", + "type": "github" + }, + "original": { + "owner": "piegamesde", + "ref": "rfc101-style", + "repo": "nixfmt", + "type": "github" + } + }, "nixlib": { "locked": { "lastModified": 1693701915, @@ -193,22 +250,6 @@ "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1670461440, - "narHash": "sha256-jy1LB8HOMKGJEGXgzFRLDU1CBGL0/LlkolgnqIsF0D8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "04a75b2eecc0acf6239acf9dd04485ff8d14f425", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.11-small", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs-regression": { "locked": { "lastModified": 1643052045, @@ -226,6 +267,22 @@ } }, "nixpkgs-stable": { + "locked": { + "lastModified": 1672580127, + "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0874168639713f547c05947c76124f78441ea46c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { "locked": { "lastModified": 1694908564, "narHash": "sha256-ducA98AuWWJu5oUElIzN24Q22WlO8bOfixGzBgzYdVc=", @@ -243,7 +300,7 @@ }, "nvim-flake": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "neovim-src": "neovim-src", "nixpkgs": [ "unstable" @@ -269,6 +326,7 @@ "fetch-rs": "fetch-rs", "master": "master", "nix": "nix", + "nixfmt": "nixfmt", "nixos-generators": "nixos-generators", "nvim-flake": "nvim-flake", "sops-nix": "sops-nix", @@ -283,7 +341,7 @@ "nixpkgs": [ "unstable" ], - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { "lastModified": 1695284550, @@ -301,7 +359,7 @@ }, "spicetify-nix": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "nixpkgs": [ "unstable" ] diff --git a/flake.nix b/flake.nix index 3baf92d..bffe60a 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,10 @@ unstable.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; stable.url = "github:NixOS/nixpkgs?ref=nixos-23.05"; - nix.url = "github:NixOS/nix?ref=3a62651bd663a849a568bf69017d0f3b1addd564"; + nix = { + url = "github:NixOS/nix?ref=2.17-maintenance"; + inputs.nixpkgs.follows = "unstable"; + }; nixos-generators = { url = "github:nix-community/nixos-generators"; @@ -19,6 +22,10 @@ url = "github:nix-community/disko"; inputs.nixpkgs.follows = "unstable"; }; + nixfmt = { + url = "github:piegamesde/nixfmt?ref=rfc101-style"; + inputs.nixpkgs.follows = "unstable"; + }; spicetify-nix = { url = "github:Gerg-L/spicetify-nix"; inputs.nixpkgs.follows = "unstable"; @@ -69,7 +76,23 @@ "game-laptop" "moms-laptop" ]; - formatter.${system} = pkgs.alejandra; + formatter.${system} = pkgs.writeShellApplication { + name = "lint"; + runtimeInputs = [ + (pkgs.nixfmt.overrideAttrs { + version = "0.6.0-${inputs.nixfmt.shortRev}"; + + src = inputs.nixfmt; + }) + pkgs.deadnix + pkgs.statix + pkgs.fd + ]; + text = '' + fd '.*\.nix' . -x statix fix -- {} \; + fd '.*\.nix' . -X deadnix -e -- {} \; -X nixfmt {} \; + ''; + }; devShells.${system}.default = pkgs.mkShell { packages = [ diff --git a/hosts/gerg-desktop/disko.nix b/hosts/gerg-desktop/disko.nix index ff323ec..33d4307 100644 --- a/hosts/gerg-desktop/disko.nix +++ b/hosts/gerg-desktop/disko.nix @@ -1,139 +1,97 @@ -{disko, ...}: _: { +{disko, ...}: {lib, ...}: { imports = [disko.nixosModules.disko]; - disko.devices = { - disk = { - "0E" = let - baseDevice = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E"; - in { - type = "disk"; - device = baseDevice; - content = { - type = "gpt"; - partitions = { - BOOT = { - device = "${baseDevice}-part1"; - type = "EF00"; - start = "0"; - end = "4G"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/efi0E"; - }; - }; - swap = { - device = "${baseDevice}-part2"; - start = "5G"; - end = "21G"; - content = { - type = "swap"; - randomEncryption = true; - }; - }; - zfsroot = { - device = "${baseDevice}-part3"; - start = "21G"; - end = "100%"; - content = { - type = "zfs"; - pool = "rpool"; - }; - }; + + disko.devices.disk = lib.genAttrs ["0E" "22"] (name: let + fullName = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N${name}"; + in { + type = "disk"; + device = fullName; + content = { + type = "gpt"; + partitions = { + BOOT = { + device = "${fullName}-part1"; + type = "EF00"; + start = "0"; + end = "4G"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/efi${name}"; }; }; - }; - "22" = let - baseDevice = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22"; - in { - type = "disk"; - device = baseDevice; - content = { - type = "gpt"; - partitions = { - BOOT = { - device = "${baseDevice}-part1"; - type = "EF00"; - start = "0"; - end = "4G"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/efi22"; - }; - }; - swap = { - device = "${baseDevice}-part2"; - start = "5G"; - end = "21G"; - content = { - type = "swap"; - randomEncryption = true; - }; - }; - zfsroot = { - device = "${baseDevice}-part3"; - start = "21G"; - end = "100%"; - content = { - type = "zfs"; - pool = "rpool"; - }; - }; + swap = { + device = "${fullName}-part2"; + start = "5G"; + end = "21G"; + content = { + type = "swap"; + randomEncryption = true; + }; + }; + zfsroot = { + device = "${fullName}-part3"; + start = "21G"; + end = "100%"; + content = { + type = "zfs"; + pool = "rpool"; }; }; }; }; - zpool = { - rpool = { - type = "zpool"; - mode = "mirror"; - rootFsOptions = { - acltype = "posixacl"; - compression = "zstd"; - dnodesize = "auto"; - normalization = "formD"; - relatime = "on"; - xattr = "sa"; - encryption = "on"; - keyformat = "passphrase"; - keylocation = "prompt"; - }; - options = { - ashift = "12"; - autotrim = "on"; - }; + }); - datasets = { - "root" = { - type = "zfs_fs"; - options.mountpoint = "legacy"; - mountpoint = "/"; - postCreateHook = "zfs snapshot rpool/root@empty"; - }; - "nix" = { - type = "zfs_fs"; - options.mountpoint = "legacy"; - mountpoint = "/nix"; - postCreateHook = "zfs snapshot rpool/nix@empty"; - }; - "var" = { - type = "zfs_fs"; - options.mountpoint = "legacy"; - mountpoint = "/var"; - postCreateHook = "zfs snapshot rpool/var@empty"; - }; - "persist" = { - type = "zfs_fs"; - options.mountpoint = "legacy"; - mountpoint = "/persist"; - postCreateHook = "zfs snapshot rpool/persist@empty"; - }; - "home" = { - type = "zfs_fs"; - options.mountpoint = "legacy"; - mountpoint = "/home"; - postCreateHook = "zfs snapshot rpool/home@empty"; - }; + disko.devices.zpool = { + rpool = { + type = "zpool"; + mode = "mirror"; + rootFsOptions = { + acltype = "posixacl"; + compression = "zstd"; + dnodesize = "auto"; + normalization = "formD"; + relatime = "on"; + xattr = "sa"; + encryption = "on"; + keyformat = "passphrase"; + keylocation = "prompt"; + }; + options = { + ashift = "12"; + autotrim = "on"; + }; + + datasets = { + "root" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/"; + postCreateHook = "zfs snapshot rpool/root@empty"; + }; + "nix" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/nix"; + postCreateHook = "zfs snapshot rpool/nix@empty"; + }; + "var" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/var"; + postCreateHook = "zfs snapshot rpool/var@empty"; + }; + "persist" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/persist"; + postCreateHook = "zfs snapshot rpool/persist@empty"; + }; + "home" = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/home"; + postCreateHook = "zfs snapshot rpool/home@empty"; }; }; }; diff --git a/hosts/gerg-desktop/main.nix b/hosts/gerg-desktop/main.nix index 2560c72..65db071 100644 --- a/hosts/gerg-desktop/main.nix +++ b/hosts/gerg-desktop/main.nix @@ -1,4 +1,4 @@ -{nvim-flake, ...}: { +{nvim-flake, nixfmt, ...}: { pkgs, config, ... @@ -43,32 +43,56 @@ nix.settings.system-features = ["kvm" "big-parallel" "nixos-test" "benchmark"]; environment = { - systemPackages = builtins.attrValues { - inherit - (pkgs) - bitwarden #store stuff - qbittorrent #steal stuff - pavucontrol #gui volume control - pcmanfm #file manager - librewolf #best browser - vlc #play stuff - ripgrep - xautoclick - prismlauncher - deadnix - statix - alejandra - nix-index - element-desktop - webcord - ; - inherit (nvim-flake.packages.${pkgs.system}) neovim; - lint = pkgs.writeShellScriptBin "lint" '' - deadnix -e "''${1:-.}" - statix fix -- "''${1:-.}" - alejandra "''${1:-.}" - ''; - }; + systemPackages = let + fmt = pkgs.nixfmt.overrideAttrs { + version = "0.6.0-${nixfmt.shortRev}"; + + src = nixfmt; + }; + in + builtins.attrValues { + inherit + (pkgs) + bitwarden # store stuff + qbittorrent # steal stuff + pavucontrol # gui volume control + pcmanfm # file manager + librewolf # best browser + vlc # play stuff + ripgrep + fd + jq + xautoclick + prismlauncher + deadnix + statix + nix-index + element-desktop + webcord + ; + inherit (nvim-flake.packages.${pkgs.system}) neovim; + inherit fmt; + lint = pkgs.writeShellApplication { + name = "lint"; + runtimeInputs = [ + fmt + pkgs.deadnix + pkgs.statix + pkgs.fd + ]; + + text = '' + if [ -z "''${1:-""}" ]; then + fd '.*\.nix' . -x statix fix -- {} \; + fd '.*\.nix' . -X deadnix -e -- {} \; -X nixfmt {} \; + else + statix fix -- "$1" + deadnix -e "$1" + nixfmt "$1" + fi + ''; + }; + }; etc = { "jdks/17".source = "${pkgs.openjdk17}/bin"; "jdks/8".source = "${pkgs.openjdk8}/bin"; diff --git a/hosts/gerg-desktop/services/minecraft.nix b/hosts/gerg-desktop/services/minecraft.nix index 75ce43c..aae653f 100644 --- a/hosts/gerg-desktop/services/minecraft.nix +++ b/hosts/gerg-desktop/services/minecraft.nix @@ -7,7 +7,6 @@ config = lib.mkIf false { networking.firewall.allowedTCPPorts = [25565]; - system.stateVersion = "unstable"; users.users.minecraft = { description = "Minecraft server service user"; home = "/persist/minecraft"; @@ -64,7 +63,7 @@ serviceConfig = { Restart = "always"; User = "minecraft"; - WorkingDirectory = "/minecraft"; + WorkingDirectory = "/persist/minecraft"; StandardInput = "socket"; StandardOutput = "journal"; diff --git a/hosts/gerg-desktop/services/nextcloud.nix b/hosts/gerg-desktop/services/nextcloud.nix index b082ec2..15d7a77 100644 --- a/hosts/gerg-desktop/services/nextcloud.nix +++ b/hosts/gerg-desktop/services/nextcloud.nix @@ -16,6 +16,7 @@ _: { enableBrokenCiphersForSSE = false; database.createLocally = true; config = { + overwriteProtocol = "https"; dbtype = "pgsql"; adminpassFile = config.sops.secrets.nextcloud.path; adminuser = "admin-root"; diff --git a/hosts/gerg-desktop/spicetify.nix b/hosts/gerg-desktop/spicetify.nix index 4f6dc5c..8ea648e 100644 --- a/hosts/gerg-desktop/spicetify.nix +++ b/hosts/gerg-desktop/spicetify.nix @@ -1,16 +1,18 @@ {spicetify-nix, ...}: {pkgs, ...}: let spicePkgs = spicetify-nix.legacyPackages.${pkgs.system}; - ex = spicePkgs.extensions; in { imports = [spicetify-nix.nixosModules.default]; local.allowedUnfree = ["spotify"]; programs.spicetify = { enable = true; - enabledExtensions = [ - ex.adblock - ex.hidePodcasts - ex.shuffle - ]; + enabledExtensions = builtins.attrValues { + inherit + (spicePkgs.extensions) + adblock + hidePodcasts + shuffle + ; + }; theme = spicePkgs.themes.Comfy; colorScheme = "custom"; customColorScheme = { diff --git a/hosts/gerg-desktop/vfio.nix b/hosts/gerg-desktop/vfio.nix index 3880333..a9666ac 100644 --- a/hosts/gerg-desktop/vfio.nix +++ b/hosts/gerg-desktop/vfio.nix @@ -37,6 +37,16 @@ let echo >> $out ''; ###END OF TAKEN PART + + cfg_monitors = pkgs.writeShellApplication { + name = "cfg_monitors"; + runtimeInputs = [pkgs.xorg.xrandr pkgs.xorg.xset pkgs.gawk pkgs.gnugrep]; + text = '' + xrandr --output DP-0 --auto --mode 3440x1440 --rate 120 --primary --pos 0x0 + xrandr --output "$(xrandr | grep -e 'HDMI.* connected.*'| awk '{ print$1 }')" --auto --mode 1920x1080 --rate 144 --set TearFree on --pos 3440x360 + xset -dpms + ''; + }; in { environment.etc = { "Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" {} ( @@ -103,6 +113,7 @@ in { systemPackages = [ pkgs.virt-manager pkgs.dmidecode + cfg_monitors ]; shellAliases = { vm-start = "virsh start Windows"; @@ -110,53 +121,58 @@ in { }; }; + programs.dconf.enable = true; + users.users.gerg.extraGroups = ["kvm" "libvirtd"]; services.xserver.displayManager.xserverArgs = lib.mkAfter ["-config /etc/Xorg/active.conf"]; services.xserver.displayManager.sessionCommands = lib.mkBefore '' if ! [ -e "/etc/Xorg/ONE_MONITOR" ] ; then - xrandr --output DP-0 --auto --mode 3440x1440 --rate 120 --primary --pos 0x0 - xrandr --output "$(xrandr | grep -e 'HDMI.* connected.*'| awk '{ print$1 }')" --auto --mode 1920x1080 --rate 144 --set TearFree on --pos 3440x360 - xset -dpms + ${lib.getExe cfg_monitors} fi + ''; systemd.tmpfiles.rules = let - qemuHook = pkgs.writeShellScript "qemu-hook" '' - GUEST_NAME="$1" - OPERATION="$2" - SUB_OPERATION="$3" + qemuHook = pkgs.writeShellApplication { + name = "qemu-hook"; - if [ "$GUEST_NAME" == "Windows" ]; then - if [ "$OPERATION" == "prepare" ]; then + runtimeInputs = [pkgs.libvirt pkgs.systemd pkgs.kmod]; + text = '' + GUEST_NAME="$1" + OPERATION="$2" + + if [ "$GUEST_NAME" == "Windows" ]; then + if [ "$OPERATION" == "prepare" ]; then + systemctl stop display-manager.service + modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset + virsh nodedev-detach pci_0000_01_00_0 + virsh nodedev-detach pci_0000_01_00_1 + systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31 + systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31 + systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31 + ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf + touch /etc/Xorg/ONE_MONITOR + systemctl start display-manager.service + fi + if [ "$OPERATION" == "release" ]; then systemctl stop display-manager.service - modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset - ${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_0 - ${pkgs.libvirt}/bin/virsh nodedev-detach pci_0000_01_00_1 - systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31 - systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31 - systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31 - ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf - touch /etc/Xorg/ONE_MONITOR + systemctl set-property --runtime -- user.slice AllowedCPUs=0-31 + systemctl set-property --runtime -- system.slice AllowedCPUs=0-31 + systemctl set-property --runtime -- init.scope AllowedCPUs=0-31 + virsh nodedev-reattach pci_0000_01_00_0 + virsh nodedev-reattach pci_0000_01_00_1 + modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset + ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf + rm /etc/Xorg/ONE_MONITOR systemctl start display-manager.service + fi fi - if [ "$OPERATION" == "release" ]; then - systemctl stop display-manager.service - systemctl set-property --runtime -- user.slice AllowedCPUs=0-31 - systemctl set-property --runtime -- system.slice AllowedCPUs=0-31 - systemctl set-property --runtime -- init.scope AllowedCPUs=0-31 - ${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_0 - ${pkgs.libvirt}/bin/virsh nodedev-reattach pci_0000_01_00_1 - modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset - ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf - rm /etc/Xorg/ONE_MONITOR - systemctl start display-manager.service - fi - fi - ''; + ''; + }; in [ "L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf" - "C /var/lib/libvirt/hooks/qemu - - - - ${qemuHook}" + "C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}" "C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}" ]; _file = ./vfio.nix; diff --git a/modules/DE/dwm.nix b/modules/DE/dwm.nix index 268c820..ee33b1c 100644 --- a/modules/DE/dwm.nix +++ b/modules/DE/dwm.nix @@ -23,7 +23,7 @@ defaultSession = "none+dwm"; }; windowManager.session = - lib.singleton + [ { name = "dwm"; start = '' @@ -43,7 +43,8 @@ dont_stop & waitPID=$! ''; - }; + } + ]; }; environment.systemPackages = builtins.attrValues { inherit diff --git a/modules/X11.nix b/modules/X11.nix index 66f4e04..c4ba7c6 100644 --- a/modules/X11.nix +++ b/modules/X11.nix @@ -61,9 +61,10 @@ in { pkgs.brightnessctl #brightness control for laptop pkgs.playerctl #music control pkgs.xclip - pkgs.coreutils ]; - services.xserver.displayManager.sessionCommands = "${pkgs.sxhkd}/bin/sxhkd -c ${configFile} &"; + services.xserver.displayManager.sessionCommands = '' + ${lib.getExe' pkgs.sxhkd "sxhkd"} -c ${configFile} & + ''; } ) ]; diff --git a/modules/boot.nix b/modules/boot.nix new file mode 100644 index 0000000..936950d --- /dev/null +++ b/modules/boot.nix @@ -0,0 +1,87 @@ +{self, ...}: { + lib, + pkgs, + config, + ... +}: { + options.local.bootConfig.disable = lib.mkEnableOption ""; + config = lib.mkIf (!config.local.bootConfig.disable) { + environment.etc = { + "issue" = { + text = "[?12l[?25h"; + mode = "0444"; + }; + }; + boot = { + blacklistedKernelModules = ["pcspkr"]; + kernelParams = lib.mkAfter [ + "acpi_call" + "pti=auto" + "randomize_kstack_offset=on" + "vsyscall=none" + "slab_nomerge" + "module.sig_enforce=1" + "lockdown=confidentiality" + "page_poison=1" + "page_alloc.shuffle=1" + "sysrq_always_enabled=0" + "idle=nomwait" + "rootflags=noatime" + "iommu=pt" + "usbcore.autosuspend=-1" + "noresume" + "acpi_backlight=native" + "logo.nologo" + "fbcon=nodefer" + "bgrt_disable" + "systemd.show_status=false" + "rd.udev.log_level=3" + "vt.global_cursor_default=0" + "quiet" + "splash" + ]; + consoleLogLevel = 3; + initrd = { + verbose = false; + + systemd.enable = true; + }; + plymouth = { + enable = lib.mkDefault true; + theme = "breeze"; + logo = "${self.packages.${pkgs.system}.images}/logo.png"; + }; + loader = { + grub = { + configurationLimit = 10; + extraConfig = '' + GRUB_TIMEOUT_STYLE=hidden + ''; + }; + systemd-boot = { + configurationLimit = 10; + enable = lib.mkDefault true; + consoleMode = "max"; + editor = false; + }; + efi.canTouchEfiVariables = lib.mkDefault true; + timeout = 0; + }; + }; + systemd.services.efibootmgr = { + reloadIfChanged = false; + restartIfChanged = false; + stopIfChanged = false; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + path = [pkgs.efibootmgr]; + wantedBy = ["default.target"]; + script = '' + efibootmgr -t 0 + ''; + }; + }; + _file = ./misc.nix; +} diff --git a/modules/boot/misc.nix b/modules/boot/misc.nix deleted file mode 100644 index 0bd2ff6..0000000 --- a/modules/boot/misc.nix +++ /dev/null @@ -1,88 +0,0 @@ -{self, ...}: { - lib, - pkgs, - config, - ... -}: { - options.local.bootConfig.disable = lib.mkEnableOption ""; - config = - lib.mkIf (!config.local.bootConfig.disable) - { - environment.etc = { - "issue" = { - text = "[?12l[?25h"; - mode = "0444"; - }; - }; - boot = { - blacklistedKernelModules = ["pcspkr"]; - kernelParams = [ - "acpi_call" - "pti=auto" - "randomize_kstack_offset=on" - "vsyscall=none" - "slab_nomerge" - "module.sig_enforce=1" - "lockdown=confidentiality" - "page_poison=1" - "page_alloc.shuffle=1" - "sysrq_always_enabled=0" - "idle=nomwait" - "rootflags=noatime" - "iommu=pt" - "usbcore.autosuspend=-1" - "noresume" - "acpi_backlight=native" - "logo.nologo" - "fbcon=nodefer" - "bgrt_disable" - "quiet" - "systemd.show_status=false" - "rd.udev.log_level=3" - "vt.global_cursor_default=0" - ]; - consoleLogLevel = 3; - initrd = { - verbose = false; - - systemd.enable = true; - }; - plymouth = { - enable = lib.mkDefault true; - theme = "breeze"; - logo = "${self.packages.${pkgs.system}.images}/logo.png"; - }; - loader = { - grub = { - configurationLimit = 10; - extraConfig = '' - GRUB_TIMEOUT_STYLE=hidden - ''; - }; - systemd-boot = { - configurationLimit = 10; - enable = lib.mkDefault true; - consoleMode = "max"; - editor = false; - }; - efi.canTouchEfiVariables = lib.mkDefault true; - timeout = 0; - }; - }; - systemd.services.efibootmgr = { - reloadIfChanged = false; - restartIfChanged = false; - stopIfChanged = false; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - path = [pkgs.efibootmgr]; - wantedBy = ["default.target"]; - script = '' - efibootmgr -t 0 - ''; - }; - }; - _file = ./misc.nix; -} diff --git a/modules/builders.nix b/modules/builders.nix index 5d08426..95d7afc 100644 --- a/modules/builders.nix +++ b/modules/builders.nix @@ -18,11 +18,9 @@ _: { max-jobs = 0; substituters = [ "ssh-ng://nix-ssh@gerg-desktop" - "https://cache.nixos.org/" ]; trusted-public-keys = [ "gerg-desktop:6p1+h6jQnb1MOt3ra3PlQpfgEEF4zRrQWiEuAqcjBj8=" - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; }; distributedBuilds = true; diff --git a/modules/keys.nix b/modules/keys.nix index 93a604c..4b2ce5f 100644 --- a/modules/keys.nix +++ b/modules/keys.nix @@ -1,19 +1,14 @@ _: {lib, ...}: { - options = { - local.keys = lib.mkOption { - default = {}; - }; - }; - config = { - local.keys = { - gerg_gerg-phone = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDU6BnoHIgMLgZVGuvi03J9l5Z1yP1P5Q8QPyjRHyi77"; - gerg_gerg-windows = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILpYY2uw0OH1Re+3BkYFlxn0O/D8ryqByJB/ljefooNc"; - root_moms-laptop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIq9YTf4jlVCKBKn44m4yJvj94C7pTOyaa4VjZFohNqD"; - root_game-laptop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUKHZasYQUAmRBiqtx1drDxfq18/N4rKydCtPHx461I"; - root_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIeHsGcmOdIMzV+SNe4WFcA3CPHCNb1aqxThkXtm7G/1"; - gerg-desktop_fingerprint = "BQxvBOWsTw1gdNDR0KzrSRmbVhDrJdG05vYXkVmw8yA"; - gerg_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJWbwkFJmRBgyWyWU+w3ksZ+KuFw9uXJN3PwqqE7Z/i8"; - }; + options.local.keys = lib.mkOption {}; + + config.local.keys = { + gerg_gerg-phone = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDU6BnoHIgMLgZVGuvi03J9l5Z1yP1P5Q8QPyjRHyi77"; + gerg_gerg-windows = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILpYY2uw0OH1Re+3BkYFlxn0O/D8ryqByJB/ljefooNc"; + root_moms-laptop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIq9YTf4jlVCKBKn44m4yJvj94C7pTOyaa4VjZFohNqD"; + root_game-laptop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUKHZasYQUAmRBiqtx1drDxfq18/N4rKydCtPHx461I"; + root_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIeHsGcmOdIMzV+SNe4WFcA3CPHCNb1aqxThkXtm7G/1"; + gerg-desktop_fingerprint = "BQxvBOWsTw1gdNDR0KzrSRmbVhDrJdG05vYXkVmw8yA"; + gerg_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJWbwkFJmRBgyWyWU+w3ksZ+KuFw9uXJN3PwqqE7Z/i8"; }; _file = ./keys.nix; } diff --git a/modules/misc.nix b/modules/misc.nix index 3fc9561..3811a4f 100644 --- a/modules/misc.nix +++ b/modules/misc.nix @@ -18,17 +18,17 @@ _: { allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.local.allowedUnfree; }; }; + programs.git.enable = true; + environment.defaultPackages = lib.mkForce (builtins.attrValues { inherit (pkgs) - alsa-utils #volume control bottom #view tasks efibootmgr #efi editor nix-output-monitor #nom nom nom nom; nix-tree #view packages pciutils #lspci - xclip #commandline clipboard access ; }); @@ -43,14 +43,17 @@ _: { KbdInteractiveAuthentication = false; }; }; + i18n.defaultLocale = "en_US.UTF-8"; #time settings + time.timeZone = "America/New_York"; - # For`info` command. + + # For `info` command. documentation.info.enable = false; # NixOS manual and such. documentation.nixos.enable = false; - + # Useless with flakes (without configuring) programs.command-not-found.enable = false; }; _file = ./misc.nix; diff --git a/modules/shell.nix b/modules/shell.nix index 0064d04..c51b7d2 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -1,4 +1,8 @@ -{fetch-rs, ...}: { +{ + fetch-rs, + self, + ... +}: { pkgs, config, lib, @@ -72,16 +76,9 @@ syntaxHighlighting.enable = true; histSize = 10000; histFile = "$HOME/.cache/zsh_history"; - interactiveShellInit = let - fzf-tab = pkgs.fetchFromGitHub { - owner = "Aloxaf"; - repo = "fzf-tab"; - rev = "c2b4aa5ad2532cca91f23908ac7f00efb7ff09c9"; - hash = "sha256-gvZp8P3quOtcy1Xtt1LAW1cfZ/zCtnAmnWqcwrKel6w="; - }; - in '' + interactiveShellInit = '' ### fzf-tab ### - source ${fzf-tab}/fzf-tab.plugin.zsh + source ${self.packages.${pkgs.system}.fzf-tab}/fzf-tab.plugin.zsh ### pager ### man () { PROGRAM="''${@[-1]}" diff --git a/modules/theming.nix b/modules/theming.nix index c971295..5cf45f5 100644 --- a/modules/theming.nix +++ b/modules/theming.nix @@ -55,7 +55,7 @@ in { platformTheme = "gtk2"; }; services.xserver.displayManager.sessionCommands = '' - xrdb -load /etc/xdg/Xresources + ${lib.getExe' pkgs.xorg.xrdb "xrdb"} -load /etc/xdg/Xresources ''; fonts = { packages = [pkgs.overpass]; diff --git a/packages/fzf-tab.nix b/packages/fzf-tab.nix new file mode 100644 index 0000000..b0c72dd --- /dev/null +++ b/packages/fzf-tab.nix @@ -0,0 +1,7 @@ +{fetchFromGitHub}: +fetchFromGitHub { + owner = "Aloxaf"; + repo = "fzf-tab"; + rev = "c2b4aa5ad2532cca91f23908ac7f00efb7ff09c9"; + hash = "sha256-gvZp8P3quOtcy1Xtt1LAW1cfZ/zCtnAmnWqcwrKel6w="; +} diff --git a/packages/papermc.nix b/packages/papermc.nix index c0c4ed6..d05cd0a 100644 --- a/packages/papermc.nix +++ b/packages/papermc.nix @@ -1,45 +1,40 @@ { lib, - stdenv, + runCommandNoCC, + makeBinaryWrapper, fetchurl, - bash, jre, -}: -stdenv.mkDerivation (finalAttrs: { +}: let pname = "papermc"; version = "1.20.1.83"; +in + runCommandNoCC "papermc" { + inherit pname version; - jar = let - mcVersion = lib.versions.pad 3 finalAttrs.version; - buildNum = builtins.elemAt (lib.versions.splitVersion finalAttrs.version) 3; - in - fetchurl { - url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/paper-${mcVersion}-${buildNum}.jar"; - sha256 = "sha256-HQpc3MOXa1wkXqgm9ciQj04FUIyuupnYiu+2RZ/sXE4="; + src = let + mcVersion = lib.versions.pad 3 version; + buildNum = builtins.elemAt (lib.versions.splitVersion version) 3; + in + fetchurl { + url = "https://papermc.io/api/v2/projects/paper/versions/${mcVersion}/builds/${buildNum}/downloads/paper-${mcVersion}-${buildNum}.jar"; + hash = "sha256-HQpc3MOXa1wkXqgm9ciQj04FUIyuupnYiu+2RZ/sXE4="; + }; + + nativeBuildInputs = [makeBinaryWrapper]; + + meta = { + description = "High-performance Minecraft Server"; + homepage = "https://papermc.io/"; + sourceProvenance = with lib.sourceTypes; [binaryBytecode]; + license = lib.licenses.gpl3Only; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [aaronjanse neonfuz]; + mainProgram = "minecraft-server"; }; - preferLocalBuild = true; + } + '' + install -D $src $out/share/papermc/papermc.jar + makeWrapper ${lib.getExe jre} "$out/bin/minecraft-server" \ + --append-flags "-jar $out/share/papermc/papermc.jar nogui" - dontUnpack = true; - dontConfigure = true; - - buildPhase = '' - cat > minecraft-server << EOF - #!${bash}/bin/sh - exec ${jre}/bin/java \$@ -jar $out/share/papermc/papermc.jar nogui - ''; - - installPhase = '' - install -Dm444 ${finalAttrs.jar} $out/share/papermc/papermc.jar - install -Dm555 -t $out/bin minecraft-server - ''; - - meta = { - description = "High-performance Minecraft Server"; - homepage = "https://papermc.io/"; - sourceProvenance = with lib.sourceTypes; [binaryBytecode]; - license = lib.licenses.gpl3Only; - platforms = lib.platforms.unix; - maintainers = with lib.maintainers; [aaronjanse neonfuz]; - mainProgram = "minecraft-server"; - }; -}) + '' diff --git a/packages/t-rex.nix b/packages/t-rex.nix deleted file mode 100644 index b714e9b..0000000 --- a/packages/t-rex.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - stdenv, - writeShellScriptBin, - fetchzip, - glibc, -}: let - src = fetchzip { - url = "https://github.com/trexminer/T-Rex/releases/download/0.26.8/t-rex-0.26.8-linux.tar.gz"; - sha256 = "sha256-qM/YIMqcntVYD8zJGCORQgIn1h4J4CDobyXwcdK3li8="; - stripRoot = false; - }; -in - writeShellScriptBin "t-rex" - '' - LD_LIBRARY_PATH=${stdenv.cc.cc.lib}/lib/:${glibc}/lib/:/run/opengl-driver/lib/ - exec ${glibc}/lib64/ld-linux-x86-64.so.2 \ - ${src}/t-rex --no-watchdog "$@" - ''