commit 958007079aa061eb71e668c6d5da0311ba1972f4 Author: soup Date: Sun Oct 27 12:02:43 2024 -0400 Initial commit diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..772ae01 --- /dev/null +++ b/flake.lock @@ -0,0 +1,58 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1725930920, + "narHash": "sha256-RVhD9hnlTT2nJzPHlAqrWqCkA7T6CYrP41IoVRkciZM=", + "path": "/nix/store/20yis5w6g397plssim663hqxdiiah2wr-source", + "rev": "44a71ff39c182edaf25a7ace5c9454e7cba2c658", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "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..f33aaa2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "nixpkgs"; + }; + outputs = inputs: + let lib = import ./lib.nix; + in + inputs.flake-utils.lib.eachDefaultSystem (system: + let + nixpkgs = inputs.nixpkgs.legacyPackages.${system}; + versions = [ + ["2.0.3" "sha256-++wvqD6TunG47jp2SKW+clGOJ6Sy9CnEu2e6AgKP1X0="] + ["2.0.0" "sha256-WQ4B0sT3qTVl4/Moj0FcFg5LDZIBPbnmcfUxwrmFyYY="] + ["1.46.3" "sha256-vnDzegjO7XFqBj3dZ1T4TZfuFr3Ur2f4/2zlFUQUwSI="] + ]; + + packages = builtins.listToAttrs (builtins.map (l: + let + version = builtins.elemAt l 0; + zipHash = builtins.elemAt l 1; + in { + name = "deno-${builtins.replaceStrings ["."] ["_"] version}"; + value = lib.mkDeno { inherit version zipHash nixpkgs; }; + } + ) versions); + + in { packages = packages // { + deno-latest = packages.deno-2_0_3; + }; + }); +} diff --git a/lib.nix b/lib.nix new file mode 100644 index 0000000..ef5aa90 --- /dev/null +++ b/lib.nix @@ -0,0 +1,20 @@ +{ + mkDeno = { version, zipHash, nixpkgs }: + let url = "https://github.com/denoland/deno/releases/download/v${version}/deno-x86_64-unknown-linux-gnu.zip"; + in nixpkgs.stdenv.mkDerivation { + inherit version; + pname = "deno"; + + src = nixpkgs.fetchzip { inherit url; hash = zipHash; }; + nativeBuildInputs = with nixpkgs; [ autoPatchelfHook libgcc ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp $src/deno $out/bin/deno + + runHook postInstall + ''; + }; +}