diff --git a/contrib/.gitignore b/contrib/.gitignore new file mode 100644 index 0000000..681ba5b --- /dev/null +++ b/contrib/.gitignore @@ -0,0 +1,2 @@ +# `nix build` output +/result diff --git a/contrib/flake.lock b/contrib/flake.lock new file mode 100644 index 0000000..428b670 --- /dev/null +++ b/contrib/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1745742390, + "narHash": "sha256-1rqa/XPSJqJg21BKWjzJZC7yU0l/YTVtjRi0RJmipus=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "26245db0cb552047418cfcef9a25da91b222d6c7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/contrib/flake.nix b/contrib/flake.nix new file mode 100644 index 0000000..338b98a --- /dev/null +++ b/contrib/flake.nix @@ -0,0 +1,41 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + }; + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems f; + outputsBySystem = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages = { + default = pkgs.buildGo124Module { + pname = "cocoon"; + version = "0.1.0"; + src = ../.; + vendorHash = "sha256-kFwd2FnOueEOg/YRTQ8c7/iAO3PoO3yzWyVDFu43QOs="; + meta.mainProgram = "cocoon"; + }; + }; + devShells = { + default = pkgs.mkShell { + buildInputs = [ + pkgs.go_1_24 + pkgs.gopls + pkgs.gotools + pkgs.go-tools + ]; + }; + }; + }); + mergeOutputs = outputType: + nixpkgs.lib.mapAttrs (system: systemOutputs: systemOutputs.${outputType} or {}) outputsBySystem; + in + { + packages = mergeOutputs "packages"; + devShells = mergeOutputs "devShells"; + }; +}