From aa13912e3ec97705d47207003afb6845c6859bc8 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 13 Oct 2021 15:58:07 +0530 Subject: init --- flake.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3308ce1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05"; + }; + + outputs = + { self + , nixpkgs + }: + let + 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 [ 1 2 ]; + 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"; + })); + }; +} -- cgit v1.2.3