/ flake.nix
flake.nix
1 { 2 description = "ℵ-0xFF — minimal viable nix: fmt, lint, buck2, remote"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 6 systems.url = "github:nix-systems/default"; 7 flake-parts.url = "github:hercules-ci/flake-parts"; 8 treefmt-nix.url = "github:numtide/treefmt-nix"; 9 10 # LLVM 22 from git - required for nv toolchain 11 llvm-project = { 12 url = "github:llvm/llvm-project/bb1f220d534b0f6d80bea36662f5188ff11c2e54"; 13 flake = false; 14 }; 15 16 # Buck2 prelude (straylight fork with NVIDIA support) 17 buck2-prelude = { 18 url = "github:weyl-ai/straylight-buck2-prelude"; 19 flake = false; 20 }; 21 22 # NativeLink - Local/Remote Execution for Buck2 23 nativelink.url = "github:TraceMachina/nativelink"; 24 25 # ghc-source-gen from git (Hackage version doesn't support GHC 9.12) 26 # Required for grapesy -> proto-lens-protoc -> ghc-source-gen 27 ghc-source-gen-src = { 28 url = "github:google/ghc-source-gen"; 29 flake = false; 30 }; 31 32 # NVIDIA SDK - CUDA 13.0 runtime libraries for libtorch 33 nvidia-sdk = { 34 url = "github:weyl-ai/nvidia-sdk"; 35 inputs.nixpkgs.follows = "nixpkgs"; 36 }; 37 }; 38 39 outputs = 40 inputs@{ flake-parts, ... }: 41 flake-parts.lib.mkFlake { inherit inputs; } { 42 systems = import inputs.systems; 43 44 imports = [ 45 ./nix/modules/flake/_index.nix 46 (import ./nix/modules/flake/buck2/default.nix { inherit inputs; }) 47 ]; 48 49 # Export overlays 50 flake.overlays = (import ./nix/overlays inputs).flake.overlays; 51 52 # Export modules for downstream flakes 53 flake.flakeModules = { 54 default = import ./nix/modules/flake/default.nix { inherit inputs; }; 55 formatter = import ./nix/modules/flake/formatter.nix { inherit inputs; }; 56 lint = ./nix/modules/flake/lint.nix; 57 buck2 = import ./nix/modules/flake/buck2/default.nix { inherit inputs; }; 58 buck2-old = ./nix/modules/flake/buck2.nix; 59 build = ./nix/modules/flake/build/flake-module.nix; 60 devshell = ./nix/modules/flake/devshell.nix; 61 nativelink = ./nix/modules/flake/nativelink/flake-module.nix; 62 std = import ./nix/modules/flake/std.nix { inherit inputs; }; 63 }; 64 65 # Export lib for downstream use 66 flake.lib = import ./nix/lib { inherit (inputs.nixpkgs) lib; } // { 67 buck2 = import ./nix/lib/buck2.nix { inherit inputs; }; 68 }; 69 70 # Lint configs exported by lint.nix module 71 # Lint rules exported here (no module for this yet) 72 flake.lintRules = ./linter/rules; 73 74 # Export Dhall prelude 75 flake.dhall = ./dhall; 76 77 # Self-use: packages and minimal devshell for this repo 78 perSystem = 79 { pkgs, ... }: 80 let 81 # GHC 9.12 with haskell overlay applied (via std.nix) 82 inherit (pkgs.haskell.packages) ghc912; 83 84 in 85 { 86 packages.aleph-lint = pkgs.callPackage ./nix/packages/aleph-lint.nix { }; 87 88 # Declare examples as a Buck2 project 89 buck2.projects.examples = { 90 src = ./.; 91 targets = [ 92 "//src/examples/cxx:hello-cxx" 93 "//src/examples/haskell:hello-hs" 94 "//src/examples/rust:hello-rs" 95 "//src/examples/lean:hello-lean" 96 "//src/examples/purescript:halogen-todo" 97 "//src/examples/blake:blake" 98 ]; 99 toolchain = { 100 cxx.enable = true; 101 haskell = { 102 enable = true; 103 ghcPackages = ghc912; 104 packages = hp: [ 105 hp.aeson 106 hp.bytestring 107 hp.containers 108 hp.directory 109 hp.process 110 hp.text 111 hp.crypton 112 hp.memory 113 hp.hasktorch 114 ]; 115 }; 116 rust.enable = true; 117 lean.enable = true; 118 python = { 119 enable = true; 120 package = pkgs.python3.withPackages (ps: [ ps.numpy ]); 121 }; 122 nv.enable = true; 123 purescript.enable = true; 124 }; 125 remoteExecution = { 126 enable = true; 127 scheduler = "aleph-scheduler.fly.dev"; 128 schedulerPort = 443; 129 cas = "aleph-cas.fly.dev"; 130 casPort = 443; 131 tls = true; 132 instanceName = "main"; 133 }; 134 devShellPackages = [ 135 pkgs.ast-grep 136 pkgs.dhall 137 pkgs.dhall-json 138 ghc912.haskell-language-server 139 ]; 140 }; 141 142 # Example with NativeLink remote execution enabled 143 # Usage: nix develop .#buck2-examples-remote 144 # buck2 build --prefer-remote //src/examples/cxx:hello-cxx 145 buck2.projects.examples-remote = { 146 src = ./.; 147 targets = [ 148 "//src/examples/cxx:hello-cxx" 149 "//src/examples/haskell:hello-hs" 150 "//src/examples/rust:hello-rs" 151 ]; 152 toolchain = { 153 cxx.enable = true; 154 haskell = { 155 enable = true; 156 ghcPackages = ghc912; 157 packages = hp: [ 158 hp.aeson 159 hp.bytestring 160 hp.containers 161 hp.text 162 ]; 163 }; 164 rust.enable = true; 165 }; 166 remoteExecution = { 167 enable = true; 168 scheduler = "aleph-scheduler.fly.dev"; 169 schedulerPort = 443; 170 cas = "aleph-cas.fly.dev"; 171 casPort = 443; 172 tls = true; 173 instanceName = "main"; 174 }; 175 }; 176 177 }; 178 }; 179 }