From 0c889e226b468001a22df14e778862958ca7f99e Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 29 Apr 2024 18:35:27 +0200 Subject: [PATCH] Add flake.nix --- Cargo.toml | 2 ++ flake.lock | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Cargo.toml b/Cargo.toml index 98ab8f5..5a6c0f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,8 @@ name = "woossh" version = "0.1.0" edition = "2021" license = "GPL-3.0+" +description = "A websocket tunnel for SSH" +repository = "https://git.pvv.ntnu.no/oysteikt/woossh" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..50fd9d8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1714285404, + "narHash": "sha256-MmoQIO+KRiH3UnH0myAp2Fgi84rmpROMfw9VIbqrjHA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "94be183087845937b0fd77281c37d0796572b899", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1714253743, + "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1714217560, + "narHash": "sha256-zttBYGaoHpZfqWHQ8OI5f9OkGHCHb8tDBMySwsYNa2U=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f216be4a0746142c5f30835b254871256a7637b8", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e9df6c6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,67 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, fenix }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let + toolchain = fenix.packages.${system}.complete; + pkgs = import nixpkgs { + inherit system; + overlays = [ + (_: super: let pkgs = fenix.inputs.nixpkgs.legacyPackages.${system}; in fenix.overlays.default pkgs pkgs) + ]; + }; + in f system pkgs toolchain); + in { + apps = forAllSystems (system: pkgs: _: let + mkApp = program: { + type = "app"; + program = "${pkgs.lib.getExe program}"; + }; + in { + default = mkApp self.packages.${system}.default; + }); + + devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell { + packages = [ + (toolchain.withComponents [ + "cargo" "rustc" "rustfmt" "clippy" + ]) + ]; + RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/"; + }); + + overlays.default = final: prev: self.packages.${final.system}; + + packages = (forAllSystems (system: pkgs: _: { + default = let + cargo-toml = pkgs.lib.importTOML ./Cargo.toml; + in pkgs.rustPlatform.buildRustPackage rec { + pname = cargo-toml.package.name; + version = cargo-toml.package.version; + src = ./.; + + cargoSha256 = "sha256-ykcbKz8NnSw1uP8ajBVr/PGZKrDJvjFKpaFOyKoEGTc="; + + meta = with pkgs.lib; { + description = cargo-toml.package.description; + homepage = cargo-toml.package.repository; + license = licenses.mit; + platforms = systems; + mainProgram = (pkgs.lib.head cargo-toml.bin).name; + }; + }; + })); + }; +} +