Just a basic programmer living in California

  • 8 Posts
  • 215 Comments
Joined 2 years ago
cake
Cake day: February 23rd, 2024

help-circle


  • I agree that this doesn’t seem necessary. Personally I think Nix would be a good candidate for dependency management that works consistently between languages. I think that may be partway set up for Haskell, and I’ve noticed that nixpkgs has a good collection of Python dependencies. But for most cases the Nix flow currently usually involves using the language’s bespoke dependency manifest to generate a Nix expression that downloads dependencies from the language’s bespoke package repo.

    One advantage of Nix is that you don’t need all packages in one repo. Nixpkgs is mostly geared for the NixOS Linux distro. Each language ecosystem could have its own repo if that makes the most sense, with Nix being the common connective language.



  • I’m using Rust on the server, Typescript on the client. Some very interesting options have appeared in Typescript over time for better ADT handling!

    ts-pattern provides a match function that verifies matches are exhaustive. Yes, it’s a static check. It’s got a powerful matching language that does stuff like extract nested properties from complex inputs, like Rust’s match. I recommend reading the documentation - for me it led to some “I didn’t know that was possible!” moments.

    I’ve also been using fp-ts to get Option and Either types. (Either instead of Result because fp-ts is inspired by Haskell.) It has features for processing fallible values as monads which gets close to the conciseness of Rust’s ? operator and try Trait, but is more generalized. It also has mtl-ish types like TaskEither which roughly serve the purpose of a Promise but with an explicit error type.

    Now that you mention it, must-use detection for Either values would be helpful. Eslint has a built-in check that does exactly that for Javascript’s native Promise type. I haven’t tried it, but it looks like eslint-plugin-fp-ts has a rule that might do the same for other types.


  • I try to capture every detail of the build and test environments in Nix devshells. And where I can I try to encapsulate as much as possible in Nix checks and packages which run in build sandboxes - both locally and on the server. Build sandboxes don’t work for everything, but the devshells alone are great for reproducibility.

    • Wrong interpreter version? A devshell with a flake.lock file ensures every environment is using the exact same interpreter.
    • Accidentally picking up stuff from the local .env? Sandboxed checks and builds don’t get any files that aren’t version controlled, so that’s not an issue. But it’s still an issue with devshells.
    • Accidentally picking up programs or env vars in your environment? Sandboxed builds always get a clean starting environment. If you run nix develop --ignore-env you get a devshell that also gets a clean starting state.

    Nix doesn’t fix everything.

    • File system case sensitivity - depending on where this issue presents (program-generated files vs source files), I use property testing to catch this problem. In fact I was working on exactly that the other day.
    • Timing issues - that’s a good old fashioned hard problem. Try to make logical dependencies explicit. It’s really easy to get implicit order dependencies in concurrent code if you aren’t on guard. In languages that support it promises or futures are good for spelling out what needs to happen in what order.
    • Edit: Difficulty keeping secrets in sync - one option is to use Sops or Age to put encrypted secrets in version control. Then your CI only needs to be configured with one secret to decrypt the other secrets it needs.












  • I think Templates is for cases where you make lots of documents that have the same starting structure. Like a letter head, or a spreadsheet you recreate every month. The starting structure can be saved in Templates so you can copy it ever time you need it. Maybe I’ll put a Nix flake template there instead of always copying from a recent project.

    Public might be for files that other users have read access to on a multi user system? Or maybe for network shares? Or a personal website? I’m not sure. Edit: I found a comment saying that Gnome file sharing uses Public.