summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-05-30 07:00:28 -0400
committerseth <[email protected]>2024-05-30 07:19:01 -0400
commit936db5739a58ad5d01810c60e8ebebafc93f00ab (patch)
treefd8762027d465c68f8fffdcd78fccd40a1778f94 /flake.nix
initial commit
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix78
1 files changed, 78 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..0733e33
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,78 @@
+{
+ description = "oh yeah. we're getting ziggy with it now.";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ zig-overlay = {
+ url = "github:mitchellh/zig-overlay";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ zig-overlay,
+ ...
+ }: let
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system});
+
+ # https://github.com/mitchellh/zig-overlay?tab=readme-ov-file#usage
+ zigVersion = "master-2024-05-08";
+ zigFor = system: zig-overlay.packages.${system}.${zigVersion};
+ in {
+ devShells = forAllSystems ({
+ pkgs,
+ system,
+ ...
+ }: {
+ default = pkgs.mkShellNoCC {
+ inputsFrom = [self.packages.${system}.ziggy-with-it];
+ };
+ });
+
+ packages = forAllSystems ({
+ lib,
+ pkgs,
+ system,
+ ...
+ }: rec {
+ default = ziggy-with-it;
+ ziggy-with-it = pkgs.stdenvNoCC.mkDerivation {
+ pname = "ziggy-with-it";
+ version = self.shortRev or self.dirtyShortRev or "waaaa";
+
+ src = with lib.fileset;
+ toSource {
+ root = ./.;
+ fileset = unions [
+ (gitTracked ./src)
+ ./build.zig
+ ./build.zig.zon
+ ];
+ };
+
+ # `deps.nix` is generated with by running `zon2nix`
+ # https://github.com/nix-community/zon2nix
+ postPatch = ''
+ ln -s ${pkgs.callPackage ./deps.nix {}} $ZIG_GLOBAL_CACHE_DIR/p
+ '';
+
+ nativeBuildInputs = [
+ (pkgs.zig.hook.override {
+ # FIXME: `zig.hook` requires `zig` to have it's `meta` attribute
+ # zig-overlay requires this `meta` attribute..yay
+ zig = zigFor system // {inherit (pkgs.zig) meta;};
+ })
+ ];
+ };
+ });
+ };
+}