mirror of
https://github.com/mitchellh/zig-overlay.git
synced 2025-02-05 17:02:48 +02:00
Initial commit based on original arqv repository
This commit is contained in:
commit
223a4e3b2c
8 changed files with 2754 additions and 0 deletions
20
.github/workflows/update.yml
vendored
Normal file
20
.github/workflows/update.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
name: update-sources
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
update-sources:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.3.4
|
||||||
|
- uses: cachix/install-nix-action@v12
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
- run: ./update
|
||||||
|
- run: "git config user.email mitchellh@users.noreply.github.com"
|
||||||
|
- run: "git config user.name zig-overlay"
|
||||||
|
- run: "git add -A"
|
||||||
|
- run: "git commit -m 'update sources.json' | true"
|
||||||
|
- run: "git push -u origin main"
|
||||||
|
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
sources.json.bak
|
61
README.md
Normal file
61
README.md
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
# Nix Flake for Zig
|
||||||
|
|
||||||
|
This repository is a Nix flake packaging the [Zig](https://ziglang.com)
|
||||||
|
compiler. The flake mirrors the binaries built officially by Zig and
|
||||||
|
does not build them from source.
|
||||||
|
|
||||||
|
Provided packages:
|
||||||
|
|
||||||
|
* Nightly versions updated daily (`.master.<date>`), starting from version
|
||||||
|
`0.8.0-dev.1140+9270aae07` dated 2021-02-13, and latest master
|
||||||
|
(`.master.latest`) for the sake of convenience.
|
||||||
|
* Release versions.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Flake Support
|
||||||
|
|
||||||
|
In your `flake.nix` file:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs.zig.url = "github:mitchellh/zig-overlay";
|
||||||
|
outputs = { self, zig, ... }: {
|
||||||
|
...
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In a shell:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# run the latest version (0.7.1)
|
||||||
|
$ nix run 'github:mitchellh/zig-overlay'
|
||||||
|
# open a shell with master version dated 2021-02-13 (oldest version available)
|
||||||
|
$ nix shell 'github:mitchellh/zig-overlay#master."2021-02-13"'
|
||||||
|
# open a shell with latest master version
|
||||||
|
$ nix shell 'github:mitchellh/zig-overlay#master.latest'
|
||||||
|
```
|
||||||
|
|
||||||
|
### No Flake Support
|
||||||
|
|
||||||
|
Import in your project as you would normally (`pkgs.fetchFromGitHub` or
|
||||||
|
`builtins.fetchgit`). The `default.nix` exposes a `pkgs` argument for possible
|
||||||
|
pinning of the nixpkgs repository, and a `system` argument which defaults to
|
||||||
|
`builtins.currentSystem`.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# It is a good idea to use an exact commit in place of 'main' here.
|
||||||
|
let zigf = fetchTarball "https://github.com/mitchellh/zig-overlay/archive/main.tar.gz" in
|
||||||
|
# If you're using home-manager
|
||||||
|
home.packages = [ zigf.master.latest ]; # or any available version
|
||||||
|
# If you're using NixOS
|
||||||
|
users.user.<username>.packages = [ zigf.master.latest ]; # or any available version
|
||||||
|
# ...the rest of your configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
## Thanks
|
||||||
|
|
||||||
|
This repository is originally hosted by the username `arqv`. This user
|
||||||
|
and repository disappeared at some point and I had a local checkout so
|
||||||
|
I've forked it, modified it, and reuploaded it here.
|
46
default.nix
Normal file
46
default.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{ pkgs ? import <nixpkgs> {},
|
||||||
|
system ? builtins.currentSystem }:
|
||||||
|
|
||||||
|
let inherit (pkgs) lib;
|
||||||
|
releases = builtins.fromJSON (lib.strings.fileContents ./sources.json);
|
||||||
|
in lib.attrsets.mapAttrs (k: v:
|
||||||
|
if k == "master" then
|
||||||
|
lib.attrsets.mapAttrs (k: v:
|
||||||
|
(pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "zig";
|
||||||
|
inherit (v.${system}) version;
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
inherit (v.${system}) url sha256;
|
||||||
|
};
|
||||||
|
dontConfigure = true;
|
||||||
|
dontBuild = true;
|
||||||
|
dontFixup = true;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/{doc,bin,lib}
|
||||||
|
cp -r docs/* $out/doc
|
||||||
|
cp -r lib/* $out/lib
|
||||||
|
cp zig $out/bin/zig
|
||||||
|
'';
|
||||||
|
}))
|
||||||
|
v
|
||||||
|
else
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "zig";
|
||||||
|
inherit (v.${system}) version;
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
inherit (v.${system}) url sha256;
|
||||||
|
};
|
||||||
|
dontConfigure = true;
|
||||||
|
dontBuild = true;
|
||||||
|
dontFixup = true;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/{doc,bin,lib}
|
||||||
|
cp -r ${if k == "0.6.0" then "doc/*"
|
||||||
|
else
|
||||||
|
if k == "0.7.0" then "langref.html"
|
||||||
|
else "docs/*"} $out/doc
|
||||||
|
cp -r lib/* $out/lib
|
||||||
|
cp zig $out/bin/zig
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
releases
|
43
flake.lock
generated
Normal file
43
flake.lock
generated
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1610051610,
|
||||||
|
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1613343273,
|
||||||
|
"narHash": "sha256-YlSATlS8L16u1ooX/cCN7/vFcsI1TTOQegIc9dt/mco=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "be864bbd6763cd4c92777643b9c4c6f07c3390d5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
21
flake.nix
Normal file
21
flake.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
description = "Zig compiler binaries.";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||||
|
# List of systems where binaries are provided.
|
||||||
|
let
|
||||||
|
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
|
||||||
|
in flake-utils.lib.eachSystem systems (system:
|
||||||
|
let pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in rec {
|
||||||
|
packages = import ./default.nix { inherit system pkgs; };
|
||||||
|
defaultPackage = packages."0.7.1";
|
||||||
|
apps.zig = flake-utils.lib.mkApp { drv = defaultPackage; };
|
||||||
|
defaultApp = apps.zig;
|
||||||
|
});
|
||||||
|
}
|
2505
sources.json
Normal file
2505
sources.json
Normal file
File diff suppressed because it is too large
Load diff
57
update
Executable file
57
update
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#! nix-shell -p ruby -i ruby
|
||||||
|
|
||||||
|
require 'net/http'
|
||||||
|
require 'json'
|
||||||
|
require 'pathname'
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
|
ZIG_URI = URI("https://ziglang.org/download/index.json")
|
||||||
|
DEFAULT_SYSTEMS = ["x86_64-linux", "aarch64-linux", "aarch64-darwin", "x86_64-darwin"]
|
||||||
|
|
||||||
|
response = JSON.parse(Net::HTTP.get(ZIG_URI))
|
||||||
|
sources = if Pathname.new("sources.json").exist?
|
||||||
|
JSON.parse(File.read("sources.json"))
|
||||||
|
else
|
||||||
|
{ "master" => {} }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Update versions
|
||||||
|
response.each do |k, v|
|
||||||
|
unless k == "master"
|
||||||
|
sources[k] = DEFAULT_SYSTEMS.to_h do |system|
|
||||||
|
data = if system == "x86_64-darwin"
|
||||||
|
response[k]["x86_64-macos"] or {}
|
||||||
|
elsif system == "aarch64-darwin"
|
||||||
|
response[k]["aarch64-macos"] or {}
|
||||||
|
else
|
||||||
|
response[k][system] or {}
|
||||||
|
end
|
||||||
|
[system, { "url" => data["tarball"],
|
||||||
|
"version" => k,
|
||||||
|
"sha256" => data["shasum"] }]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Update master
|
||||||
|
sources["master"][response["master"]["date"]] = DEFAULT_SYSTEMS.to_h do |system|
|
||||||
|
data = if system == "x86_64-darwin"
|
||||||
|
response["master"]["x86_64-macos"]
|
||||||
|
elsif system == "aarch64-darwin"
|
||||||
|
response["master"]["aarch64-macos"]
|
||||||
|
else
|
||||||
|
response["master"][system]
|
||||||
|
end
|
||||||
|
[system, { "url" => data["tarball"],
|
||||||
|
"version" => response["master"]["version"],
|
||||||
|
"sha256" => data["shasum"] }]
|
||||||
|
end
|
||||||
|
sources["master"]["latest"] = sources["master"][response["master"]["date"]]
|
||||||
|
|
||||||
|
FileUtils.cp "sources.json", "sources.json.bak"
|
||||||
|
File.write "sources.json", JSON.pretty_generate(sources)
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: ruby
|
||||||
|
# End:
|
Loading…
Add table
Reference in a new issue