guides
Your First Flake
Create your first conformant flake with Weyl Standard.
Your First Flake
The Minimal Conformant Flake
{ description = "My weyl-std project";
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; weyl-std.url = "github:weyl-ai/weyl-std"; };
outputs = inputs@{ flake-parts, weyl-std, ... }: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ weyl-std.flakeModules.default ];
systems = [ "x86_64-linux" "aarch64-linux" ];
perSystem = { pkgs, ... }: { packages.default = pkgs.hello; devShells.default = pkgs.mkShell { packages = [ pkgs.hello ]; }; }; };
nixConfig = { extra-substituters = [ "https://weyl-ai.cachix.org" ]; extra-trusted-public-keys = [ "weyl-ai.cachix.org-1:cR0SpSAPw7wejZ21ep4SLojE77gp5F2os260eEWqTTw=" ]; };}What weyl-std Provides
When you import weyl-std.flakeModules.default, you get:
| Module | Description |
|---|---|
| formatter | treefmt with nixfmt, ruff, shfmt, etc. |
| nixpkgs | Central nixpkgs config with CUDA support |
| std | Overlays and library functions |
| devshell | Development shell utilities |
Adding a Package
Create nix/packages/my-tool.nix:
{ lib, stdenv }:stdenv.mkDerivation (finalAttrs: { pname = "my-tool"; version = "0.1.0";
src = ../../src;
meta = { description = "My tool"; license = lib.licenses.mit; mainProgram = "my-tool"; };})Then in your flake module:
perSystem = { pkgs, ... }: { packages.my-tool = pkgs.callPackage ./nix/packages/my-tool.nix { };};Enabling CUDA
imports = [ weyl-std.flakeModules.default ];
weyl-std.nixpkgs.cuda.enable = true;This configures nixpkgs with:
cudaSupport = truecudaCapabilitiesfor your target GPUs- CUDA overlays from weyl-std
Next Steps
- File Placement — Where to put your code
- Module Systems — Understanding flake-parts vs NixOS
- Forbidden Patterns — What not to do