Just wanted to let others know that you can install Nix and Home Manager on your SteamDeck which allows for persistent software across system updates without anything breaking. You might need sudo for this.

Simple step by step guide with commands:

  • sh <(curl -L https://nixos.org/nix/install) --no-daemon - single user installation, from official documentation
  • source .bash_profile - load the nix env into your current session
  • nix-channel --add https://nixos.org/channels/nixos-24.11 nixpkgs - replaces your nix channel with the current stable (nix default to unstable for some reason)
  • nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz home-manager - adds the home manager channel
  • mv .bash_profile .bash_profile.bckp
  • mv .bashrc .bashrc.bckp - these two commands backup your bash config files
  • nix-shell '<home-manager>' -A install - installs home manager standalone, as per the official documentation
  • kate ~/.config/home-manager/home.nix - open your nix config file in the default text editor and put the following content there:
{ config, pkgs, ... }:
{
  home.username = "deck";
  home.homeDirectory = "/home/deck";

  programs.bash = {
    enable = true;
    initExtra = ''
      if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi

      export NIX_SHELL_PRESERVE_PROMPT=1
      if [[ -n "$IN_NIX_SHELL" ]]; then
        export PS1="$PS1(nix-shell) "
      fi
    '';
  };

  home.stateVersion = "24.11"; # don't change this even if you upgrade your channel in the future, this should stay the same as the version you first installed nix on

  home.packages = with pkgs; [
    
  ];

  programs.home-manager.enable = true;
}
  • home-manager switch - applies the configuration from the above file
  • close the terminal and open it again, everything should work

The config file tells nix to automatically load the nix environment into your terminal session. This is a fairly minimal setup where nothing is installed. If you want to install some software, simply add it to the home.packages array like so:

  home.packages = with pkgs; [
      nmap
      cowsay
  ];

After running home-manager switch, you should be able to run two new commands: nmap and cowsay.

Other very cool possibility is to install them inside a temporary shell by running: nix-shell -p nmap cowsay. This is perfect, if you only need the package(s) this once and not something you run regularly - after you exit the temporary nix-shell, the packages won’t be on your system.

Anyway, nix survives even across system upgrades, because it installs all its files into /nix or your home directory, which are preserved even when upgrading, unlike system directories.

P.S. Don’t forget to run nix-collect-garbage from time to time if you install a lot of temporary packages.

  • Fubarberry@sopuli.xyzM
    link
    fedilink
    English
    arrow-up
    7
    ·
    22 days ago

    Thanks for sharing. Another valid option is Distrobox, which lets you permanently install Debian/Fedora/Arch/etc packages.

      • Fubarberry@sopuli.xyzM
        link
        fedilink
        English
        arrow-up
        3
        ·
        22 days ago

        It’s pretty common, many immutable distros come with it pre installed as the primary way to install new software.