Quickly packaging services using Nix flakes (Part 1)

I’m writing a small guide on how to package software and services for yourself as flakes. Part one is out now here: Part 1: Quickly packaging services using Nix flakes

Somehow I really struggled with this after I first setup my nixos system as a flake. I’m also still fairly new to this, so any feedback and pointing out of the mistakes I made is appreciated!

Part 2 will hopefully come next week and I will then update this thread.

9 Likes

I finally (after only 6 months) managed to write the second part!
https://blog.lenny.ninja/part-2-quickly-packaging-services-using-nix-flakes.html

5 Likes

In part 1, you’re using the anti-pattern of import nixpkgs. Maybe update it to pkgs = nixpkgs.legacyPackages.${system}. See also: 1000 instances of nixpkgs

You may also want to link to the second part from part 1. Right now it looks like it’s just not finished.

1 Like

Updated, thanks a lot!

1 Like

The update wasn’t quite right. You changed it to pkgs = pkgs = nixpkgs.legacyPackages.${system};, the first pkgs = should be removed. I also just noticed it’s in part 2 as well, but in a different location:

nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });

should be

nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});

but thank you for the quick corrections!

1 Like