diff --git a/deploy.nix b/deploy.nix index a4a51e7..87d1934 100644 --- a/deploy.nix +++ b/deploy.nix @@ -55,5 +55,14 @@ user = "deck"; }; }; + yuge = { + hostname = "sdeck"; + interactiveSudo = true; + profiles.system = { + sshUser = "deck"; + user = "root"; + path = deploy-rs.lib.x86_64-linux.activate.custom self.systemConfigs.yuge "./bin/activate"; + }; + }; }; } diff --git a/flake.lock b/flake.lock index 3058281..1de7b6c 100644 --- a/flake.lock +++ b/flake.lock @@ -1045,6 +1045,22 @@ } }, "flake-compat_13": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_14": { "flake": false, "locked": { "lastModified": 1751685974, @@ -1307,6 +1323,28 @@ "type": "github" } }, + "flake-parts_7": { + "inputs": { + "nixpkgs-lib": [ + "system-manager", + "userborn", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems_2" @@ -1522,7 +1560,7 @@ }, "flake-utils_20": { "inputs": { - "systems": "systems_26" + "systems": "systems_27" }, "locked": { "lastModified": 1731533236, @@ -1540,7 +1578,7 @@ }, "flake-utils_21": { "inputs": { - "systems": "systems_27" + "systems": "systems_28" }, "locked": { "lastModified": 1731533236, @@ -1558,7 +1596,7 @@ }, "flake-utils_22": { "inputs": { - "systems": "systems_29" + "systems": "systems_30" }, "locked": { "lastModified": 1731533236, @@ -1760,6 +1798,29 @@ "type": "github" } }, + "gitignore_3": { + "inputs": { + "nixpkgs": [ + "system-manager", + "userborn", + "pre-commit-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "gnome-shell": { "flake": false, "locked": { @@ -3352,6 +3413,34 @@ "type": "github" } }, + "pre-commit-hooks-nix": { + "inputs": { + "flake-compat": [ + "system-manager", + "userborn", + "flake-compat" + ], + "gitignore": "gitignore_3", + "nixpkgs": [ + "system-manager", + "userborn", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1769069492, + "narHash": "sha256-Efs3VUPelRduf3PpfPP2ovEB4CXT7vHf8W+xc49RL/U=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "a1ef738813b15cf8ec759bdff5761b027e3e1d23", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "aagl": "aagl", @@ -3414,6 +3503,7 @@ "shitpost-src": "shitpost-src", "sops-nix": "sops-nix", "stylix": "stylix", + "system-manager": "system-manager", "tangled-core": "tangled-core", "tmux-float": "tmux-float", "tmux-super-fingers-src": "tmux-super-fingers-src", @@ -3899,6 +3989,28 @@ "type": "github" } }, + "system-manager": { + "inputs": { + "flake-compat": "flake-compat_13", + "nixpkgs": [ + "nixpkgs" + ], + "userborn": "userborn" + }, + "locked": { + "lastModified": 1777545354, + "narHash": "sha256-T3u9Ixg0SX6bYYXHYEZ7O+MW0pQ1qxnjIQKCPM+irN4=", + "owner": "numtide", + "repo": "system-manager", + "rev": "6eac5ac077960363d3807b1c74f47103d1f62efd", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "system-manager", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1689347949, @@ -4243,6 +4355,21 @@ "type": "github" } }, + "systems_30": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "systems_4": { "locked": { "lastModified": 1681028828, @@ -4337,7 +4464,7 @@ "inputs": { "actor-typeahead-src": "actor-typeahead-src", "fenix": "fenix_3", - "flake-compat": "flake-compat_13", + "flake-compat": "flake-compat_14", "gomod2nix": "gomod2nix", "htmx-src": "htmx-src", "htmx-ws-src": "htmx-ws-src", @@ -4593,6 +4720,35 @@ "type": "github" } }, + "userborn": { + "inputs": { + "flake-compat": [ + "system-manager", + "flake-compat" + ], + "flake-parts": "flake-parts_7", + "nixpkgs": [ + "system-manager", + "nixpkgs" + ], + "pre-commit-hooks-nix": "pre-commit-hooks-nix", + "systems": "systems_26" + }, + "locked": { + "lastModified": 1770377964, + "narHash": "sha256-q2pnlX2IW0kg80GLFnwWd/GigIpkuZnyKPLhrgJql3E=", + "owner": "jfroche", + "repo": "userborn", + "rev": "55c2cd7952c207a62736a5bbd9499ea73da18d24", + "type": "github" + }, + "original": { + "owner": "jfroche", + "ref": "system-manager", + "repo": "userborn", + "type": "github" + } + }, "utils": { "inputs": { "systems": "systems_4" @@ -4614,7 +4770,7 @@ "vicinae": { "inputs": { "nixpkgs": "nixpkgs_11", - "systems": "systems_28" + "systems": "systems_29" }, "locked": { "lastModified": 1777243295, diff --git a/flake.nix b/flake.nix index 468517a..0a89cda 100644 --- a/flake.nix +++ b/flake.nix @@ -197,6 +197,10 @@ url = "github:Janik-Haag/nixos-dns"; inputs.nixpkgs.follows = "nixpkgs"; }; + system-manager = { + url = "github:numtide/system-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # Pinned source inputs (replace fetchFromGitHub/fetchgit). Update with `nix flake update `. bblauncher-src = { @@ -285,6 +289,7 @@ nur, deploy-rs, nixos-raspberrypi, + system-manager, ... } @ inputs: let devices = { @@ -340,6 +345,14 @@ hasGui = false; # Don't wan't to run GUI apps on the SteamDeck isServer = true; }; + yuge = mkDevice { + name = "yuge"; + system = "x86_64-linux"; + user = "deck"; + hasGui = false; + isServer = true; + isSystemManager = true; + }; }; mkDevice = device: rec { @@ -352,6 +365,10 @@ if (builtins.hasAttr "isNix" device) then device.isNix else false; + isSystemManager = + if (builtins.hasAttr "isSystemManager" device) + then device.isSystemManager + else false; isDarwin = !isNull (builtins.match ".*-darwin" device.system); isArm = !isNull (builtins.match "aarch64-.*" device.system); isDesktopLinux = isLinux && hasGui; @@ -397,6 +414,7 @@ # linux_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isLinux) devices; darwin_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isDarwin) devices; rpi_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isArm && x.isLinux) devices; + systemManager_devices = nixpkgs.lib.attrsets.filterAttrs (n: x: x.isSystemManager) devices; overlays = import ./overlays.nix { inherit inputs; @@ -442,6 +460,11 @@ }; }; + systemConfigs = import ./system-manager { + inherit inputs system-manager; + devices = systemManager_devices; + }; + installerImages = let nixos = self.nixosConfigurations; mkImage = nixosConfig: nixosConfig.config.system.build.sdImage; diff --git a/modules/system-manager/.gitkeep b/modules/system-manager/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/steamdeck/default.nix b/steamdeck/default.nix index 7aa984f..cd21374 100644 --- a/steamdeck/default.nix +++ b/steamdeck/default.nix @@ -1,10 +1,5 @@ -{ - pkgs, - lib, - ... -}: { +{pkgs, ...}: { imports = [ - ./tailscale.nix ../home/programs/helix.nix ../home/programs/sops.nix ]; @@ -49,15 +44,6 @@ _1password-cli just ]; - file.".ssh/rc".text = '' - export PATH="/nix/var/nix/profiles/default/bin:$PATH" - ''; - activation.tailscale-service = let - tailscale_service = pkgs.writeText "tailscaled.service" (builtins.replaceStrings ["/usr/bin/tailscaled"] ["${pkgs.tailscale}/bin/tailscaled"] (builtins.readFile ./tailscaled.service)); - in - lib.hm.dag.entryAfter ["writeBoundary"] '' - run echo cp ${tailscale_service} /etc/systemd/system/tailscaled.service - ''; stateVersion = "24.11"; }; } diff --git a/steamdeck/tailscale.nix b/steamdeck/tailscale.nix deleted file mode 100644 index 9de09f1..0000000 --- a/steamdeck/tailscale.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ - pkgs, - config, - ... -}: { - imports = [ - ../modules/home/tailscale.nix - ]; - services.tailscale = { - enable = false; - }; - - home.packages = [ - pkgs.tailscale - ]; -} diff --git a/steamdeck/tailscaled.service b/steamdeck/tailscaled.service deleted file mode 100644 index 6f531fe..0000000 --- a/steamdeck/tailscaled.service +++ /dev/null @@ -1,23 +0,0 @@ -[Unit] -Description=Tailscale node agent -Documentation=https://tailscale.com/kb/ -Wants=network-pre.target -After=network-pre.target NetworkManager.service systemd-resolved.service - -[Service] -ExecStartPre=/usr/bin/tailscaled --cleanup -ExecStart=/usr/bin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port=41641 -ExecStopPost=/usr/bin/tailscaled --cleanup - -Restart=on-failure - -RuntimeDirectory=tailscale -RuntimeDirectoryMode=0755 -StateDirectory=tailscale -StateDirectoryMode=0700 -CacheDirectory=tailscale -CacheDirectoryMode=0750 -Type=notify - -[Install] -WantedBy=multi-user.target diff --git a/system-manager/default.nix b/system-manager/default.nix new file mode 100644 index 0000000..6bfbbb5 --- /dev/null +++ b/system-manager/default.nix @@ -0,0 +1,18 @@ +{ + devices, + inputs, + system-manager, + ... +}: (builtins.mapAttrs ( + name: device: + system-manager.lib.makeSystemConfig { + modules = [ + { + nixpkgs.hostPlatform = device.system; + _module.args = {inherit device inputs;}; + } + ./${device.name}/configuration.nix + ]; + } + ) + devices) diff --git a/system-manager/yuge/configuration.nix b/system-manager/yuge/configuration.nix new file mode 100644 index 0000000..2b9bc52 --- /dev/null +++ b/system-manager/yuge/configuration.nix @@ -0,0 +1,10 @@ +{...}: { + imports = [ + ./shadps4.nix + ./sshd.nix + ./sudo.nix + ./tailscale.nix + ]; + + system-manager.allowAnyDistro = true; +} diff --git a/system-manager/yuge/shadps4.nix b/system-manager/yuge/shadps4.nix new file mode 100644 index 0000000..2301fc2 --- /dev/null +++ b/system-manager/yuge/shadps4.nix @@ -0,0 +1,29 @@ +{...}: { + environment.etc."xdg/applications/bloodborne.desktop" = { + replaceExisting = true; + text = '' + [Desktop Entry] + Name=Bloodborne + Comment=Bloodborne via shadPS4 + Exec=/home/deck/.local/bin/shadps4 -g /home/deck/Games/Bloodborne/CUSA00900/eboot.bin + Icon=net.shadps4.shadPS4 + Terminal=false + Type=Application + Categories=Game; + ''; + }; + + environment.etc."xdg/applications/shadps4-qt.desktop" = { + replaceExisting = true; + text = '' + [Desktop Entry] + Name=shadPS4 (Qt) + Comment=shadPS4 PS4 emulator — Qt launcher + Exec=/home/deck/.local/bin/shadps4-qt + Icon=net.shadps4.shadPS4 + Terminal=false + Type=Application + Categories=Game; + ''; + }; +} diff --git a/system-manager/yuge/sshd.nix b/system-manager/yuge/sshd.nix new file mode 100644 index 0000000..6c59133 --- /dev/null +++ b/system-manager/yuge/sshd.nix @@ -0,0 +1,8 @@ +{...}: { + environment.etc."ssh/sshd_config.d/50-nix-path.conf" = { + replaceExisting = true; + text = '' + SetEnv PATH=/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/bin + ''; + }; +} diff --git a/system-manager/yuge/sudo.nix b/system-manager/yuge/sudo.nix new file mode 100644 index 0000000..720f789 --- /dev/null +++ b/system-manager/yuge/sudo.nix @@ -0,0 +1,9 @@ +{...}: { + environment.etc."sudoers.d/50-nix-path" = { + mode = "0440"; + replaceExisting = true; + text = '' + Defaults secure_path="/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" + ''; + }; +} diff --git a/system-manager/yuge/tailscale.nix b/system-manager/yuge/tailscale.nix new file mode 100644 index 0000000..cc5dfb9 --- /dev/null +++ b/system-manager/yuge/tailscale.nix @@ -0,0 +1,22 @@ +{pkgs, ...}: { + systemd.services.tailscaled = { + description = "Tailscale node agent"; + documentation = ["https://tailscale.com/docs/"]; + wants = ["network-pre.target"]; + after = ["network-pre.target" "NetworkManager.service" "systemd-resolved.service"]; + wantedBy = ["system-manager.target"]; + + serviceConfig = { + Type = "notify"; + ExecStart = "${pkgs.tailscale}/bin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tailscaled.sock --port=41641"; + ExecStopPost = "${pkgs.tailscale}/bin/tailscaled --cleanup"; + Restart = "on-failure"; + RuntimeDirectory = "tailscale"; + RuntimeDirectoryMode = "0755"; + StateDirectory = "tailscale"; + StateDirectoryMode = "0700"; + CacheDirectory = "tailscale"; + CacheDirectoryMode = "0750"; + }; + }; +}