diff --git a/flake.lock b/flake.lock index e056373..b417346 100644 --- a/flake.lock +++ b/flake.lock @@ -404,7 +404,7 @@ "nur": "nur", "pre-commit-hooks": "pre-commit-hooks", "vscode-server": "vscode-server", - "wsl": "wsl" + "nixos-wsl": "nixos-wsl" } }, "rust-overlay": { @@ -488,7 +488,7 @@ "type": "github" } }, - "wsl": { + "nixos-wsl": { "inputs": { "flake-compat": [], "flake-utils": [ diff --git a/flake.nix b/flake.nix index af9edd7..0d780e6 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ system = "x86_64-linux"; username = "winston"; isGraphical = false; - extraModules = [ inputs.wsl.nixosModules.default ]; + extraModules = [ inputs.nixos-wsl.nixosModules.default ]; } ]; imports = [ inputs.pre-commit-hooks.flakeModule ]; @@ -65,9 +65,6 @@ RULES = "./home/secrets/secrets.nix"; buildInputs = (with pkgs; [ - dhall - dhall-lsp-server - dhall-yaml just nix-output-monitor nixd @@ -132,7 +129,7 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - wsl = { + nixos-wsl = { url = "github:nix-community/nixos-wsl"; inputs.flake-compat.follows = ""; inputs.flake-utils.follows = "flake-utils"; diff --git a/home/default.nix b/home/default.nix index ce027d8..20edd12 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,6 +1,7 @@ { config, lib, + osConfig, pkgs, ... }: @@ -43,9 +44,10 @@ in watchexec ] ++ lib.optionals (config.isGraphical && isLinux) [ - _1password-gui - uhk-agent + (_1password-gui.override { polkitPolicyOwners = [ osConfig.dotfiles.username ]; }) neovide + nextcloud-client + uhk-agent ] ); sessionVariables.SSH_AUTH_SOCK = lib.optionalString isDarwin "${config.programs.gpg.homedir}/S.gpg-agent.ssh"; diff --git a/home/lib.nix b/home/lib.nix index 1b8e2e9..6c46ba7 100644 --- a/home/lib.nix +++ b/home/lib.nix @@ -6,6 +6,7 @@ }: rec { inherit (pkgs.stdenv) isLinux isDarwin; + inherit (pkgs.lib) mkDefault mkOption types; extraSpecialArgs = { flakePath = @@ -21,10 +22,10 @@ rec { "/Users/${username}" else throw "Unsupported system"; - home.username = username; - isGraphical = false; - targets.genericLinux.enable = isLinux; - xdg.mime.enable = isLinux; + home.username = mkDefault username; + isGraphical = mkDefault false; + targets.genericLinux.enable = mkDefault isLinux; + xdg.mime.enable = mkDefault isLinux; }; modules = @@ -36,10 +37,7 @@ rec { ]) ++ [ ( - { osConfig, lib, ... }: - let - inherit (lib) mkOption types; - in + { osConfig, ... }: { options = { isGraphical = mkOption { diff --git a/machines/common/darwin/default.nix b/machines/common/darwin/default.nix index d6830e3..9342768 100644 --- a/machines/common/darwin/default.nix +++ b/machines/common/darwin/default.nix @@ -1,5 +1,4 @@ { - config, pkgs, lib, ... @@ -66,6 +65,7 @@ builtins.concatStringsSep "\n" (map (app: ''yabai -m rule --add app="${app}" ${options}'') apps); unmanaged = apps: mkRules apps "manage=off"; in + # bash '' # auto-inject scripting additions yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa" @@ -119,6 +119,7 @@ ) ); in + # bash '' #!/usr/bin/env sh # focus window @@ -157,11 +158,9 @@ }; }; - environment.systemPackages = [ pkgs.jankyborders ]; launchd.user.agents.jankyborders.serviceConfig = { - ProgramArguments = [ "${pkgs.jankyborders}/bin/borders" ]; + ProgramArguments = [ (lib.getExe pkgs.jankyborders) ]; KeepAlive = true; RunAtLoad = true; - EnvironmentVariables.PATH = "${pkgs.jankyborders}/bin:${config.environment.systemPath}"; }; } diff --git a/machines/common/linux/boot.nix b/machines/common/nixos/boot.nix similarity index 100% rename from machines/common/linux/boot.nix rename to machines/common/nixos/boot.nix diff --git a/machines/common/linux/cosmic.nix b/machines/common/nixos/cosmic.nix similarity index 100% rename from machines/common/linux/cosmic.nix rename to machines/common/nixos/cosmic.nix diff --git a/machines/common/linux/default.nix b/machines/common/nixos/default.nix similarity index 100% rename from machines/common/linux/default.nix rename to machines/common/nixos/default.nix diff --git a/machines/common/linux/gnome.nix b/machines/common/nixos/gnome.nix similarity index 100% rename from machines/common/linux/gnome.nix rename to machines/common/nixos/gnome.nix diff --git a/machines/common/linux/greeter.nix b/machines/common/nixos/greeter.nix similarity index 93% rename from machines/common/linux/greeter.nix rename to machines/common/nixos/greeter.nix index db5a8a8..2be6a2a 100644 --- a/machines/common/linux/greeter.nix +++ b/machines/common/nixos/greeter.nix @@ -15,9 +15,9 @@ let ); binary = { - swayfx = "sway"; + hyprland = "Hyprland"; sway = "sway"; - hyprland = "hypr"; + swayfx = "sway"; } .${desktop} or (throw "greetd: desktop not supported"); in @@ -25,7 +25,7 @@ in config = lib.mkIf condition { services.greetd = { enable = true; - settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --cmd '${pkgs.dbus}/bin/dbus-run-session ${binary}'"; + settings.default_session.command = "${lib.getExe pkgs.greetd.tuigreet} --remember --cmd ${binary}"; }; services.gnome.gnome-keyring.enable = true; security.pam.services.greetd = { diff --git a/machines/common/linux/hyprland.nix b/machines/common/nixos/hyprland.nix similarity index 100% rename from machines/common/linux/hyprland.nix rename to machines/common/nixos/hyprland.nix diff --git a/machines/common/linux/input.nix b/machines/common/nixos/input.nix similarity index 100% rename from machines/common/linux/input.nix rename to machines/common/nixos/input.nix diff --git a/machines/common/linux/network.nix b/machines/common/nixos/network.nix similarity index 100% rename from machines/common/linux/network.nix rename to machines/common/nixos/network.nix diff --git a/machines/common/linux/podman.nix b/machines/common/nixos/podman.nix similarity index 100% rename from machines/common/linux/podman.nix rename to machines/common/nixos/podman.nix diff --git a/machines/common/linux/sound.nix b/machines/common/nixos/sound.nix similarity index 100% rename from machines/common/linux/sound.nix rename to machines/common/nixos/sound.nix diff --git a/machines/common/linux/sway.nix b/machines/common/nixos/sway.nix similarity index 74% rename from machines/common/linux/sway.nix rename to machines/common/nixos/sway.nix index 50e6d58..3477d34 100644 --- a/machines/common/linux/sway.nix +++ b/machines/common/nixos/sway.nix @@ -37,23 +37,24 @@ in programs.sway = { enable = true; - package = lib.mkIf (config.dotfiles.desktop == "swayfx") pkgs.swayfx; + package = if (config.dotfiles.desktop == "swayfx") then pkgs.swayfx else pkgs.sway; extraPackages = with pkgs; [ swaylock-effects swayidle ]; - extraSessionCommands = '' - # session - export XDG_SESSION_TYPE=wayland - export XDG_SESSION_DESKTOP=sway - export XDG_CURRENT_DESKTOP=sway - # wayland - export NIXOS_OZONE_WL=1 - export MOZ_ENABLE_WAYLAND=1 - export QT_QPA_PLATFORM=wayland - export SDL_VIDEODRIVER=wayland - export _JAVA_AWT_WM_NONREPARENTING=1 - ''; + extraSessionCommands = # bash + '' + # session + export XDG_SESSION_TYPE=wayland + export XDG_SESSION_DESKTOP=sway + export XDG_CURRENT_DESKTOP=sway + # wayland + export NIXOS_OZONE_WL=1 + export MOZ_ENABLE_WAYLAND=1 + export QT_QPA_PLATFORM=wayland + export SDL_VIDEODRIVER=wayland + export _JAVA_AWT_WM_NONREPARENTING=1 + ''; wrapperFeatures = { base = true; gtk = true; diff --git a/machines/common/linux/traefik.nix b/machines/common/nixos/traefik.nix similarity index 100% rename from machines/common/linux/traefik.nix rename to machines/common/nixos/traefik.nix diff --git a/machines/common/wsl/default.nix b/machines/common/wsl/default.nix deleted file mode 100644 index c75b880..0000000 --- a/machines/common/wsl/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ lib, pkgs, ... }: -let - inherit (lib) mkForce; -in -{ - services = { - kanata.enable = mkForce false; - dnsmasq.enable = mkForce false; - mullvad-vpn.enable = mkForce false; - stubby.enable = mkForce false; - }; - virtualisation.podman.enable = mkForce false; - - system = { - build.installBootLoader = mkForce "${pkgs.coreutils}/bin/true"; - stateVersion = "23.11"; - }; -} diff --git a/machines/futomaki/default.nix b/machines/futomaki/default.nix index b99aa5a..2fada27 100644 --- a/machines/futomaki/default.nix +++ b/machines/futomaki/default.nix @@ -2,7 +2,10 @@ { imports = [ ./hardware.nix ]; - dotfiles.desktop = "sway"; + dotfiles = { + desktop = "sway"; + gaming.enable = true; + }; networking = { networkmanager.enable = true; @@ -17,54 +20,31 @@ time.timeZone = "Europe/Vienna"; services = { - flatpak.enable = true; openssh.enable = true; pcscd.enable = true; - transmission.enable = true; - transmission.openFirewall = true; }; - virtualisation.podman.enable = true; - virtualisation.libvirtd.enable = true; + virtualisation = { + libvirtd.enable = true; + podman.enable = true; + }; users.users."${config.dotfiles.username}".extraGroups = [ "libvirtd" - "transmission" ]; environment.systemPackages = with pkgs; [ - cabextract - discover-overlay - lutris-free - mangohud + (pkgs.wrapOBS { + plugins = with pkgs.obs-studio-plugins; [ + obs-backgroundremoval + obs-composite-blur + obs-pipewire-audio-capture + wlrobs + ]; + }) virt-manager - wineWowPackages.staging - winetricks + virtiofsd ]; - programs = { - gamemode = { - enable = true; - settings = { - custom = { - start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'"; - end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'"; - }; - }; - }; - steam = { - enable = true; - package = pkgs.steam.override { - extraEnv.MANGOHUD = 1; - extraPkgs = - p: with p; [ - corefonts - protontricks - gamescope - ]; - }; - }; - }; - system.stateVersion = "22.11"; } diff --git a/machines/lib.nix b/machines/lib.nix index 82c8515..697bafe 100644 --- a/machines/lib.nix +++ b/machines/lib.nix @@ -3,7 +3,7 @@ rec { hmCommonConfig = { username }: ( - { config, pkgs, ... }: + { pkgs, ... }: let homeLib = import ../home/lib.nix { inherit inputs username pkgs; }; in @@ -34,6 +34,9 @@ rec { extraModules ? [ ], }: let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + inherit (pkgs) lib; + ldTernary = l: d: if pkgs.stdenv.isLinux then @@ -42,17 +45,16 @@ rec { d else throw "Unsupported system"; - target = ldTernary "nixosConfigurations" "darwinConfigurations"; builder = ldTernary inputs.nixpkgs.lib.nixosSystem inputs.darwin.lib.darwinSystem; + hostPlatform = ldTernary "nixos" "darwin"; module = ldTernary "nixosModules" "darwinModules"; - hostPlatform = ldTernary "linux" "darwin"; + target = ldTernary "nixosConfigurations" "darwinConfigurations"; - linuxModules = [ inputs.nixos-cosmic.nixosModules.default ]; darwinModules = [ inputs.nekowinston-nur.darwinModules.default ]; - - pkgs = inputs.nixpkgs.legacyPackages.${system}; - inherit (pkgs) lib; - inherit (pkgs.lib) mkOption types; + linuxModules = [ + inputs.nixos-cosmic.nixosModules.default + inputs.nixos-wsl.nixosModules.default + ]; in { ${target}."${host}" = builder { @@ -60,43 +62,25 @@ rec { modules = [ { - options = { + config = { dotfiles = { - username = mkOption { - type = types.str; - default = username; - description = "The username of the user"; - }; - desktop = mkOption { - type = types.nullOr ( - types.enum [ - "cosmic" - "gnome" - "hyprland" - "sway" - "swayfx" - ] - ); - default = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null; - description = "The desktop environment to use"; - }; - }; - isGraphical = mkOption { - type = types.bool; - default = isGraphical; - description = "Whether the system is a graphical target"; + username = lib.mkDefault username; + desktop = if (pkgs.stdenv.isLinux && isGraphical) then "sway" else null; }; + isGraphical = lib.mkDefault isGraphical; + networking.hostName = lib.mkDefault host; }; - config.networking.hostName = host; } + ../modules/shared + ../modules/${hostPlatform} ./common/shared ./common/${hostPlatform} ./${host} inputs.home-manager.${module}.home-manager (hmCommonConfig { inherit username; }) ] - ++ lib.optionals pkgs.stdenv.isLinux linuxModules ++ lib.optionals pkgs.stdenv.isDarwin darwinModules + ++ lib.optionals pkgs.stdenv.isLinux linuxModules ++ extraModules; specialArgs = { inherit inputs; diff --git a/machines/yuba/default.nix b/machines/yuba/default.nix index a28306a..d6d2d4a 100644 --- a/machines/yuba/default.nix +++ b/machines/yuba/default.nix @@ -1,5 +1,5 @@ { - imports = [ ../common/wsl ]; + dotfiles.wsl.enable = true; i18n.defaultLocale = "en_US.UTF-8"; location = { @@ -8,10 +8,5 @@ }; time.timeZone = "Europe/Vienna"; - wsl = { - enable = true; - defaultUser = "winston"; - startMenuLaunchers = true; - useWindowsDriver = true; - }; + system.stateVersion = "23.11"; } diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/modules/darwin/default.nix @@ -0,0 +1 @@ +{ } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix new file mode 100644 index 0000000..15e647d --- /dev/null +++ b/modules/nixos/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./gaming.nix + ./wsl.nix + ]; +} diff --git a/modules/nixos/gaming.nix b/modules/nixos/gaming.nix new file mode 100644 index 0000000..ff74578 --- /dev/null +++ b/modules/nixos/gaming.nix @@ -0,0 +1,41 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.dotfiles.gaming; + gamePkgs = + pkgs: with pkgs; [ + corefonts + gamescope + mangohud + ]; +in +{ + options.dotfiles.gaming.enable = lib.mkEnableOption "gaming configuration"; + + config = lib.mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + discover-overlay + (lutris.override { extraPkgs = gamePkgs; }) + ]; + + programs = { + gamemode = { + enable = true; + settings = { + custom = { + start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'"; + end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'"; + }; + }; + }; + steam = { + enable = true; + package = pkgs.steam.override { extraPkgs = gamePkgs; }; + }; + }; + }; +} diff --git a/modules/nixos/wsl.nix b/modules/nixos/wsl.nix new file mode 100644 index 0000000..c511463 --- /dev/null +++ b/modules/nixos/wsl.nix @@ -0,0 +1,37 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.dotfiles.wsl; + inherit (lib) mkDefault mkForce; +in +{ + options.dotfiles.wsl.enable = lib.mkEnableOption "NixOS-WSL specific options"; + + config = lib.mkIf cfg.enable { + # disable services that are not needed in WSL + services = { + dnsmasq.enable = mkForce false; + kanata.enable = mkForce false; + mullvad-vpn.enable = mkForce false; + stubby.enable = mkForce false; + }; + + # podman runs on native Windows + virtualisation.podman.enable = mkForce false; + + # main WSL defaults + wsl = { + enable = mkDefault true; + defaultUser = mkDefault config.dotfiles.username; + startMenuLaunchers = mkDefault true; + useWindowsDriver = mkDefault true; + }; + + # skip installing the bootloader + system.build.installBootLoader = mkForce "${pkgs.coreutils}/bin/true"; + }; +} diff --git a/modules/shared/config.nix b/modules/shared/config.nix new file mode 100644 index 0000000..a899c38 --- /dev/null +++ b/modules/shared/config.nix @@ -0,0 +1,36 @@ +{ + lib, + ... +}: +let + inherit (lib) types; +in +{ + options = { + dotfiles = lib.mkOption { + type = types.submodule { + options = { + desktop = lib.mkOption { + description = "The desktop environment to use"; + type = types.nullOr ( + types.enum [ + "cosmic" + "gnome" + "hyprland" + "sway" + "swayfx" + ] + ); + }; + username = lib.mkOption { + description = "The username of the user"; + type = types.str; + }; + }; + }; + }; + isGraphical = lib.mkEnableOption "" // { + description = "Whether the system is a graphical target"; + }; + }; +} diff --git a/modules/shared/default.nix b/modules/shared/default.nix new file mode 100644 index 0000000..6b0d6c3 --- /dev/null +++ b/modules/shared/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./config.nix + ]; +} diff --git a/pkgs/overlays.nix b/pkgs/overlays.nix index 8af9cbc..3719937 100644 --- a/pkgs/overlays.nix +++ b/pkgs/overlays.nix @@ -4,15 +4,15 @@ ( final: prev: let - srcs = prev.callPackages ../_sources/generated.nix { }; + srcs = final.callPackages ../_sources/generated.nix { }; in { nushellPlugins = (prev.nushellPlugins or { }) // { - clipboard = prev.callPackage ./nu_plugin_clipboard.nix { }; + clipboard = final.callPackage ./nu_plugin_clipboard.nix { }; }; starship = prev.starship.overrideAttrs (old: { patches = [ - (prev.fetchpatch { + (final.fetchpatch { url = "https://github.com/starship/starship/pull/4439.patch"; sha256 = "sha256-BKH3elz96Oa424Oz5UIKA2/BOpkym1LTestvccFinnc="; }) @@ -22,10 +22,10 @@ inherit (srcs.yabai) version src; }); nur = import inputs.nur { - nurpkgs = prev; - pkgs = prev; + nurpkgs = final; + pkgs = final; repoOverrides = { - nekowinston = inputs.nekowinston-nur.packages.${prev.stdenv.system}; + nekowinston = inputs.nekowinston-nur.packages.${final.stdenv.system}; }; }; }