← Back to context

Comment by worble

3 days ago

Yeah, that's exactly what I did for a while, but really once you get the hang of nix it's kind of unnecessary. I keep this bit of nix to hand for anything that I need to run

   #!/usr/bin/env nix-shell

   { pkgs ? import <nixpkgs> { } }:

  (
    let base = pkgs.appimageTools.defaultFhsEnvArgs; in
    pkgs.buildFHSUserEnv (base // {
      name = "FHS";
      targetPkgs = pkgs: (with pkgs; [
        /* add additional packages here e.g */
        pcre
        tzdata
      ]);
      runScript = "bash";
      extraOutputsToInstall = [ "dev" ];
    })
  ).env

Running `nix-shell` will drop you into a bash shell that looks just like a normal linux distribution with a lot of common libraries (thanks to `pkgs.appimageTools.defaultFhsEnvArgs`) and after trying to run your application you can shove whatever you need in the extra packages when it complains about a dependency being missing.

Obviously it's a bit more work than other distros, but once nix gets it's claws into you, you'll find it hard to go back to old ways.