1. 36
    1. 3

      Neat! Having to patch binaries to run them was always one of the most painful parts of NixOS and the major deal breaker every time I talked about it to friends and other people. Having some automated way to patch them would help a lot!

      1. 1

        Does nix have something similar to the python context managers, that deletes packages after the operation is done?

        For example:

        with install(cerbot) as cb:
            cb update certificate
        # at this point certbot is uninstalled
        
        1. 9

          I have this function in my shell config:

          using () {
                  nix-shell -p $1 --run zsh
          }
          

          That lets me run using nmap in my terminal, and it will be installed and available as long as that terminal is open.

          It’s not eagerly uninstalled, but I know that I can run nix garbage-collect if I ever want to cleanup tools that I’m not using regularly, and in the meantime using will pick it up automatically.

          I find this super helpful for one-off utilities, it’s effectively npx for the shell in general.

          It would be pretty trivial to extend this command to remove the package after zsh exits though!

          1. 4

            Yes! nix-shell -p python3 python3Packages.requests python3Packages.pip python3Packages.readchar python3Packages.jinja2 will open up a shell that contains python3 and all those libraries, when you exit the shell everything is “uninstalled” from your system. This is exactly what I do to avoid cluttering my machine with binaries and libraries I only use once. It’s also very useful to workaround our universe of conflicting software packages, for example if you have to run some scripts in python2 and others in python3.

            I say “uninstalled” because, in reality, there’s a big cache so data isn’t actually deleted for a while.

            1. 2

              It will not remove it from disk, but it will remove it from the environment (so you will now be able to call it) with nix-shell.