add "init" template for an empty dev env

This commit is contained in:
Mitchell Hashimoto 2022-11-10 14:02:57 -08:00
parent 5ef08a767b
commit 16cb5d1851
No known key found for this signature in database
GPG key ID: 523D5DC389D273BC
4 changed files with 68 additions and 0 deletions

View file

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