diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..941914d --- /dev/null +++ b/flake.lock @@ -0,0 +1,58 @@ +{ + "nodes": { + "crate2nix": { + "flake": false, + "locked": { + "lastModified": 1665362239, + "narHash": "sha256-vNMu88WotPaOfuzubfOsLcaHB9WwDfV5/drEzY8tpFo=", + "owner": "kolloch", + "repo": "crate2nix", + "rev": "cdcdd4950cc6ef1133b5f866a7c20dc06c130a84", + "type": "github" + }, + "original": { + "owner": "kolloch", + "repo": "crate2nix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1665634984, + "narHash": "sha256-zwXeMc96BD9iFxSB/SLr3dI8iYpqM+seX9qy6bGV+cw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cfea568da97a2668ef3cb3fc42eaacfb0e706807", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "crate2nix": "crate2nix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..037f57b --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + description = "like jq, but for HTML."; + + inputs = { + nixpkgs.url = "nixpkgs"; # Resolves to github:NixOS/nixpkgs + # Helpers for system-specific outputs + flake-utils.url = "github:numtide/flake-utils"; + crate2nix = { + url = "github:kolloch/crate2nix"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, crate2nix, flake-utils }: + # Create system-specific outputs for the standard Nix systems + # https://github.com/numtide/flake-utils/blob/master/default.nix#L3-L9 + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + crateName = "htmlq"; + + inherit (import "${crate2nix}/tools.nix" { inherit pkgs; }) + generatedCargoNix; + + project = pkgs.callPackage (generatedCargoNix { + name = crateName; + src = ./.; + }) { + defaultCrateOverrides = pkgs.defaultCrateOverrides // { + # Crate dependency overrides go here + }; + }; + in { + packages.${crateName} = project.rootCrate.build; + + defaultPackage = self.packages.${system}.${crateName}; + + devShell = pkgs.mkShell { + inputsFrom = builtins.attrValues self.packages.${system}; + buildInputs = [ pkgs.cargo pkgs.rust-analyzer pkgs.clippy ]; + }; + }); +}