nix flake

This commit is contained in:
Michael Zhang 2023-08-10 19:24:37 -05:00
parent 53f2105d24
commit 77f8019507
5 changed files with 224 additions and 1 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
/target /target
/node_modules /node_modules
/dist /dist
/.direnv
/result

162
flake.lock Normal file
View file

@ -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
}

56
flake.nix Normal file
View file

@ -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 ]; };
});
}

View file

@ -1,4 +1,6 @@
{ {
"name": "grub",
"version": "0.1.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build" "build": "vite build"