mirror of
https://github.com/mitchellh/zig-overlay.git
synced 2025-02-05 17:02:48 +02:00
add "init" template for an empty dev env
This commit is contained in:
parent
5ef08a767b
commit
16cb5d1851
4 changed files with 68 additions and 0 deletions
|
@ -47,5 +47,10 @@
|
|||
path = ./templates/compiler-dev;
|
||||
description = "A development environment for Zig compiler development.";
|
||||
};
|
||||
|
||||
templates.init = {
|
||||
path = ./templates/init;
|
||||
description = "A basic, empty development environment.";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
5
templates/init/.envrc
Normal file
5
templates/init/.envrc
Normal file
|
@ -0,0 +1,5 @@
|
|||
# If we are a computer with nix-shell available, then use that to setup
|
||||
# the build environment with exactly what we need.
|
||||
if has nix; then
|
||||
use nix
|
||||
fi
|
46
templates/init/flake.nix
Normal file
46
templates/init/flake.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
description = "An empty project that uses Zig.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/release-22.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
zig.url = "github:mitchellh/zig-overlay";
|
||||
|
||||
# Used for shell.nix
|
||||
flake-compat = {
|
||||
url = github:edolstra/flake-compat;
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
} @ inputs: let
|
||||
overlays = [
|
||||
# Other overlays
|
||||
(final: prev: {
|
||||
zigpkgs = inputs.zig.packages.${prev.system};
|
||||
})
|
||||
];
|
||||
|
||||
# Our supported systems are the same supported systems as the Zig binaries
|
||||
systems = builtins.attrNames inputs.zig.packages;
|
||||
in
|
||||
flake-utils.lib.eachSystem systems (
|
||||
system: let
|
||||
pkgs = import nixpkgs {inherit overlays system;};
|
||||
in rec {
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
zigpkgs.master
|
||||
];
|
||||
};
|
||||
|
||||
# For compatibility with older versions of the `nix` binary
|
||||
devShell = self.devShells.${system}.default;
|
||||
}
|
||||
);
|
||||
}
|
12
templates/init/shell.nix
Normal file
12
templates/init/shell.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
(import
|
||||
(
|
||||
let
|
||||
flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat;
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = flake-compat.locked.narHash;
|
||||
}
|
||||
)
|
||||
{src = ./.;})
|
||||
.shellNix
|
Loading…
Add table
Reference in a new issue