[HN Gopher] Persistent packages on Steam Deck using Nix
       ___________________________________________________________________
        
       Persistent packages on Steam Deck using Nix
        
       Author : Rikudou
       Score  : 81 points
       Date   : 2025-02-09 18:15 UTC (4 hours ago)
        
 (HTM) web link (chrastecky.dev)
 (TXT) w3m dump (chrastecky.dev)
        
       | metadat wrote:
       | I didn't realize you could install Nix on any Linux distro. It
       | actually looks really straightforward:
       | 
       | https://forum.elivelinux.org/t/how-to-install-nix-packages-o...
       | 
       | I'm giving it a go now in the easily undoable single-user "no-
       | daemon" mode.
       | 
       | Super excited how approachable this makes Nix, I've put this off
       | for many years due to what turned out to be an incorrect
       | assumption about the level of commitment!
        
         | rendaw wrote:
         | I've been using it for developing, but for non-headless stuff
         | IIRC there's a lot of issues with opengl drivers and hardcoded
         | X11 paths and stuff. I dropped a good chunk of time before
         | giving up.
        
           | iamdbtoo wrote:
           | I'm currently experiencing this with a Tauri-based app. Nix
           | has been great for us for local dev and service builds, but
           | building an application inside of Nix that needs to run
           | outside of it has been challenging to say the least.
        
           | worble wrote:
           | Yeah, I just went through this process myself on steam deck
           | and the fact it can't access opengl or vulkan natively makes
           | anything that isn't terminal based a massive pain in the ass.
           | 
           | There is nixgl which you can wrap around any executable to
           | make it work and it's got support in home-manager
           | (https://nix-community.github.io/home-
           | manager/options.xhtml#o...) but it's a huge annoyance having
           | to wrap `config.lib.nixGL.wrap <package>` around _everything_
           | you want to install.
        
           | IshKebab wrote:
           | It's really 50 years of Unix's dumb practice of installing
           | everything at absolute paths in `/usr` that has come home to
           | roost. I wonder if Nix will finally make people write
           | relocatable apps.
        
         | Cyph0n wrote:
         | To be honest, the naming is a bit confusing. Here is my
         | understanding:
         | 
         | - Nix: build system and package manager (available on Linux and
         | macOS)
         | 
         | - Nix: language used to define how to build packages
         | 
         | - nixpkgs: Nix package monorepo
         | 
         | - NixOS: Linux distro that is fully managed using Nix
         | (language), has Nix (package manager) built-in, and is defined
         | as part of nixpkgs
        
           | soraminazuki wrote:
           | The language is also commonly referred to as Nix expressions
           | or the Nix language.
        
         | goosedragons wrote:
         | You can also do it with Guix in case you prefer Guile and more
         | strict FOSSy-ness.
        
           | kombine wrote:
           | I'm playing with Guix and even made a dedicated installation.
           | I find it more attractive than Nix (more sane language,
           | shepherd service manager), but it lacks in diversity of
           | packages and many of the ones I require are very stale.
        
             | gray_-_wolf wrote:
             | Patches are welcome :)
        
         | kombine wrote:
         | https://github.com/DeterminateSystems/nix-installer I've had
         | good experience with this installer if you have root access. I
         | also installed nix on my work HPC cluster running Ubuntu via
         | nix-portable.
        
           | bsimpson wrote:
           | For context, Determinate is a startup made of the Nix guy and
           | some of the senior community members. They explicitly support
           | the Steam Deck (and used it as a test case to create their
           | installer).
           | 
           | https://determinate.systems/posts/nix-on-the-steam-deck/
        
             | asmor wrote:
             | Not just senior community members, DetSys is the company of
             | the creator of nix.
             | 
             | This installer and the relationship between DetSys and Nix
             | has also been subject to major criticism about conflict of
             | interest between community interests and DetSys, since
             | everyone agrees the official Nix installer has major
             | issues. "Determinate Nix" (as DetSys calls the nix
             | configured with their installer) also enables features that
             | are the de-facto way to use Nix these days, but are
             | disabled in the default distribution because of... let's
             | say... commitment issues.
             | 
             | If you want a community run alternative, try Lix. They have
             | a version of the DetSys installer too - and they actually
             | cut releases of nix instead of building moats around it.
             | 
             | https://lix.systems/
        
               | abathur wrote:
               | There should (hopefully) be an ~official-nix version of
               | the detsys installer in the ~near future. (That said, one
               | slice of the reasons this has taken a while is that the
               | upstream Nix variant is obliged to stick to official
               | features for now.)
               | 
               | It's basically at the point where it just needs a
               | redirect from the nixos.org domain, and for the
               | project/community to work through how to manage its
               | development/relationship to the Nix repo.
        
           | PerryStyle wrote:
           | Just out of curiosity, have you checked out Spack,
           | https://github.com/spack/spack, which has a lot of HPC users.
           | Support for mixing and matching both system and from source
           | dependencies has been extremely useful in my work.
        
         | o11c wrote:
         | Last I checked, there was a major caveat to this - it mucks
         | with your PATH in intrusive ways. So it's not "just try it",
         | it's "switch to a frankenstein system and don't turn back"
        
           | Rikudou wrote:
           | Hmm, didn't seem that way, I specifically did it the way I
           | describe in the article to have it easily reversible, though
           | I must admit it's just theoretical, I haven't tried
           | uninstalling it.
        
         | __MatrixMan__ wrote:
         | I use it on macos for all of my dev environments. So instead of
         | a readme that tells me to install tools X,Y and Z, direnv
         | notices that I'm now in the project directory and it makes
         | those tools available and then when I switch to a different
         | project I end up with different sets of tools (pinned to the
         | same versions on all my machines, tracked by git).
         | 
         | It's a bit more involved than homebrew, but you end up with a
         | very precise definition of what your project depends on. This
         | prevents all kinds of headaches re: Linux and Mac users
         | depending on subtly different versions of grep or sed. Plus you
         | can recreate the same environment in CI and Prod without having
         | to define those dependencies separately.
         | 
         | Or you could, if your team was bought in. That's the hard part.
        
           | whatwhaaaaat wrote:
           | Just for a giggles, what projects do you work on that require
           | such variation in tooling where something like this becomes
           | worthwhile?
           | 
           | I always see these type of arguments for why nix is so great
           | but it's never been a pain point for me in 10+ languages and
           | 20 years of development experience. I see your example of
           | bash scripts but this can't be all for writing scripts.
        
             | tstrimple wrote:
             | Not the OP, but I work in consulting. When I was still
             | hands on keyboard, this would have been very helpful for
             | the clients who don't provide their own hardware or
             | environment for us to use. I also do work for extremely
             | large organizations who have literally dozens of different
             | stacks accumulated over the decades.
             | 
             | In addition, I play with all sorts of open source tools and
             | they often come with their own tool chains and
             | expectations. Python version management in particular
             | benefits a lot from this level of isolation. Instead of
             | figuring out the different version management tools for
             | each stack I use a higher order environment management tool
             | in Nix.
             | 
             | Some others are solving these issues with containers, and
             | that's a part of the nix strategy as well.
        
               | whatwhaaaaat wrote:
               | Yeah I get the idea but I'm asking op for concrete
               | examples. Python has its own environment management
               | options that work well. I've read on this site over and
               | over what it can do - I'm wondering if anyone has hard
               | examples of tooling they switch about enough to make it
               | worthwhile.
        
         | Rikudou wrote:
         | I still recommend my article, it's really similar on all Linux
         | distros and Home Manager makes it much more pleasant to use.
        
         | sweeter wrote:
         | They also have a simple uninstall command now as well. It used
         | to be kind of a pain in the butt to do but now you can just
         | install it and uninstall it in a couple minutes.
         | 
         | The determinate systems installer for Nix is honestly a really
         | great example of a great command line tool. It very
         | transparently tells you "this is what we're going to be doing.
         | Will you allow me to do all of these things?" and it tells you
         | what when it is doing them. Then they bundle the uninstaller.
        
       | talldayo wrote:
       | This is actually a bit of a match made in heaven for Nix. The
       | Steam Deck runs Arch with immutable root, which means most of the
       | AUR packages won't entirely work. So you need a package manager
       | which respects immutable root, supports atomic upgrades with Arch
       | and has a package selection similar to the AUR. There are a few
       | options, but the best one _really_ is Nix:
       | https://repology.org/repositories/statistics/newest
       | 
       | Given that package management on the Deck is traditionally
       | handled with Flatpak, Nix seems like a great alternative for
       | power users with storage to spare.
        
         | mhitza wrote:
         | VMs with Gnome Boxes also work nicely on the deck for power
         | users. With KVM, measured via geekbench, the VM incurred only a
         | 5% performance penalty.
        
           | sweeter wrote:
           | I run containers with podman as well as Waydroid for Android
           | apps. I install novel reader applications or whatever and
           | have them open in the background using TTS, while I play.
        
         | Rikudou wrote:
         | I actually use both, flatpaks for GUI apps and Nix for various
         | CLI tools, setting up my Deck like I described in the article
         | was triggered by me being too lazy to check my local game
         | server's IP on the server itself and wanted to use nmap for
         | that.
         | 
         | Long story short, it would be faster to go check the computer
         | physically. But it was more fun this way, even though I didn't
         | have the time to play the game in the end.
        
       | colordrops wrote:
       | Would love if there was a Nix flake for setting up retro gaming.
       | Last time I checked you had to install these complicated tools
       | and set them up manually.
        
         | Rikudou wrote:
         | There's EmuDeck which does all of the work for you. There's
         | also another newer package that does the same but I forgot the
         | name. At least EmuDeck can be easily installed with a flatpak,
         | no idea about the other one
        
           | asmor wrote:
           | EmuDeck is the more featureful one, but messy in a lot of
           | places - and definitely not just a flatpak. I particularly
           | hate how the ~/Emulation folder is full of _absolute_
           | symlinks (even when creating sibling folder aliases!) to
           | random places, so it can 't be properly used with Syncthing
           | unless you write your own ignore files and set up shares per
           | emulator save directory. Their Windows version is also not
           | exactly the same, so syncing media between a Windows machine
           | and a Linux one is even more annoying.
           | 
           | RetroDeck bundles everything into a single flatpak and seems
           | a lot saner, but is a lot newer.
        
           | colordrops wrote:
           | EmuDeck is exactly the package I was referring to that is a
           | pain in the ass to setup.
        
       | jquaint wrote:
       | Love using Nix for retro gaming setups. Its great to bundle
       | drivers, emulators, etc.
       | 
       | https://nixos.wiki/wiki/RetroArch
       | https://nixos.wiki/wiki/Playstation2
        
       | craftkiller wrote:
       | This is great. Nix made compiling ship of harkinian (ocarina of
       | time pc port), 2ship2harkinian (majora's mask pc port) and sm64ex
       | (super mario 64 pc port) trivial on nixos but where I really want
       | them is on my steam deck. Now I can.
        
       | bsimpson wrote:
       | > you can either run NixOS (which isn't ideal on a Steam Deck)
       | 
       | I've actually been using NixOS on my Legion Go to give me the
       | SteamOS experience while I wait for the official image from Valve
       | [1].
       | 
       | I knew that Valve had whitelisted /nix, but seeing how the author
       | explicitly loads Nix in Bash:                   .nix-
       | profile/etc/profile.d/nix.sh
       | 
       | makes me wonder how it works in game mode. Say that someone uses
       | Nix to install a game like YARG that's not in the Steam store
       | [2]. That will install the game to /nix/store and write an alias
       | to the user's desktop. /home/deck is not immutable, so you could
       | add the desktop file as a non-Steam game, and everything will
       | work as expected, right?
       | 
       | What are the boundaries between things that work everywhere,
       | things that only work after you've loaded a bash profile (e.g.
       | from a terminal), and things that only work in NixOS? What if a
       | package wants to run at login? What if it uses its own systemd
       | rules?
       | 
       | [1] https://github.com/Jovian-Experiments/Jovian-NixOS/
       | 
       | [2] https://news.ycombinator.com/item?id=42991513
        
       | 486sx33 wrote:
       | Not to be confused with *nix (Meaning any Linux or Unix)
        
       | ilrwbwrkhv wrote:
       | I bought 20 Steam Decks recently to give to one of my teams. Will
       | share this with them.
        
       | sweeter wrote:
       | Nix is great on the steam deck in so many ways. I use home
       | manager just to install my general development environment, but
       | at the same time there are some issues. like the sleep/suspend
       | button will often cause the Nix Daemon socket to stop working,
       | and you and you have to restart it, which can be kind of hard if
       | you don't have access to SSH or whatever.
        
         | Rikudou wrote:
         | To be fair, I would be very afraid of the daemon mode on a
         | Deck, that's why I went with the single user mode.
        
       ___________________________________________________________________
       (page generated 2025-02-09 23:00 UTC)