From 77f801950770940a822a7b04f7fca9eb5d122cde Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 10 Aug 2023 19:24:37 -0500 Subject: [PATCH] nix flake --- .envrc | 1 + .gitignore | 4 +- flake.lock | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 56 ++++++++++++++++++ package.json | 2 + 5 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 .envrc 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 c2fec07..bcb99f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target /node_modules -/dist \ No newline at end of file +/dist +/.direnv +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a47b531 --- /dev/null +++ b/flake.lock @@ -0,0 +1,162 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1691648495, + "narHash": "sha256-JULr+eKL9rjfex17hZYn0K/fBxxfK/FM9TOCcxPQay4=", + "owner": "nix-community", + "repo": "fenix", + "rev": "6c9f0709358f212766cff5ce79f6e8300ec1eb91", + "type": "github" + }, + "original": { + "id": "fenix", + "type": "indirect" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "flake-utils_2": { + "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" + } + }, + "napalm": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1672245824, + "narHash": "sha256-i596lbPiA/Rfx3DiJiCluxdgxWY7oGSgYMT7OmM+zik=", + "owner": "nix-community", + "repo": "napalm", + "rev": "7c25a05cef52dc405f4688422ce0046ca94aadcf", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "napalm", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1691472822, + "narHash": "sha256-XVfYZ2oB3lNPVq6sHCY9WkdQ8lHoIDzzbpg8bB6oBxA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "41c7605718399dcfa53dd7083793b6ae3bc969ff", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1663087123, + "narHash": "sha256-cNIRkF/J4mRxDtNYw+9/fBNq/NOA2nCuPOa3EdIyeDs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9608ace7009ce5bc3aeb940095e01553e635cbc7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1691709280, + "narHash": "sha256-zmfH2OlZEXwv572d0g8f6M5Ac6RiO8TxymOpY3uuqrM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cf73a86c35a84de0e2f3ba494327cf6fb51c0dfd", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "napalm": "napalm", + "nixpkgs": "nixpkgs_3" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1691604464, + "narHash": "sha256-nNc/c9r1O8ajE/LkMhGcvJGlyR6ykenR3aRkEkhutxA=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "05b061205179dab9a5cd94ae66d1c0e9b8febe08", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d63bbfe --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + description = "A very basic flake"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + inputs.napalm.url = "github:nix-community/napalm"; + + outputs = { self, nixpkgs, flake-utils, fenix, napalm }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ fenix.overlays.default napalm.overlays.default ]; + }; + + toolchain = pkgs.fenix.stable; + rustPlatform = + pkgs.makeRustPlatform { inherit (toolchain) cargo rustc; }; + version = "0.1.0"; + in rec { + defaultPackage = packages.grub; + + packages = rec { + grub = rustPlatform.buildRustPackage { + name = "grub"; + inherit version; + src = pkgs.symlinkJoin { + name = "grub-src"; + paths = [ + (pkgs.nix-gitignore.gitignoreSource [ ./.gitignore ] ./.) + frontend + ]; + }; + cargoLock = { + lockFile = ./Cargo.lock; + outputHashes = { + "mzlib-0.1.0" = + "sha256-J7dEeCTPIoKmldpAkQadDBXhJP+Zv9hNlUdpMl2L5QM="; + }; + }; + }; + + frontend = pkgs.buildNpmPackage { + name = "frontend"; + inherit version; + src = pkgs.nix-gitignore.gitignoreSource [ ./.gitignore ] ./.; + npmDepsHash = "sha256-8XYO7U5+X9/8vx/PbTWpgvbJv1D140srgOv5IaVLRxY="; + installPhase = '' + mkdir -p $out + mv dist $out + ''; + }; + }; + + devShell = pkgs.mkShell { packages = with toolchain; [ cargo rustc ]; }; + }); +} diff --git a/package.json b/package.json index 3b0d007..361332f 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,6 @@ { + "name": "grub", + "version": "0.1.0", "scripts": { "dev": "vite", "build": "vite build"