| 1 | { |
| 2 | description = "larc"; |
| 3 | |
| 4 | inputs = { |
| 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | flake-utils.url = "github:numtide/flake-utils"; |
| 7 | }; |
| 8 | |
| 9 | outputs = { self, nixpkgs, flake-utils }: |
| 10 | flake-utils.lib.eachDefaultSystem (system: |
| 11 | let |
| 12 | pkgs = nixpkgs.legacyPackages.${system}; |
| 13 | |
| 14 | /* |
| 15 | * NOTE(kroot): go-sqlite3 requires cgo, so we need to enable it |
| 16 | * and provide the necessary build inputs |
| 17 | */ |
| 18 | buildInputs = with pkgs; [ |
| 19 | sqlite |
| 20 | ]; |
| 21 | |
| 22 | nativeBuildInputs = with pkgs; [ |
| 23 | pkg-config |
| 24 | ]; |
| 25 | |
| 26 | commonGoArgs = { |
| 27 | inherit buildInputs nativeBuildInputs; |
| 28 | src = ./.; |
| 29 | vendorHash = "sha256-z45q+0un+SrgdM3a4do/TYkaFenhgc0VqZyE9eWq8PE="; |
| 30 | env.CGO_ENABLED = "1"; |
| 31 | env.GOTOOLCHAIN = "local"; |
| 32 | /* FIXME(kroot): nixpkgs has go 1.25, but go.mod wants 1.26 */ |
| 33 | postPatch = '' |
| 34 | sed -i 's/go 1.26.0/go 1.25.0/' go.mod |
| 35 | ''; |
| 36 | }; |
| 37 | |
| 38 | in { |
| 39 | packages = { |
| 40 | larc = pkgs.buildGoModule (commonGoArgs // { |
| 41 | pname = "larc"; |
| 42 | version = "0.1.0"; |
| 43 | subPackages = [ "cmd/larc" ]; |
| 44 | }); |
| 45 | |
| 46 | larcs = pkgs.buildGoModule (commonGoArgs // { |
| 47 | pname = "larcs"; |
| 48 | version = "0.1.0"; |
| 49 | subPackages = [ "cmd/larcs" ]; |
| 50 | }); |
| 51 | |
| 52 | compile = pkgs.buildGoModule (commonGoArgs // { |
| 53 | pname = "larc-compile"; |
| 54 | version = "0.1.0"; |
| 55 | subPackages = [ "cmd/compile" ]; |
| 56 | }); |
| 57 | |
| 58 | default = self.packages.${system}.larc; |
| 59 | }; |
| 60 | |
| 61 | devShells.default = pkgs.mkShell { |
| 62 | buildInputs = buildInputs ++ (with pkgs; [ |
| 63 | go_1_26 |
| 64 | gopls |
| 65 | gotools |
| 66 | go-tools |
| 67 | delve |
| 68 | ]); |
| 69 | inherit nativeBuildInputs; |
| 70 | |
| 71 | CGO_ENABLED = "1"; |
| 72 | }; |
| 73 | } |
| 74 | ); |
| 75 | } |
| 76 | |