-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
83 lines (72 loc) · 2.45 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, rust-overlay }:
let
systems = [ "x86_64-linux" ];
forAllSystems = function:
nixpkgs.lib.genAttrs systems (system:
function (import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
}));
in {
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.fzf
pkgs.just
pkgs.hurl
pkgs.elm2nix
pkgs.watchexec
pkgs.cargo-dist
pkgs.rust-analyzer
pkgs.elmPackages.elm
pkgs.elmPackages.elm-format
pkgs.rust-bin.stable.latest.default
pkgs.elmPackages.elm-language-server
pkgs.nodePackages.vscode-langservers-extracted
(pkgs.writeShellApplication {
name = "run";
text = "watchexec -r just run";
})
];
};
});
packages = forAllSystems (pkgs:
let
ui = pkgs.callPackage ./ui/default.nix { };
rustPlatform = pkgs.makeRustPlatform {
cargo = pkgs.rust-bin.stable.latest.default;
rustc = pkgs.rust-bin.stable.latest.default;
};
pname = "octopod";
version = "0.1.2";
in rec {
default = rustPlatform.buildRustPackage {
inherit pname version;
src = ./.;
preBuild = ''
cp ${ui}/Main.js ui/Main.js
'';
cargoLock.lockFile = ./Cargo.lock;
};
image = pkgs.dockerTools.buildLayeredImage {
name = pname;
tag = "latest";
created = "now";
config.Cmd = [ "${default}/bin/octopod" ];
};
deploy = pkgs.writeShellScriptBin "deploy" ''
${pkgs.skopeo}/bin/skopeo --insecure-policy copy docker-archive:${image} docker://docker.io/frectonz/octopod:${version} --dest-creds="frectonz:$ACCESS_TOKEN"
${pkgs.skopeo}/bin/skopeo --insecure-policy copy docker://docker.io/frectonz/octopod:${version} docker://docker.io/frectonz/octopod:latest --dest-creds="frectonz:$ACCESS_TOKEN"
'';
});
formatter = forAllSystems (pkgs: pkgs.nixfmt-classic);
};
}