blob: e341db63b2d644e8f5979e718a2b150734e15dfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
{
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";
}));
};
}
|