From cd265fa1a766c7c0f9d66bba147250b5874267e4 Mon Sep 17 00:00:00 2001 From: BuyMyMojo Date: Wed, 2 Apr 2025 09:36:08 +1100 Subject: [PATCH] Move home-manager to nixos config for easier multi system config --- nixos/flake.nix | 82 ++++++--- nixos/home-manager/low-power-laptop.nix | 76 +++++++++ nixos/home-manager/nixos.nix | 75 +++++++++ nixos/home-manager/nixos/packages.nix | 155 ++++++++++++++++++ nixos/home-manager/nixos/services.nix | 14 ++ nixos/home-manager/packages/common-cli.nix | 70 ++++++++ .../home-manager/packages/common-desktop.nix | 85 ++++++++++ nixos/programs/shadps4/.gitignore | 1 + nixos/programs/shadps4/flake.lock | 27 +++ nixos/programs/shadps4/flake.nix | 134 +++++++++++++++ 10 files changed, 700 insertions(+), 19 deletions(-) create mode 100644 nixos/home-manager/low-power-laptop.nix create mode 100644 nixos/home-manager/nixos.nix create mode 100644 nixos/home-manager/nixos/packages.nix create mode 100644 nixos/home-manager/nixos/services.nix create mode 100644 nixos/home-manager/packages/common-cli.nix create mode 100644 nixos/home-manager/packages/common-desktop.nix create mode 100644 nixos/programs/shadps4/.gitignore create mode 100644 nixos/programs/shadps4/flake.lock create mode 100644 nixos/programs/shadps4/flake.nix diff --git a/nixos/flake.nix b/nixos/flake.nix index d71424d..271faed 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -16,32 +16,57 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + moonlight = { + url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly. + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + + shadps4-git.url = "./programs/shadps4"; + + nixpkgs-gsr-ui = { + url = "github:js6pak/nixpkgs/gpu-screen-recorder-ui/init"; # Add `/develop` to the flake URL to use nightly. + }; + + bellado.url = "github:isabelroses/bellado"; + }; outputs = { nixpkgs, unstable, + home-manager, nix-your-shell, + nixpkgs-gsr-ui, + bellado, ... }@inputs: let system = "x86_64-linux"; + + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + overlays = [ nix-your-shell.overlays.default ]; + }; + + unstable = import unstable { + inherit system; + config.allowUnfree = true; + }; + + gsr-ui = import nixpkgs-gsr-ui { + inherit system; + config.allowUnfree = true; + }; in { nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - overlays = [ nix-your-shell.overlays.default ]; - }; - unstable = import unstable { - inherit system; - config.allowUnfree = true; - }; + inherit pkgs; + inherit unstable; inherit nix-your-shell; @@ -50,6 +75,19 @@ ./universal.nix ./hosts/nixos/configuration.nix ./hosts/nixos/services.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.buymymojo = ./home-manager/honixos.nix; + home-manager.extraSpecialArgs = { + inherit unstable; + inherit inputs; + inherit gsr-ui; + inherit bellado; + }; + } ]; }; @@ -57,22 +95,28 @@ nixosConfigurations.low-power-laptop = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - overlays = [ nix-your-shell.overlays.default ]; - }; - unstable = import unstable { - inherit system; - config.allowUnfree = true; - }; + inherit pkgs; + inherit unstable; inherit nix-your-shell; }; modules = [ ./universal.nix - ./hosts/low-power-laptop/configuration.nix + ./hosts/low-power-laptop/configuration.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.aria = ./home-manager/low-power-laptop.nix; + + home-manager.extraSpecialArgs = { + inherit unstable; + inherit inputs; + inherit bellado; + }; + } ]; }; diff --git a/nixos/home-manager/low-power-laptop.nix b/nixos/home-manager/low-power-laptop.nix new file mode 100644 index 0000000..45b33cc --- /dev/null +++ b/nixos/home-manager/low-power-laptop.nix @@ -0,0 +1,76 @@ +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "aria"; + home.homeDirectory = "/home/aria"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "24.11"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = [ + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # pkgs.hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/aria/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/nixos/home-manager/nixos.nix b/nixos/home-manager/nixos.nix new file mode 100644 index 0000000..b1de60d --- /dev/null +++ b/nixos/home-manager/nixos.nix @@ -0,0 +1,75 @@ +{ + config, + pkgs, + unstable, + inputs, + ... +}: + +{ + + imports = [ + ./nixos/packages.nix + ./nixos/services.nix + + ./packages/common-cli.nix + ./packages/common-desktop.nix + ]; + + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "buymymojo"; + home.homeDirectory = "/home/buymymojo"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "24.11"; # Please read the comment before changing. + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/buymymojo/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + EDITOR = "code"; + NIXPKGS_ALLOW_UNFREE = "1"; + }; + + home.sessionPath = [ + "/home/buymymojo/bin/" + ]; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/nixos/home-manager/nixos/packages.nix b/nixos/home-manager/nixos/packages.nix new file mode 100644 index 0000000..de3d396 --- /dev/null +++ b/nixos/home-manager/nixos/packages.nix @@ -0,0 +1,155 @@ +{ + config, + pkgs, + unstable, + gsr-ui, + inputs, + ... +}: + +{ + + home.file."jdks/zulujdk8".source = pkgs.zulu8; + home.file."jdks/zulujdk17".source = pkgs.zulu17; + home.file."jdks/zulujdk23".source = pkgs.zulu23; + + home.file."Godot/current".source = unstable.godot; + home.file."Godot/current-mono".source = unstable.godot-mono; + home.file."Godot/export-templates/current".source = unstable.godot-export-templates; + home.file."Godot/4.3".source = unstable.godot_4_3; + home.file."Godot/4.3-mono".source = unstable.godot_4_3-mono; + home.file."Godot/export-templates/4.3".source = unstable.godot_4_3-export-templates; + + home.file."bin/wine".source = unstable.wineWowPackages.waylandFull; + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = + with unstable; + with inputs; + [ + pkgs.nextcloud-client + pkgs.xpipe + pkgs.monero-gui + unstable.kiwix + + # pkgs.protonplus + unstable.pcsx2 + pkgs.rpcs3 + unstable.ryubing + unstable.torzu + pkgs.heroic-unwrapped + unstable.ludusavi + inputs.shadps4-git.packages."x86_64-linux".default + + unstable.wineWowPackages.waylandFull + unstable.winetricks + steamtinkerlaunch + + # === Minecraft === + pkgs.prismlauncher + # pkgs.zulu8 + # pkgs.zulu17 + # pkgs.zulu23 + # === Minecraft === + + # === CLI === + pkgs.bat + pkgs.btop + pkgs.rrsync + pkgs.ripgrep + pkgs.wl-clipboard + pkgs.poop # Compare the performance of multiple commands with a colorful terminal user interface + pkgs.age + pkgs.stow + unstable.yt-dlp + pkgs.aria2 + pkgs.jujutsu + pkgs.lazyjj + pkgs.biome + # === CLI === + + # === Image CLI === + unstable.oxipng + unstable.image_optim + unstable.jpegoptim + pkgs.libjxl + pkgs.libavif + pkgs.libwebp + pkgs.imagemagick + # === Image CLI === + + # === Game perf === + unstable.mangojuice + unstable.goverlay + # === Game perf === + + # === Dev tooling === + # pkgs.rustup + # === Dev tooling === + + # pkgs.polychromatic + + pkgs.lazydocker + pkgs.distrobox + pkgs.boxbuddy + + unstable.godot-mono + unstable.godot-export-templates + unstable.blender-hip + unstable.freecad-wayland + pkgs.unityhub + pkgs.material-maker + unstable.blockbench + + unstable.gpu-screen-recorder-gtk + gsr-ui.gpu-screen-recorder-ui + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + programs.mangohud = { + enable = true; + enableSessionWide = true; + package = unstable.mangohud; + }; + + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [ + wlrobs + obs-vkcapture + obs-pipewire-audio-capture + obs-teleport + obs-source-record + obs-source-clone + obs-composite-blur + ]; + }; + + # === ssh === + programs.ssh.matchBlocks = { + "*" = { + identityFile = "/home/buymymojo/.ssh/id_ed25519-mainpc"; + }; + + "game2.buymymojo.net" = { + hostname = "game2.buymymojo.net"; + user = "jumpbox"; + identityFile = "/home/buymymojo/.ssh/id_ed25519-mainpc"; + }; + + "git.aria.coffee" = { + hostname = "git.aria.coffee"; + user = "git"; + identityFile = "/home/buymymojo/.ssh/id_ed25519-mainpc"; + port = 23; + }; + }; + +} diff --git a/nixos/home-manager/nixos/services.nix b/nixos/home-manager/nixos/services.nix new file mode 100644 index 0000000..ddc5404 --- /dev/null +++ b/nixos/home-manager/nixos/services.nix @@ -0,0 +1,14 @@ +{ + config, + pkgs, + unstable, + inputs, + ... +}: + +{ + + services.ssh-agent.enable = true; + services.syncthing.enable = true; + +} diff --git a/nixos/home-manager/packages/common-cli.nix b/nixos/home-manager/packages/common-cli.nix new file mode 100644 index 0000000..f64ca27 --- /dev/null +++ b/nixos/home-manager/packages/common-cli.nix @@ -0,0 +1,70 @@ +{ + config, + pkgs, + unstable, + inputs, + lib, + ... +}: + +let + withExtraPackages = + pkg: extraPackages: + pkgs.runCommand "${pkg.name}-wrapped" { nativeBuildInputs = [ pkgs.makeWrapper ]; } '' + for exe in ${lib.getBin pkg}/bin/*; do + makeWrapper $exe $out/bin/$(basename $exe) --prefix PATH : ${lib.makeBinPath extraPackages} + done + ''; +in +{ + + imports = [ + inputs.bellado.homeManagerModules.default + ]; + + home.packages = + with unstable; + with inputs; + [ + + ]; + + programs.neovim = { + # package = unstable.neovim; + enable = true; + viAlias = true; + vimAlias = true; + plugins = with pkgs.vimPlugins; [ + lazy-nvim + ]; + + }; + + programs.git = { + enable = true; + userName = "BuyMyMojo"; + userEmail = "hello+git@buymymojo.net"; + lfs.enable = true; + signing.key = "E7B7B8D20C8753C077F9B17119AB7AA462B8AB3B"; + signing.signByDefault = true; + extraConfig = { + init = { + + defaultBranch = "main"; + }; + }; + }; + + programs.bellado = { + enable = true; + enableAliases = true; + }; + + programs.ssh.enable = true; + programs.ssh.addKeysToAgent = "yes"; + + # === shells === + programs.bash.enable = true; + programs.fish.enable = true; + +} diff --git a/nixos/home-manager/packages/common-desktop.nix b/nixos/home-manager/packages/common-desktop.nix new file mode 100644 index 0000000..c3ddf26 --- /dev/null +++ b/nixos/home-manager/packages/common-desktop.nix @@ -0,0 +1,85 @@ +{ + config, + pkgs, + unstable, + inputs, + lib, + ... +}: + +let + withExtraPackages = + pkg: extraPackages: + pkgs.runCommand "${pkg.name}-wrapped" { nativeBuildInputs = [ pkgs.makeWrapper ]; } '' + for exe in ${lib.getBin pkg}/bin/*; do + makeWrapper $exe $out/bin/$(basename $exe) --prefix PATH : ${lib.makeBinPath extraPackages} + done + ''; +in +{ + + imports = [ + inputs.moonlight.homeModules.default + ]; + + nixpkgs = { + overlays = [ + inputs.moonlight.overlays.default + ]; + }; + + home.packages = + with unstable; + with inputs; + [ + pkgs.yubioath-flutter + pkgs.qbittorrent + unstable.peazip + + # === Communication === + pkgs.vesktop + pkgs.discord-canary + pkgs.signal-desktop + pkgs.telegram-desktop + # pkgs.thunderbird-latest-unwrapped + # === Communication === + + # === Editors/Office === + unstable.libreoffice-fresh + # pkgs.kdePackages.kate + pkgs.jetbrains.webstorm + pkgs.jetbrains.rider + pkgs.jetbrains.idea-community + # unstable.neovim + # === Editors/Office === + + # === Media === + unstable.gimp + unstable.krita + # pkgs.mpv + unstable.losslesscut-bin + unstable.jellyfin-media-player + # === Media === + + unstable.orca-slicer + ]; + + programs.moonlight-mod = { + enable = true; + # stable = { + # extensions = { + # allActivites.enabled = true; + # alwaysFocus.enabled = true; + + # betterEmbedsYT = { + # enabled = true; + # config = { + # fullDescription = false; + # expandDescription = true; + # }; + # }; + # }; + # }; + }; + +} diff --git a/nixos/programs/shadps4/.gitignore b/nixos/programs/shadps4/.gitignore new file mode 100644 index 0000000..82e0cdf --- /dev/null +++ b/nixos/programs/shadps4/.gitignore @@ -0,0 +1 @@ +/result \ No newline at end of file diff --git a/nixos/programs/shadps4/flake.lock b/nixos/programs/shadps4/flake.lock new file mode 100644 index 0000000..7fa58fe --- /dev/null +++ b/nixos/programs/shadps4/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1743095683, + "narHash": "sha256-gWd4urRoLRe8GLVC/3rYRae1h+xfQzt09xOfb0PaHSk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5e5402ecbcb27af32284d4a62553c019a3a49ea6", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nixos/programs/shadps4/flake.nix b/nixos/programs/shadps4/flake.nix new file mode 100644 index 0000000..1acba3f --- /dev/null +++ b/nixos/programs/shadps4/flake.nix @@ -0,0 +1,134 @@ +{ + description = "Current git build of shadps4"; + + inputs = { + # nixpkgs.url = "github:nixos/nixpkgs?rev=cfd19cdc54680956dc1816ac577abba6b58b901c"; # Same as https://github.com/shadps4-emu/shadPS4/blob/main/shell.nix + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + pkgs = import nixpkgs { + config.allowUnfree = true; + system = "x86_64-linux"; + }; + in + { + + packages.x86_64-linux.default = pkgs.stdenv.mkDerivation { + name = "shadps4-git"; + pname = "shadps4"; + + src = pkgs.fetchFromGitHub { + owner = "shadps4-emu"; + repo = "shadPS4"; + rev = "a707d31a4c23fdd8aefb146ae04d25ecbca246d0"; + hash = "sha256-ZOuhdZuLXbR3kzNwoK7jioFy+MjKL8GDBtVRsyGcL98="; + fetchSubmodules = true; + leaveDotGit = true; + }; + + nativeBuildInputs = [ + pkgs.llvmPackages_18.clang + pkgs.cmake + pkgs.pkg-config + pkgs.git + pkgs.qt6.wrapQtAppsHook + ]; + + buildInputs = [ + pkgs.alsa-lib + pkgs.libpulseaudio + pkgs.openal + pkgs.openssl + pkgs.zlib + pkgs.libedit + pkgs.udev + pkgs.libevdev + pkgs.SDL2 + pkgs.jack2 + pkgs.sndio + pkgs.qt6.qtbase + pkgs.qt6.qttools + pkgs.qt6.qtmultimedia + + pkgs.vulkan-headers + pkgs.vulkan-utility-libraries + pkgs.vulkan-tools + + pkgs.ffmpeg + pkgs.fmt + pkgs.glslang + pkgs.libxkbcommon + pkgs.wayland + pkgs.xorg.libxcb + pkgs.xorg.xcbutil + pkgs.xorg.xcbutilkeysyms + pkgs.xorg.xcbutilwm + pkgs.sdl3 + pkgs.stb + pkgs.qt6.qtwayland + pkgs.wayland-protocols + pkgs.libpng + ]; + + # buildPhase = '' + # # === setup === + # export QT_QPA_PLATFORM="wayland" + # export QT_PLUGIN_PATH="${pkgs.qt6.qtwayland}/lib/qt-6/plugins:${pkgs.qt6.qtbase}/lib/qt-6/plugins" + # export QML2_IMPORT_PATH="${pkgs.qt6.qtbase}/lib/qt-6/qml" + # export CMAKE_PREFIX_PATH="${pkgs.vulkan-headers}:$CMAKE_PREFIX_PATH" + + # # OpenGL + # export LD_LIBRARY_PATH="${ + # pkgs.lib.makeLibraryPath [ + # pkgs.libglvnd + # pkgs.vulkan-tools + # ] + # }:$LD_LIBRARY_PATH" + + # export LDFLAGS="-L${pkgs.llvmPackages_18.libcxx}/lib -lc++" + # export LC_ALL="C.UTF-8" + # export XAUTHORITY=${builtins.getEnv "XAUTHORITY"} + # # === setup === + + # # === build === + # cmake -S . -B build/ -DENABLE_QT_GUI=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + # # cmake --build ./build --parallel $(nproc) + # # === build === + # ''; + + # installPhase = '' + # cmake --install . --parallel $(nproc) + # ''; + + cmakeFlags = [ + (nixpkgs.lib.cmakeBool "ENABLE_QT_GUI" true) + (nixpkgs.lib.cmakeBool "ENABLE_UPDATER" false) + ]; + + # Still in development, help with debugging + # cmakeBuildType = "RelWithDebugInfo"; + # dontStrip = true; + + installPhase = '' + runHook preInstall + + install -D -t $out/bin shadps4 + install -Dm644 $src/.github/shadps4.png $out/share/icons/hicolor/512x512/apps/net.shadps4.shadPS4.png + install -Dm644 -t $out/share/applications $src/dist/net.shadps4.shadPS4.desktop + install -Dm644 -t $out/share/metainfo $src/dist/net.shadps4.shadPS4.metainfo.xml + + runHook postInstall + ''; + + runtimeDependencies = [ + pkgs.vulkan-loader + pkgs.xorg.libXi + ]; + + }; + + }; +}