Skip to content

Instantly share code, notes, and snippets.

@sortofsleepy
Last active January 9, 2026 18:32
Show Gist options
  • Select an option

  • Save sortofsleepy/d0c076e95e856cf67f1d4cc8257d1f0d to your computer and use it in GitHub Desktop.

Select an option

Save sortofsleepy/d0c076e95e856cf67f1d4cc8257d1f0d to your computer and use it in GitHub Desktop.
flake template for setting up a dev environment.
{
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/
'';
};
}
);
};
}
{
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
#];
}
);
};
}
@sortofsleepy
Copy link
Author

for buildflake.nix, remember to rename flake.nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment