-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode-slides.nix
103 lines (102 loc) · 3.56 KB
/
code-slides.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
let
#helpers
file = stepNum: { filename, extension, focus?"" }: ''
### ${filename}.${extension}
```${extension} ${focus}
${builtins.readFile ./step-${stepNum}/${filename}.${extension}}
```
'';
in
''
<!--s-->
${file "1" {filename = "flake"; extension = "nix"; /*focus = "[|3-6,14|5-7]"; */}}
note:
- Flakes are the notice board and it gives a heads up what is in the project
- Flake allows us to use nix and its packages with a lock file
- Flake allows you to describe an entire Git repository as a reliable collection of packages:
- dev environments that contains dependecies related to your project
this is usually a good starting point when you try to "discover" a project
- fully nixified packages of the reporostiry
<!--v-->
${file "2" {filename = "flake"; extension = "nix"; }}
note:
- lets pick the nodejs eco system to start with
<!--v-->
${file "2" {filename = "bash"; extension = "sh"; }}
note:
- here we run nix develop
- here we are assuming that the user that uses
our repo will know this commands exists
- and there are more then one command
- it will be nice to have them documented, or even better have them has one
known command to serve as entry point
<!--v-->
${file "3" {filename = "server"; extension = "js"; }}
<!--s-->
${let step = file "3"; in ''
${step {filename = "flake"; extension = "nix"; }}
note:
- lets try to solve this by adding a nix default package to our flake
- this is a package that creates a shell script exectuable
- inside that script it contains the commands that we were executing manually before
- it is a bit meta
- it will run nix develop
- which will search a flake file in the current folder or in one of the parent folders
and will try to run in the default devShell defined in it the node start server command
- lets see how the actual shell script looks like
---
- we can even add the package into our dev shell...
- when adding any package to the buildInputs it could be our default or the nodejs package
nix will append the bin folder to the PATH of the dev shell
- there is still an issue here we have infused 2 commands in one: node server.js and nix develop...
<!--v-->
${step {filename = "bash"; extension = "sh"; }}
note:
- nix build
- similar to nix develop it will search for the flake
- and will evualate and build the default package in it
- this process run in "closed" nix building enviorment
- which allows fetching of source code,configuring, patching, building
- this build process must end by creating a folder or a file in nix store
- when done by default it will create for us a result symlink to this file or folder in the current folder
---
''}
<!--s-->
${let step = file "4"; in ''
${step {filename = "flake"; extension = "nix";}}
<!--v-->
${step {filename = "bash"; extension = "sh"; }}
''}
<!--s-->
${let step = file "5"; in ''
${step {filename = "commands"; extension = "nix"; }}
<!--v-->
${step {filename = "flake"; extension = "nix"; }}
<!--v-->
${step {filename = "bash"; extension = "sh"; }}
''}
<!--s-->
${let step = file "6"; in ''
${step {filename = "commands"; extension = "nix"; }}
<!--v-->
${step {filename = "flake"; extension = "nix"; }}
<!--v-->
${step {filename = "bash"; extension = "sh"; }}
''}
<!--s-->
${let step = file "7"; in ''
${step {filename = "commands"; extension = "nix"; }}
<!--v-->
${step {filename = "flake"; extension = "nix"; }}
<!--v-->
${step {filename = "bash"; extension = "sh"; }}
''}
<!--s-->
${let step = file "8"; in ''
${step {filename = "commands"; extension = "nix"; }}
<!--v-->
${step {filename = "bash"; extension = "sh"; }}
<!--v-->
${step {filename = "flake"; extension = "nix"; }}
''}
''