{ description = "A very basic flake"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05"; }; outputs = { self , nixpkgs }: let allPrograms = [ 1 2 ]; supportedSystems = [ "x86_64-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; } ); in { devShell = forAllSystems (system: let pkgs = nixpkgsFor."${system}"; in with pkgs; mkShell { nativeBuildInputs = [ gcc ]; }); apps = forAllSystems (system: let pkgs = nixpkgsFor."${system}"; execs = with builtins; map toString allPrograms; mkApp = name: with pkgs; stdenv.mkDerivation { name = "${name}"; src = ./src; buildInputs = [ gcc ]; unpackPhase = '' true ''; buildPhase = '' gcc -o main $src/${name}/main.c -fopenmp ''; installPhase = '' install -Dm755 main $out/bin/main ''; }; in with pkgs; lib.genAttrs execs (p: { type = "app"; program = "${mkApp p}/bin/main"; })); }; }