Skip to content

Commit e60a974

Browse files
blackheavenfrasertweedale
authored andcommitted
feature(tools): Add docker support
1 parent 90acd70 commit e60a974

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

code/hsec-tools/flake.nix

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
overrides = self: super: with pkgs.haskell.lib; {
2222
Cabal-syntax = super.Cabal-syntax_3_8_1_0;
2323
};
24+
2425
modifier = drv:
2526
pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
2627
[
@@ -31,10 +32,52 @@
3132
pkgs.nixpkgs-fmt
3233
]);
3334
};
35+
36+
gitconfig =
37+
pkgs.writeTextFile {
38+
name = ".gitconfig";
39+
text = ''
40+
[safe]
41+
directory = *
42+
'';
43+
destination = "/.gitconfig"; # should match 'config.WorkDir'
44+
};
3445
in
3546
{
47+
48+
packages.hsec-tools = pkgs.haskell.lib.justStaticExecutables (project false);
49+
packages.hsec-tools-image =
50+
pkgs.dockerTools.buildImage {
51+
name = "haskell/hsec-tools";
52+
tag = "latest";
53+
54+
copyToRoot = pkgs.buildEnv {
55+
name = "image-root";
56+
paths = [
57+
self.packages.${system}.hsec-tools
58+
pkgs.git.out
59+
gitconfig
60+
];
61+
pathsToLink = [ "/bin" "/" ];
62+
};
63+
config = {
64+
Cmd = [ "/bin/hsec-tools" ];
65+
Env = [
66+
"LOCALE_ARCHIVE=${pkgs.glibcLocales}/lib/locale/locale-archive"
67+
"LC_TIME=en_US.UTF-8"
68+
"LANG=en_US.UTF-8"
69+
"LANGUAGE=en"
70+
"LC_ALL=en_US.UTF-8"
71+
"GIT_DISCOVERY_ACROSS_FILESYSTEM=1"
72+
];
73+
Volumes = {
74+
"/advisories" = { };
75+
};
76+
WorkDir = "/";
77+
};
78+
};
3679
# Used by `nix build` & `nix run` (prod exe)
37-
defaultPackage = project false;
80+
defaultPackage = self.packages.${system}.hsec-tools;
3881

3982
# Used by `nix develop` (dev shell)
4083
devShell = project true;

0 commit comments

Comments
 (0)