aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorStanisław Zagórowski <hasohasacz@gmail.com>2024-01-12 23:20:25 +0100
committerStanisław Zagórowski <hasohasacz@gmail.com>2024-01-12 23:20:25 +0100
commitef505837c9ad56e49eef8f5080f92fa494ef6800 (patch)
treed7badac18a25d607bbd4a3dfc310d464282e2cef /flake.nix
parent14e2cc8846c844a234fb7688f84a874607dc96e9 (diff)
nixify
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix79
1 files changed, 79 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..0417539
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,79 @@
+{
+ description = "Reluax, a LuaX web framework";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ naersk.url = "github:nmattia/naersk";
+ naersk.inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ outputs = { self, nixpkgs, naersk }:
+ let
+ cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
+ supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
+ forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
+ in
+ {
+ overlay = final: prev: {
+ "${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; };
+ };
+
+ packages = forAllSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ self.overlay
+ ];
+ };
+ in
+ {
+ "${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
+ });
+
+
+ defaultPackage = forAllSystems (system: (import nixpkgs {
+ inherit system;
+ overlays = [ self.overlay ];
+ })."${cargoToml.package.name}");
+
+ checks = forAllSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ self.overlay
+ ];
+ };
+ in
+ {
+ format = pkgs.runCommand "check-format"
+ {
+ buildInputs = with pkgs; [ rustfmt cargo ];
+ } ''
+ ${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
+ ${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
+ touch $out # it worked!
+ '';
+ "${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
+ });
+ devShell = forAllSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [ self.overlay ];
+ };
+ in
+ pkgs.mkShell {
+ inputsFrom = with pkgs; [
+ pkgs."${cargoToml.package.name}"
+ ];
+ buildInputs = with pkgs; [
+ rustfmt
+ nixpkgs-fmt
+ ];
+ LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
+ });
+ };
+}
+