]> Git — Sourcephile - sourcephile-nix.git/blob - Makefile
nix: add install scripts
[sourcephile-nix.git] / Makefile
1 include .lib/nix/Makefile.make
2
3 #
4 ## init
5 ###
6 .PHONY: build
7 build:
8 nix $(NIX) build -f build \
9 --out-link result \
10 --show-trace $(NIX_BUILD)
11 tree result/
12
13 init: build
14 result/bin/init
15
16 #
17 ## vmdk
18 ###
19 vmdk: var/virtualbox/nixops.vmdk
20 .PHONY: var/virtualbox/nixops.vmdk
21
22 var/virtualbox/nixops.vmdk:
23 # NOTE: user's TMPDIR may be too small
24 TMPDIR=/tmp \
25 time nix $(NIX) build \
26 --out-link var/virtualbox \
27 --argstr system x86_64-linux \
28 -f "<nixpkgs-commonsoft/build/pkgs/installer/nixops-virtualbox>"
29
30 #
31 ## create
32 ###
33 create: $(dir $(NIXOPS_STATE))
34 $(if $(filter $(NIXOPS_DEPLOYMENT),$(deployment)),,\
35 nixops create \
36 $(NIXOPS_CREATE) \
37 install/logical.nix \
38 install/physical.nix)
39 modify: $(NIXOPS_STATE)
40 nixops modify \
41 $(NIXOPS_MODIFY) \
42 install/logical.nix \
43 install/physical.nix
44
45 $(dir $(NIXOPS_STATE)):
46 mkdir -p $@
47
48 deployment = $(shell \
49 test ! -f $(NIXOPS_STATE) || \
50 sqlite3 $(NIXOPS_STATE) \
51 "select value from DeploymentAttrs \
52 where name='name' and value='$(NIXOPS_DEPLOYMENT)';")
53
54 #
55 ## deploy
56 ###
57 deploy: create
58 time nixops deploy $(NIXOPS_OPTS) $(NIXOPS_DEPLOY)
59 #TMPDIR=/tmp \
60 #time disnixos-env --use-nixops \
61 # -s install/disnix/services.nix \
62 # -d install/disnix/distribution.nix \
63 # -n install/logical.nix \
64 # -n install/physical.nix
65 %/offline: NIX_BUILD+=--option substituters ""
66 %/offline: NIXOPS_DEPLOY+=--option substituters ""
67 %/offline: %
68
69 %/verbose: NIX+=-v -v -v
70 %/verbose: %
71
72
73 stop:
74 nixops stop
75
76 #
77 ## state
78 ###
79 state: $(NIXOPS_STATE)
80 sqlite3 $(NIXOPS_STATE) .dump
81
82 privateIpv4:
83 sqlite3 $(NIXOPS_STATE) \
84 'update ResourceAttrs set value = "$(IPv4)" where name="privateIpv4"'