The stuff in /nix/store
is read-only, intentionally. Changing it by hand is throwing the entire concept of nixos out the window, and may cause all kinds of issues. I won’t tell you how to undo the read-only bit, just in case you actually try, or someone else reading this does. Please don’t even try to hack around it 
Rather, you want to modify the package that provides that file downstream (read: for your configuration). It’s natural that you’d like to hand-modify the files, because that’s how other distros work, given they make changing package contents or writing your own painfully cumbersome.
But this is where the really cool part of NixOS comes in, this is much easier in our world; you can do all of that with some changes to configuration.nix
.
Let’s start with what this change actually is. We’ll look at the commit that was made upstream: contentstatsid key might not be present · lutris/lutris@072e72a · GitHub
It doesn’t really matter what that change does, the important bit is that it is a change to the lutris source code. If we can apply the same change to the source of the lutris you’re using, and rebuild it, it should all magically work.
Nix allows you to take an existing package, and override how it is built. We can use that to apply the above change to the source code. In this case, we can do that like so (in configuration.nix
):
{pkgs, lib, ...}: let
# lutris-unwrapped is the "real" lutris. The lutris package that is
# installed "wraps" the "real" lutris to make it actually work on
# NixOS, but the source is compiled here.
#
# We use `overrideAttrs` to change the way the package is actually
# built. In particular, this is because we want to override
# something in the `stdenv.mkDerivation` call, this to be specific:
#
# https://github.com/NixOS/nixpkgs/blob/685d243d971c4f9655c981036b9c7bafdb728a0d/pkgs/applications/misc/lutris/default.nix#L131
lutris-unwrapped = pkgs.lutris-unwrapped.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches ++ [
# Work around https://github.com/NixOS/nixpkgs/issues/173712
#
# TODO: Remove once updated upstream
(pkgs.fetchpatch {
name = "fix-lutris-config.patch";
# Note: Putting `.diff` at the end of a GitHub commit URL will
# give us a nice patch we can just apply. Very handy!
url = "https://github.com/lutris/lutris/commit/072e72a4aefd91101b79dd05d8ce9f100a4b6b0c.diff";
sha256 = lib.fakeSha256; # Put the checksum that nix complains to you about here
})
];
});
# This is the lutris package we can actually install. It takes
# lutris-unwrapped as an input, and then creates the usable package.
#
# We therefore need to override one of its arguments, rather than
# its actual contents. We use `.override` for that. We override part
# of this line:
#
# https://github.com/NixOS/nixpkgs/blob/685d243d971c4f9655c981036b9c7bafdb728a0d/pkgs/applications/misc/lutris/fhsenv.nix#L1
lutris = pkgs.lutris.override {inherit lutris-unwrapped;};
in {
environment.systemPackages = [
# This is the lutris we created above. If you use `with pkgs;`, this will still work, `with` is confusing,
# but in a nutshell it doesn't override anything we ourselves declare in the outer "scope".
lutris
];
}
Note you can scroll that code block. Also don’t just copy that to the end of configuration.nix
, of course, weave it in so it makes sense. The let
bit should come before the big {}
with all your options, just as it is here, and reuse the environment.systemPackackages
you already have. My comments are very verbose for the purpose of explanation, don’t skim past them.
And that’s how you reproducibly and declaratively fix a bug in a package. This is literally impossible with any other distribution (well, except guix I guess, and some other even more niche distros, but they’re all just copying NixOS).
This will also create a new set of files in /nix/store
, but with that change applied, mind you.
Hope that’s enough detail, it’s the best description of overriding things in NixOS I can come up with. If you still need a hand, or my untested code doesn’t actually work, ask!