# flake.nix { description = "Portable Ubuntu setup with XFCE, XRDP, and swap"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; home-manager.url = "github:nix-community/home-manager"; }; outputs = { self, nixpkgs, home-manager }: let system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; }; in { # Define the dev shell environment with XFCE, XRDP, and utilities devShell.${system} = pkgs.mkShell { buildInputs = [ pkgs.xfce pkgs.xfce.xfce4-terminal pkgs.xrdp ]; }; # Configuration for Home Manager, setting up XFCE and XRDP homeConfigurations.gabriel = home-manager.lib.homeManagerConfiguration { pkgs = import nixpkgs { inherit system; }; home.username = "gabriel"; home.homeDirectory = "/home/gabriel"; programs.bash.enable = true; programs.xfce.enable = true; services.xrdp.enable = true; }; # System-level configuration for creating swap, user, etc. systemConfigurations.ubuntuSetup = pkgs.lib.mkDefault { users.users.gabriel = { isNormalUser = true; shell = pkgs.bashInteractive; password = "hashedPassword"; # You can replace this with a more secure password handling mechanism }; # Create a 2GB swap file systemd.services.swapfile = { enable = true; serviceConfig.ExecStart = '' fallocate -l 2G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swapfile ''; wantedBy = [ "multi-user.target" ]; }; # Set up the swap entry in /etc/fstab system.fstab = [ { device = "/swapfile"; mountPoint = "none"; fsType = "swap"; options = "sw"; } ]; }; }; }