From 0c1e7da1ae9395a78fe1b2eac9ddbf6dfba5e910 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Tue, 31 Jan 2023 13:17:07 -0600 Subject: [PATCH] Add flake --- .envrc | 1 + .gitignore | 2 ++ default.nix | 12 +++++++ flake.lock | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 33 +++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 .envrc create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index b30a080..2ce430a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ **/*.rs.bk shiet.* /v*.tar.gz +.direnv +/result* diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ab39f3f --- /dev/null +++ b/default.nix @@ -0,0 +1,12 @@ +{ toolchain, makeRustPlatform, pkg-config }: + +let rustPlatform = makeRustPlatform { inherit (toolchain) cargo rustc; }; + +in rustPlatform.buildRustPackage { + name = "liveterm"; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ ]; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..433ab59 --- /dev/null +++ b/flake.lock @@ -0,0 +1,93 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1675146246, + "narHash": "sha256-upQtcca/sThA5Jkmn5pDaYFoCmPLMyv7bGFCZFcVhqM=", + "owner": "nix-community", + "repo": "fenix", + "rev": "97deb5c86b238c2a000ef4eb92fb40465f086706", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1674641431, + "narHash": "sha256-qfo19qVZBP4qn5M5gXc/h1MDgAtPA5VxJm9s8RUAkVk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9b97ad7b4330aacda9b2343396eb3df8a853b4fc", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1667629849, + "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3bacde6273b09a21a8ccfba15586fb165078fb62", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1675097868, + "narHash": "sha256-BKFLjEzdoFWso7Artln7djf8RbtBynj9wZKIj22LV5g=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "b75803ad31772d105d86f8ebee0cbc8844a4fa29", + "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..85240c0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + inputs = { fenix.url = "github:nix-community/fenix"; }; + + outputs = { self, nixpkgs, flake-utils, fenix }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ fenix.overlays.default ]; + }; + + toolchain = pkgs.fenix.stable; + + flakePkgs = { leanshot = pkgs.callPackage ./. { inherit toolchain; }; }; + in rec { + packages = flake-utils.lib.flattenTree flakePkgs; + defaultPackage = packages.leanshot; + + devShell = pkgs.mkShell { + inputsFrom = with packages; [ leanshot ]; + packages = (with pkgs; [ cargo-watch cargo-deny cargo-edit ]) + ++ (with toolchain; [ cargo rustc rustfmt ]); + + CARGO_UNSTABLE_SPARSE_REGISTRY = "true"; + PKG_CONFIG_PATH = let + standardPkgs = pkgs.lib.makeSearchPathOutput "dev" "lib/pkgconfig" + (with pkgs; [ libGL xorg.libX11 ]); + otherPkgs = pkgs.lib.makeSearchPath "pkgconfig" + (with pkgs; [ "${xorg.xorgproto}/share" ]); + in "${standardPkgs}:${otherPkgs}"; + }; + }); +}