dotfiles

My PC Dotfiles & Website
commit ed840d4b4d13fae4af9fae2b0691d21188f95f81
parent a85431844b0069c88f5d2b86a5e0000b026aee36
Author: maydayv7 <maydayv7@gmail.com>
Date:   Sun, 20 Jul 2025 20:28:39 +0530

feat: Rename `hardware.filesystem` -> `hardware.fs` and improve

Also add `fs.persist` and update Hyprland to v0.50

Diffstat:

MCHANGELOG.md | 2++
MREADME.md | 2+-
Mdevices/futura.nix | 2+-
Mdevices/valkyrie/default.nix | 3++-
Mdevices/valkyrie/minecraft.nix | 1+
Mdevices/vortex.nix | 2+-
Mflake.lock | 82++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mflake.nix | 2+-
Mmodules/README.md | 6++++--
Mmodules/apps/games/mc-server.nix | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mmodules/gui/desktop/hyprland/settings/default.nix | 12+++++-------
Mmodules/hardware/README.md | 2+-
Mmodules/hardware/filesystem.nix | 117+++++++++++++++++++++++++++++++++++++++----------------------------------------
13 files changed, 188 insertions(+), 136 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -2,6 +2,8 @@ ### July +- Update Hyprland to v0.50 +- Rename `hardware.filesystem` -> `hardware.fs` and improve - Improve `nixos apply --delta` - Add Minecraft Server Configuration - Update GNOME Extensions diff --git a/README.md b/README.md @@ -311,7 +311,7 @@ Example `flake.nix`: hardware = { boot = "efi"; cores = 4; - filesystem = "simple"; + fs.scheme = "simple"; modules = [ /* Imported from 'nixos-hardware' */]; }; diff --git a/devices/futura.nix b/devices/futura.nix @@ -11,7 +11,7 @@ hardware = { boot = "efi"; cpu.cores = 4; - filesystem = "simple"; + fs.scheme = "simple"; support = [ "laptop" ]; modules = [ "common-pc" diff --git a/devices/valkyrie/default.nix b/devices/valkyrie/default.nix @@ -19,7 +19,7 @@ hardware = { boot = "secure"; - filesystem = "advanced"; + fs.scheme = "advanced"; modules = [ "asus-zephyrus-ga402x-nvidia" ]; gpu = "nvidia"; cpu = { @@ -91,6 +91,7 @@ "wheel" "keys" "systemd-journal" + "minecraft" ]; }; } diff --git a/devices/valkyrie/minecraft.nix b/devices/valkyrie/minecraft.nix @@ -7,6 +7,7 @@ games = [ "mc-server" ]; mc-server = { memory = 16; + vc-port = 24454; config = { motd = "My World"; gamemode = "survival"; diff --git a/devices/vortex.nix b/devices/vortex.nix @@ -15,7 +15,7 @@ imports = [ { services.fwupd.enable = true; } ]; hardware = { boot = "secure"; - filesystem = "advanced"; + fs.scheme = "advanced"; modules = [ "dell-inspiron-5509" ]; cpu = { cores = 8; diff --git a/flake.lock b/flake.lock @@ -20,11 +20,11 @@ ] }, "locked": { - "lastModified": 1749155310, - "narHash": "sha256-t0HfHg/1+TbSra5s6nNM0o4tnb3uqWedShSpZXsUMYY=", + "lastModified": 1752743471, + "narHash": "sha256-4izhj1j7J4mE8LgljCXSIUDculqOsxxhdoC81VhqizM=", "owner": "hyprwm", "repo": "aquamarine", - "rev": "94981cf75a9f11da0b6dd6a1abbd7c50a36ab2d3", + "rev": "e31b575d19e7cf8a8f4398e2f9cffe27a1332506", "type": "github" }, "original": { @@ -612,11 +612,11 @@ ] }, "locked": { - "lastModified": 1748038505, - "narHash": "sha256-7L2MRMB2ONEh7wlgQzraEoA+0o88EOV87KNqZg7vpHA=", + "lastModified": 1752187517, + "narHash": "sha256-nKsdPPUQx+E8KW6i7OvGOpfpnZqRReZQpSo+cN2wiAM=", "owner": "VirtCode", "repo": "hypr-dynamic-cursors", - "rev": "761acf0e602e0f6549e5e6c0289a0402e6073489", + "rev": "cb39e89fc3e6d2113dc098c0c69a762b55004fd4", "type": "github" }, "original": { @@ -641,11 +641,11 @@ ] }, "locked": { - "lastModified": 1749145600, - "narHash": "sha256-v2kY5RDk9oyo1x9m8u83GdklC96xlJ7ka1rrvZoYL78=", + "lastModified": 1752149140, + "narHash": "sha256-gbh1HL98Fdqu0jJIWN4OJQN7Kkth7+rbkFpSZLm/62A=", "owner": "hyprwm", "repo": "hyprgraphics", - "rev": "80b754e38e836777ad3a9d5d1ffc3491b0332471", + "rev": "340494a38b5ec453dfc542c6226481f736cc8a9a", "type": "github" }, "original": { @@ -665,7 +665,7 @@ "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", "nixpkgs": [ - "nixpkgs" + "unstable" ], "pre-commit-hooks": "pre-commit-hooks", "systems": [ @@ -674,11 +674,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1749215657, - "narHash": "sha256-KCYxy6Ym6bKyX3ShAr6vXksLRxUeOngwfRjrN+E7+xU=", + "lastModified": 1752936500, + "narHash": "sha256-StLLgYbL3U2iDezMbfr/QjUtd2a0Mb+pScDSQxFElTg=", "owner": "hyprwm", - "repo": "hyprland", - "rev": "456c820d52263579e4afdc3429fdaecab12f37a5", + "repo": "Hyprland", + "rev": "91d8a629ebfffaa46290331a74a54e249dec64fe", "type": "github" }, "original": { @@ -767,11 +767,11 @@ ] }, "locked": { - "lastModified": 1749155776, - "narHash": "sha256-t1PM0wxQLQwv2F2AW23uA7pm5giwmcgYEWbNIRct9r4=", + "lastModified": 1750371812, + "narHash": "sha256-D868K1dVEACw17elVxRgXC6hOxY+54wIEjURztDWLk8=", "owner": "hyprwm", "repo": "hyprland-qtutils", - "rev": "396e8aa1c06274835b69da7f9a015fff9a9b7522", + "rev": "b13c7481e37856f322177010bdf75fccacd1adc8", "type": "github" }, "original": { @@ -796,11 +796,11 @@ ] }, "locked": { - "lastModified": 1749145882, - "narHash": "sha256-qr0KXeczF8Sma3Ae7+dR2NHhvG7YeLBJv19W4oMu6ZE=", + "lastModified": 1750371198, + "narHash": "sha256-/iuJ1paQOBoSLqHflRNNGyroqfF/yvPNurxzcCT0cAE=", "owner": "hyprwm", "repo": "hyprlang", - "rev": "1bfb84f54d50c7ae6558c794d3cfd5f6a7e6e676", + "rev": "cee01452bca58d6cadb3224e21e370de8bc20f0b", "type": "github" }, "original": { @@ -826,11 +826,11 @@ ] }, "locked": { - "lastModified": 1748526041, - "narHash": "sha256-QyUACXhQJ2+K0YxwEuAfpyCXqbdCCHj1jNAWJy+vUxw=", + "lastModified": 1752254688, + "narHash": "sha256-XJJ+frO4NOxVkoSGc1Mag8ESumzx2FmVRspOgFlMqF8=", "owner": "hyprwm", "repo": "hyprland-plugins", - "rev": "2eee96fe52fa0923c0aae647eb7901b5b51df3db", + "rev": "d723e5b153b7990d36e62a425bda3768c41dd9eb", "type": "github" }, "original": { @@ -877,11 +877,11 @@ ] }, "locked": { - "lastModified": 1747531250, - "narHash": "sha256-uDhXNURTJgQSpiaCgzqAizbblpcEWEB1WGWEqtCnLLM=", + "lastModified": 1752663231, + "narHash": "sha256-rTItuAWpzICMREF8Ww8cK4hYgNMRXJ4wjkN0akLlaWE=", "owner": "KZDKM", "repo": "Hyprspace", - "rev": "511d399120bdcafb43e57ca5ff35167c2bba6db8", + "rev": "0a82e3724f929de8ad8fb04d2b7fa128493f24f7", "type": "github" }, "original": { @@ -897,11 +897,11 @@ ] }, "locked": { - "lastModified": 1746992858, - "narHash": "sha256-0jrsiUoQi/VXM2Ji7YTOEYDYYlBI2C3ZbgQpYoAEVKI=", + "lastModified": 1752017780, + "narHash": "sha256-AidMiaqcXqTeLFWsutZZvB9zpqSttZyIBv3d2alhV+Y=", "owner": "shezdy", "repo": "hyprsplit", - "rev": "bfe9bd397ca4f7d85aa70e13eaf1d82c26f2ffb4", + "rev": "e655de2ef61b19ca28aa9976104f1733ea57cdea", "type": "github" }, "original": { @@ -922,11 +922,11 @@ ] }, "locked": { - "lastModified": 1749135356, - "narHash": "sha256-Q8mAKMDsFbCEuq7zoSlcTuxgbIBVhfIYpX0RjE32PS0=", + "lastModified": 1752252310, + "narHash": "sha256-06i1pIh6wb+sDeDmWlzuPwIdaFMxLlj1J9I5B9XqSeo=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "e36db00dfb3a3d3fdcc4069cb292ff60d2699ccb", + "rev": "bcabcbada90ed2aacb435dc09b91001819a6dc82", "type": "github" }, "original": { @@ -947,11 +947,11 @@ ] }, "locked": { - "lastModified": 1749145760, - "narHash": "sha256-IHaGWpGrv7seFWdw/1A+wHtTsPlOGIKMrk1TUIYJEFI=", + "lastModified": 1751897909, + "narHash": "sha256-FnhBENxihITZldThvbO7883PdXC/2dzW4eiNvtoV5Ao=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "817918315ea016cc2d94004bfb3223b5fd9dfcc6", + "rev": "fcca0c61f988a9d092cbb33e906775014c61579d", "type": "github" }, "original": { @@ -1161,11 +1161,11 @@ ] }, "locked": { - "lastModified": 1747372754, - "narHash": "sha256-2Y53NGIX2vxfie1rOW0Qb86vjRZ7ngizoo+bnXU9D9k=", + "lastModified": 1750779888, + "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46", + "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", "type": "github" }, "original": { @@ -1700,11 +1700,11 @@ ] }, "locked": { - "lastModified": 1749155346, - "narHash": "sha256-KIkJu3zF8MF3DuGwzAmo3Ww9wsWXolwV30SjJRTAxYE=", + "lastModified": 1751300244, + "narHash": "sha256-PFuv1TZVYvQhha0ac53E3YgdtmLShrN0t4T6xqHl0jE=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "44bf29f1df45786098920c655af523535a9191ae", + "rev": "6115f3fdcb2c1a57b4a80a69f3c797e47607b90a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix @@ -195,7 +195,7 @@ hyprland = { url = "github:hyprwm/Hyprland"; inputs = { - nixpkgs.follows = "nixpkgs"; + nixpkgs.follows = "unstable"; systems.follows = "systems"; }; }; diff --git a/modules/README.md b/modules/README.md @@ -24,6 +24,7 @@ Configuration [Builder](./configuration.nix) - `mc-server`: Configure Minecraft Server - - `memory`: Memory (GB) allocated to server - Ex. `12` - `config`: Server Properties (See [here](https://minecraft.fandom.com/wiki/Server.properties)) + - `vc-port`: Port for [Simple Voice Chat](https://modrinth.com/plugin/simple-voice-chat) - Ex. `24454` - [`base`](./base): Module that contains the base common/shared configuration - @@ -59,12 +60,13 @@ Configuration [Builder](./configuration.nix) - [`hardware`](./hardware): Module that configures device and additional hardware - - `boot`: Supported Boot Firmware - `"mbr" / "efi" / "secure"` + - `fs`: File System Configuration - + - `scheme`: Disk Filesystem Scheme - `"simple" / "advanced"` + - `persist`: System Files to Preserve across Reboots (while using `advanced` File System Layout) - `cpu` - - `cores`: Number of CPU Cores - Ex. `4` - `mode`: CPU Frequency Governor Mode - `"ondemand" / "performance" / "powersave"` - `gpu`: Discrete GPU Support - `null / "nvidia"` - - `filesystem`: Disk File System Choice - `"simple" / "advanced"` - - - `persist`: System Files to Preserve across Reboots (while using `advanced` File System Layout) - `modules`: List of Hardware Configuration Modules imported from [`inputs.hardware`](https://github.com/nixos/nixos-hardware) - Ex. `[ "common-pc" ]` - `support`: List of Additional Supported Hardware - `[ "laptop" "mobile" "printer" "virtualisation" ]` - `vm`: Configure Virtualisation Support - diff --git a/modules/apps/games/mc-server.nix b/modules/apps/games/mc-server.nix @@ -8,11 +8,21 @@ ... }: let - inherit (builtins) attrValues elem toString; - inherit (lib) mkIf mkOption types; + inherit (builtins) + elem + isInt + toString + ; + inherit (lib) + mkIf + mkOption + types + ; + cfg = config.apps.mc-server; - dataDir = "/srv/minecraft"; mem = toString cfg.memory; + vc = isInt cfg.vc-port; + dataDir = "/srv/minecraft"; in { ## Minecraft Server ## @@ -30,15 +40,22 @@ in type = types.attrs; default = { }; }; + + vc-port = mkOption { + description = "Port for Simple Voice Chat"; + type = with types; nullOr int; + default = null; + }; }; config = mkIf (elem "mc-server" config.apps.games) { - environment.persist.directories = [ dataDir ]; + hardware.fs.persist.directories = [ dataDir ]; + networking.firewall.allowedUDPPorts = mkIf vc [ cfg.vc-port ]; services.minecraft-servers = { enable = true; + inherit dataDir; eula = true; openFirewall = true; - inherit dataDir; managementSystem = { tmux.enable = false; systemd-socket.enable = true; @@ -50,37 +67,69 @@ in serverProperties = cfg.config; jvmOpts = "-Xms${mem}G -Xmx${mem}G --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15"; - symlinks.mods = pkgs.linkFarmFromDrvs "mods" (attrValues { - FabricAPI = pkgs.fetchurl { + ## Mods + symlinks.mods = pkgs.linkFarmFromDrvs "mods" [ + # Server + (pkgs.fetchurl { + # Fabric API url = "https://cdn.modrinth.com/data/P7dR8mSH/versions/F5TVHWcE/fabric-api-0.128.2%2B1.21.6.jar"; sha512 = "sha512-ttDsCuxABpyx+iFZwSbQJ9f5Xj9iYKPojr6cR/PLcW0RcK+OLk/z1BCM5e6upwACqIlUdXg3TU1t+kV1XplDHg=="; - }; - Lithium = pkgs.fetchurl { + }) + (pkgs.fetchurl { + # Lithium url = "https://cdn.modrinth.com/data/gvQqBUqZ/versions/XWGBHYcB/lithium-fabric-0.17.0%2Bmc1.21.6.jar"; sha512 = "sha512-qNaotprisQ3Qz4+BSSYNW9vSWDFHRiutAzgAFO3YV4Upcrln2X32lygzPYg2senbiZdxLqJjZd24oFuMhFxlNA=="; - }; - Krypton = pkgs.fetchurl { + }) + (pkgs.fetchurl { + # Krypton url = "https://cdn.modrinth.com/data/fQEb0iXm/versions/neW85eWt/krypton-0.2.9.jar"; sha512 = "sha512-LiMEsbF+z5V4Ou6S4m5Uyb+tMlx9/NFN7r+YkSZuspM9sA/3eIXKoIP6qW8JxVHrVvk89zs1d4nLMe2tSTn/6w=="; - }; - FerriteCore = pkgs.fetchurl { + }) + (pkgs.fetchurl { + # FerriteCore url = "https://cdn.modrinth.com/data/uXXizFIs/versions/CtMpt7Jr/ferritecore-8.0.0-fabric.jar"; sha512 = "sha512-ExuC0dNm8JZkNb/LOMNi1gTWjs8wwQbTGmJhv8hoyjqCQluz+uuqLl6hfY7tXJKEOBDrLfR5Dy+LHmwb3Jt3RQ=="; - }; - ScalableLux = pkgs.fetchurl { + }) + (pkgs.fetchurl { + # ScalableLux url = "https://cdn.modrinth.com/data/Ps1zyz6x/versions/PQLHDg2Q/ScalableLux-0.1.5%2Bfabric.e4acdcb-all.jar"; sha512 = "sha512-7I+rw7+ZH7y+Bkwel97T5w8UWofkNgViQcux4UxX6p9Z7zEvJMIFFgzL2kP2k+BdZSt/Gapx9zDK7Du19/eCCg=="; - }; - C2ME = pkgs.fetchurl { + }) + (pkgs.fetchurl { + # C2ME url = "https://cdn.modrinth.com/data/VSNURh3q/versions/y6wodInu/c2me-fabric-mc1.21.6-0.3.4%2Balpha.0.42.jar"; sha512 = "sha512-PVOx3YSgNrX7kfFaC8U45vKkrCB8R0mrGrh0lyF4vCzCDx/hwvjAjp7vCma09rLeIjFNlNBJirzwJSGd/GnXVg=="; - }; - SkinRestorer = pkgs.fetchurl { + }) + (pkgs.fetchurl { + # Player Roles + url = "https://cdn.modrinth.com/data/Rt1mrUHm/versions/aX5ZEmN4/player-roles-1.6.15.jar"; + sha512 = "sha512-MnY/OUxlEfEP1z7YizZJJPQCfIPbxCpbHytzi+gCX06VbEf7lxbB9GnahNKZAEMPoXsLfHXOuF9k8vkUrVR6hg=="; + }) + (pkgs.fetchurl { + # Skin Restorer url = "https://cdn.modrinth.com/data/ghrZDhGW/versions/fs7VElhv/skinrestorer-2.3.5%2B1.21.6-fabric.jar"; sha512 = "sha512-xQq0b3XrbvJ4Af5YpMMn4cVlNYSUtgvMsQxCDSTXn1Qw4L/DCeBvvl1Cde9FKEEoZ9VsRHzJF6deYfNQf0Wp6w=="; - }; - }); + }) + + # Client and Server + (pkgs.fetchurl { + # Jade + url = "https://cdn.modrinth.com/data/nvQzSEkH/versions/AMBKaYce/Jade-1.21.6-Fabric-19.0.3.jar"; + sha512 = "sha512-ILrp41yUsDHpb2hhm1Fhrmm5gzoBaWNOrXRepWYGiZSfK4UDNHcAqfwq2iOcNeLp7xCtVbIc4/JYi43ooYUbhA=="; + }) + ( + if vc then + (pkgs.fetchurl { + # Simple Voice Chat + url = "https://cdn.modrinth.com/data/9eGKb6K1/versions/CG0sCxee/voicechat-fabric-1.21.6-2.5.32.jar"; + sha512 = "sha512-VFY/4Aa3Pv8zT1Vm/ie8/oC8IhEFlXFHVC/DkWf5Xodt97XBkbYZAkO5tF06zddDWHNUpl0Bu66P89VOHzbh5A=="; + }) + else + { } + ) + ]; + ## Datapacks files = { "world/datapacks/veinminer.zip" = pkgs.fetchurl { url = "https://cdn.modrinth.com/data/OhduvhIc/versions/gZ4v72II/veinminer-1.3.1.zip"; diff --git a/modules/gui/desktop/hyprland/settings/default.nix b/modules/gui/desktop/hyprland/settings/default.nix @@ -110,11 +110,7 @@ in # Graphics vrr = 1; }; - - render = { - direct_scanout = true; - explicit_sync = 2; - }; + render.direct_scanout = 1; general = { allow_tearing = !fancy; @@ -123,14 +119,16 @@ in # Floating Layout snap = { enabled = true; - window_gap = 15; - monitor_gap = 10; border_overlap = true; + respect_gaps = true; + monitor_gap = 10; + window_gap = 15; }; # Visuals gaps_in = 3; gaps_out = 3; + float_gaps = 3; border_size = 2; "col.active_border" = mkForce "rgb(${base0D}) rgb(${base05}) 90deg"; }; diff --git a/modules/hardware/README.md b/modules/hardware/README.md @@ -15,7 +15,7 @@ _If the `advanced` filesystem scheme is used, the keys need to be created after ### File System -The system may be set up using either a `simple` or `advanced` filesystem layout. The advanced ZFS encrypted opt-in state filesystem configuration allows for a vastly improved experience, preventing formation of cruft and exerting total control over the device state, by erasing the system at every boot, keeping only what's required +The system may be set up using either a `simple` or `advanced` filesystem scheme. The advanced ZFS encrypted opt-in state filesystem configuration allows for a vastly improved experience, preventing formation of cruft and exerting total control over the device state, by erasing the system at every boot, keeping only what's required #### Data Storage diff --git a/modules/hardware/filesystem.nix b/modules/hardware/filesystem.nix @@ -23,18 +23,19 @@ let types ; - inherit (config.hardware) filesystem; + inherit (config.hardware.fs) scheme; in { imports = [ inputs.impermanence.nixosModule ] ++ [ (mkAliasOptionModule [ "environment" "persist" ] [ "environment" "persistence" files.path.persist ]) + (mkAliasOptionModule [ "hardware" "fs" "persist" ] [ "environment" "persistence" "/data" ]) ]; options = with types; { - hardware.filesystem = mkOption { - description = "Disk File System Choice"; + hardware.fs.scheme = mkOption { + description = "Disk Filesystem Scheme"; type = nullOr (enum [ "simple" "advanced" @@ -62,7 +63,7 @@ in ## File System Configuration ## config = mkMerge [ { - warnings = optional (filesystem == null) (options.hardware.filesystem.description + " is unset"); + warnings = optional (scheme == null) (options.hardware.fs.scheme.description + " is unset"); ## Common Partitions boot.supportedFilesystems = { @@ -72,7 +73,7 @@ in }; } - (mkIf (filesystem != null) { + (mkIf (scheme != null) { programs.fuse.userAllowOther = true; # EFI System Partition @@ -84,10 +85,21 @@ in # SWAP Partition swapDevices = [ { device = "/dev/disk/by-partlabel/swap"; } ]; boot.kernel.sysctl."vm.swappiness" = 1; + + system.activationScripts.dotfiles = + with files.path; + let + path = if scheme == "advanced" then "${persist}/" else ""; + dir = "${path}${system}"; + in + '' + chown root:keys ${dir} + chmod 774 -R ${dir} + ''; }) ## Simple File System Configuration using EXT4 ## - (mkIf (filesystem == "simple") { + (mkIf (scheme == "simple") { fileSystems = { # ROOT Partition "/" = { @@ -98,7 +110,7 @@ in }) ## Advanced File System Configuration using ZFS ## - (mkIf (filesystem == "advanced") ( + (mkIf (scheme == "advanced") ( let rollback = '' zfs rollback -r fspool/system/root@blank && echo "Rollback Complete!" @@ -203,58 +215,6 @@ in }; }; - system.activationScripts.dotfiles = - let - dir = with files.path; "${persist}/${system}"; - in - '' - chown root:keys ${dir} - chmod 774 -R ${dir} - ''; - - user.homeConfig.systemd.user.services.persist-trash = { - Unit.Description = "Persist Trash Folder"; - Install.WantedBy = [ "default.target" ]; - Service = - let - dir = '' - LOCAL="$HOME/.local/share/Trash" - PERSIST="/data/home/$USER/Trash" - mkdir -p "$LOCAL" - ''; - in - { - Type = "oneshot"; - RemainAfterExit = true; - StandardOutput = "journal"; - ExecStart = "${ - pkgs.writeShellApplication { - name = "retrieve"; - runtimeInputs = [ pkgs.coreutils ]; - text = '' - ${dir} - if [ -d "$PERSIST" ] - then - cp -r "$PERSIST"/. "$LOCAL" - rm -rf "$PERSIST" - fi - ''; - } - }/bin/retrieve"; - ExecStop = "${ - pkgs.writeShellApplication { - name = "migrate"; - runtimeInputs = [ pkgs.coreutils ]; - text = '' - ${dir} - mkdir -p "$PERSIST" - cp -r "$LOCAL"/. "$PERSIST" - ''; - } - }/bin/migrate"; - }; - }; - # Maintainence services.zfs = { trim.enable = true; @@ -267,6 +227,45 @@ in monthly = 1; }; }; + + systemd.user.services.persist-trash = { + description = "Persist Trash Folder"; + wantedBy = [ "default.target" ]; + path = [ pkgs.coreutils ]; + serviceConfig = + let + run = + script: + "${ + pkgs.writeShellApplication { + name = "script"; + runtimeInputs = [ pkgs.coreutils ]; + text = '' + LOCAL="$HOME/.local/share/Trash" + PERSIST="/data/home/$USER/Trash" + mkdir -p "$LOCAL" + ${script} + ''; + } + }/bin/script"; + in + { + Type = "oneshot"; + RemainAfterExit = true; + StandardOutput = "journal"; + ExecStart = run '' + if [ -d "$PERSIST" ] + then + cp -r "$PERSIST"/. "$LOCAL" + rm -rf "$PERSIST" + fi + ''; + ExecStop = run '' + mkdir -p "$PERSIST" + cp -r "$LOCAL"/. "$PERSIST" + ''; + }; + }; } )) ];