diff --git a/.gitignore b/.gitignore index d787975..9cfeaea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ # vim *~ *.swp + +# nix +/result diff --git a/flake.lock b/flake.lock index 72b932f..b741657 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1771121070, + "narHash": "sha256-aIlv7FRXF9q70DNJPI237dEDAznSKaXmL5lfK/Id/bI=", + "owner": "ipetkov", + "repo": "crane", + "rev": "a2812c19f1ed2e5ed5ce2ef7109798b575c180e1", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1771119812, @@ -33,6 +48,7 @@ }, "root": { "inputs": { + "crane": "crane", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } diff --git a/flake.nix b/flake.nix index bbdffe4..654a65f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,17 @@ { - description = "A replacement for the man tool"; + description = "An oauth2/oidc1 proxy, written in anger"; # Flake inputs inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs" rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix + + # crane, for nicer caching when building rust + crane.url = "github:ipetkov/crane"; }; # Flake outputs - outputs = { self, nixpkgs, rust-overlay }: + outputs = { self, nixpkgs, rust-overlay, crane }: let # Overlays enable you to customize the Nixpkgs attribute set overlays = [ @@ -20,6 +23,7 @@ rustToolchain = super.rust-bin.stable.latest.default.override { extensions = [ "rust-analyzer" "rust-src" "rust-docs" ]; }; + minimalRustToolchain = super.rust-bin.stable.latest.minimal; }) ]; @@ -50,5 +54,33 @@ ]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ libiconv ]); }; }); + + packages = forAllSystems ({ pkgs }: { + default = let + craneLib = (crane.mkLib pkgs).overrideToolchain pkgs.minimalRustToolchain; + commonArgs = { + src = pkgs.lib.cleanSourceWith { + src = ./.; + filter = + let + protoFilter = path: _type: builtins.match ".*\.proto" path != null; + in + path: type: (protoFilter path type) || (craneLib.filterCargoSources path type); + name = "source"; + }; + nativeBuildInputs = with pkgs; [ + # for one of our rust deps + cmake + # for building our config + protobuf + ]; + }; + in + craneLib.buildPackage ({ + name = "proxy-in-anger"; + version = "0.0.1"; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + } // commonArgs); + }); }; }