44
submitted 2 weeks ago* (last edited 2 weeks ago) by rikudou@lemmings.world to c/steamdeck@sopuli.xyz

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.

you are viewing a single comment's thread
view the rest of the comments
[-] Fubarberry@sopuli.xyz 7 points 2 weeks ago

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

[-] rikudou@lemmings.world 2 points 2 weeks ago

Distrobox seems to use docker/podman? Not what I'm after, but I'll read more on it, never heard of it before.

[-] Fubarberry@sopuli.xyz 3 points 2 weeks ago

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

this post was submitted on 07 Dec 2024
44 points (97.8% liked)

Steam Deck

15053 readers
183 users here now

A place to discuss and support all things Steam Deck.

Replacement for r/steamdeck_linux.

As Lemmy doesn't have flairs yet, you can use these prefixes to indicate what type of post you have made, eg:
[Flair] My post title

The following is a list of suggested flairs:
[Discussion] - General discussion.
[Help] - A request for help or support.
[News] - News about the deck.
[PSA] - Sharing important information.
[Game] - News / info about a game on the deck.
[Update] - An update to a previous post.
[Meta] - Discussion about this community.

Some more Steam Deck specific flairs:
[Boot Screen] - Custom boot screens/videos.
[Selling] - If you are selling your deck.

These are not enforced, but they are encouraged.

Rules:

Link to our Matrix Space

founded 3 years ago
MODERATORS