-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
123 lines (108 loc) · 3.72 KB
/
flake.nix
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
nix-task.url = "../../.";
nix-task.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nixpkgs, utils, nix-task }:
utils.lib.mkFlake {
inherit self inputs;
outputsBuilder = channels: {
tasks = {
example = {
calculate = rec {
add_3_and_7 = nix-task.lib.mkTask {
stableId = [ "add_3_and_7" ];
dir = ./.;
path = with channels.nixpkgs; [
channels.nixpkgs.nodejs_20
];
artifacts = [ "homework" ];
run = ''
if [ -t 0 ] ; then
echo This shell is interactive
else
echo This shell is NOT interactive
fi
expr 3 + 7 > $out/homework
echo "got results"
cat $out/homework
${channels.nixpkgs.nodejs_20}/bin/node --version
echo "got directory"
'';
shellHook = ''
taskRunInBackground echo from shell hook
taskRunFinally echo will exit now
echo "got shell hook!"
'';
};
multiply_by_9 = nix-task.lib.mkTask {
stableId = "multiply_by_9";
deps = { inherit add_3_and_7; };
path = with channels.nixpkgs; [
nodejs
jq
];
artifacts = ["result"];
run = { deps, ... }: ''
node --version
value=`cat ${deps.add_3_and_7.artifacts.homework}`
result=`expr $value \* 9`
echo $result > $out/result
taskSetOutput "$(jq --null-input -cM --arg result $result '{result:$result}')"
'';
getOutput = output: output // {
numeric = output.result;
};
};
display_result = nix-task.lib.mkTask {
stableId = [ "display_result" ];
deps = {
inherit multiply_by_9;
foo.output.test = "blah";
};
path = with channels.nixpkgs; [
nodejs
];
run = { deps, ... }: ''
echo "got result!"
echo "${deps.multiply_by_9.output.numeric}"
echo "dummy dependency test"
echo "${deps.foo.output.test}"
echo "flake ref"
echo "$NIX_TASK_FLAKE_PATH"
echo "got all deps"
taskGetDeps
'';
};
test_separate = nix-task.lib.mkTask {
stableId = [ "test_separate" ];
run = ''
echo "hello world"
'';
};
};
passthroughTest = nix-task.lib.mkTask {
stableId = [ "passthrough_test" ];
dir = ./.;
path = with channels.nixpkgs; [
channels.nixpkgs.nodejs_20
];
impureEnvPassthrough = [ "SSH_AUTH_SOCK" ];
run = ''
echo "got ssh auth sock $IMPURE_SSH_AUTH_SOCK"
env
'';
shellHook = ''
echo "got shell hook!"
echo "got ssh auth sock $IMPURE_SSH_AUTH_SOCK"
env
'';
};
};
};
};
};
}