-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
70 lines (64 loc) · 2.29 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
{
inputs = {
"nixos-23.11".url = "github:NixOS/nixpkgs/nixos-23.11";
"nixos-unstable".url = "github:NixOS/nixpkgs/nixos-unstable";
"flake-utils".url = "github:numtide/flake-utils";
};
outputs = inputs@{ self, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
nixpkgs = {
"nixos-23.11" = import inputs."nixos-23.11" { inherit system; };
"nixos-unstable" = import inputs."nixos-unstable" { inherit system; };
};
pkgs = nixpkgs."nixos-23.11";
inherit (pkgs) runCommand crane;
inherit (pkgs.lib) fold composeExtensions concatMap attrValues;
inherit (pkgs.haskell.lib) justStaticExecutables;
combineOverrides = old:
fold composeExtensions (old.overrides or (_: _: { }));
haskellPackages = pkgs.haskell.packages.ghc810.override {
overrides = new: old: {
chris-martin-org = new.callPackage ./chris-martin-org {};
};
};
htmlPages = ./out;
container = pkgs.dockerTools.buildLayeredImage {
name = "chris-martin-org";
contents = [ pkgs.busybox htmlPages ];
config = {
Cmd = [ "${pkgs.busybox}/bin/busybox" "httpd" "-f" "-h" "${htmlPages}" ];
ExposedPorts."80/tcp" = { };
};
};
deploy = pkgs.writeShellApplication {
name = "deploy-chris-martin";
runtimeInputs = [ crane ];
text = ''
cleanup() {
rm -rf "$tmp"
}
trap cleanup EXIT
tmp="$(mktemp -d)"
nix build .#container --out-link "$tmp/container.tar.gz"
gunzip --force "$tmp/container.tar.gz" > "$tmp/container.tar"
crane push "$tmp/container.tar" registry.digitalocean.com/iowa/chris-martin:latest
'';
};
in {
packages = { inherit container htmlPages crane; };
devShells.default = pkgs.mkShell {
inputsFrom = [ haskellPackages.chris-martin-org.env ];
packages = [
pkgs.haskell.compiler.ghc810
pkgs.sassc
pkgs.cabal-install
pkgs.zlib
pkgs.rsync
pkgs.openssh
];
};
devShells.deploy = pkgs.mkShell { packages = [ deploy ]; };
}
);
}