Last active
January 9, 2026 18:32
-
-
Save sortofsleepy/d0c076e95e856cf67f1d4cc8257d1f0d to your computer and use it in GitHub Desktop.
flake template for setting up a dev environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "A very basic build flake"; | |
| inputs = { | |
| nixpkgs.url = "github:nixos/nixpkgs"; | |
| unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | |
| }; | |
| # note - helpful to use devenv + nix-devenv so shell modifications stay in place and you don't need to type "nix develop" every time. | |
| outputs = { self, nixpkgs, unstable, }: | |
| let | |
| supportedSystems = ["x86_64-linux"]; | |
| forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | |
| nixpkgsFor = forAllSystems(system: import nixpkgs { inherit system; }); | |
| in { | |
| packages = forAllSystems(system: | |
| let pkgs = nixpkgsFor.${system}; | |
| in { | |
| default = pkgs.stdenv.mkDerivation { | |
| name = "hello"; | |
| src = ./.; | |
| buildPhase = '' | |
| echo "Hello" > hello.txt | |
| ''; | |
| installPhase = '' | |
| mkdir -p $out | |
| cp hello.txt $out/ | |
| ''; | |
| }; | |
| } | |
| ); | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| description = "A very basic flake"; | |
| inputs = { | |
| nixpkgs.url = "github:nixos/nixpkgs"; | |
| unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | |
| }; | |
| # note - helpful to use devenv + nix-devenv so shell modifications stay in place and you don't need to type "nix develop" every time. | |
| outputs = { self, nixpkgs, unstable, }: | |
| let | |
| supportedSystems = ["x86_64-linux"]; | |
| forAllSystems = nixpkgs.lib.genAttrs supportedSystems; | |
| nixpkgsFor = forAllSystems(system: import nixpkgs { inherit system; }); | |
| in { | |
| devShells = forAllSystems(system: | |
| let pkgs = nixpkgsFor.${system}; | |
| in { | |
| default = pkgs.mkShell { | |
| nativeBuildInputs = [pkgs.zig]; | |
| }; | |
| # get packages required by the listed packages and bundle into the shell | |
| #inputsFrom = [ | |
| # self.packages.${system}.container | |
| #self.packages.${system}.go-hello-native | |
| #]; | |
| } | |
| ); | |
| }; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for buildflake.nix, remember to rename flake.nix